[SCIFIO] ImgOpener - ImgOptions - SubRegions

Mark Hiner hinerm at gmail.com
Mon Aug 26 09:44:23 CDT 2013


Hi Michael,

 Right now I get an ArrayIndexOutOfBounds at line 60 of the
ByteArrayLoader, as it tries to populate the ImgPlus using planes read by
SCIFIO.

 On my end, this is because the ImgPlus gets constrained properly to the
desired subregion, but ImgOpener tries to jam in all 21 Z slices.. so the
source is too big for the destination, and it gets AIOOB when copying,
eventually.

  Looks like the SubRegion application only considered if the SubRegion
actually contains a given Axis for X and Y. Then for ZCT it just always
applies whatever constraints it has. (e.g. it was trying to constrain C to
0-10 instead of Z, because the dimension order was CZT)

  I standardized this check so it's the same for each axis, and now your
code works for me :)

  Fixed on latest master (issue 58<https://github.com/scifio/scifio/issues/58>
).

- Mark


On Mon, Aug 26, 2013 at 9:04 AM, Michael Zinsmaier <michael.zinsmaier at gmx.de
> wrote:

> Hi Mark,
>
> if you get the same error that is thrown at my place its an
> ArrayIndexOutof Bounds ...
> I tried to track it down already and it might be an Error in ImgOpener
> readPlanes  line 599 following.
>
> The while loop skips X, and Y but enters CHANNEL although the Subregion is
> set for Z which seems to be realted to this snippet
> "dimsPlaced < region.size()"
>
> I'm not sure what  is going on there but it seems somehow incorrect (-:
> maybe this helps you
>
> best Michael
>
>
> Am Montag, 26. August 2013 15:38:44 schrieb Mark Hiner:
>
>> Hi Michael,
>>
>>  I was able to confirm this code fails locally, although I don't think
>> it's an issue with the calibration (or your code).
>>
>> Without SCIFIO-BF-compat, this fails because it defaults to the
>> MinimalTIFFReader, which compresses the axes to a single plane (thus
>> there is no Z, thus it fails).
>>
>> With SCIFIO-BF-compat, it opens correctly as an LSM.. but it seems
>> that the ImgPlus that's created is too small. The # of dimensions are
>> being read correctly (e.g., same as in the current FIJI) so I'm not
>> sure why the array is the wrong size.. looking into it now.
>>
>> - Mark
>>
>>
>> On Mon, Aug 26, 2013 at 1:07 AM, Michael Zinsmaier
>> <michael.zinsmaier at gmx.de <mailto:michael.zinsmaier at gmx.**de<michael.zinsmaier at gmx.de>>>
>> wrote:
>>
>>     Hi Mark,
>>
>>     I get the error for a dataset with axes > 2. I perpared some
>>     sample code (maybe something is wrong here) and I'll send you the
>>     file in a seperate mail.
>>
>>     Regards Michael
>>
>>     ------------------------------**------------------------------**----
>>
>>         public static void main(String[] args) throws FormatException,
>>     IOException, ImgIOException, InstantiableException {
>>                 String imgRef =
>>     "C:/Users/zinsmaie/Desktop/**bilder/5d/2chZT.lsm";
>>
>>                 Context c = new Context(SciJavaService.class,
>>     SCIFIOService.class);
>>                 SCIFIO sci = new SCIFIO(c);
>>
>>                 Reader reader = sci.initializer()
>>                         .initializeReader(imgRef, true);
>>
>>                 ImgOptions options = new ImgOptions();
>>
>>     //WORKS
>>     //                DimRange[] ranges = new DimRange[] {new
>>     DimRange("0")};
>>     //                AxisType[] axes = new AxisType[] {Axes.CHANNEL};
>>     //EXCEPTION
>>                     DimRange[] ranges = new DimRange[] {new
>>     DimRange("0-10")};
>>                     AxisType[] axes = new AxisType[] {Axes.Z};
>>     //WORKS
>>     //                    DimRange[] ranges = new DimRange[] {new
>>     DimRange("0"), new DimRange("0-10")};
>>     //                    AxisType[] axes = new AxisType[]
>>     {Axes.CHANNEL, Axes.Z};
>>
>>
>>                     options.setRegion(new SubRegion(axes, ranges));
>>
>>             ImgPlus<RealType> ret = new ImgOpener().openImg(reader,
>>                         new UnsignedByteType(), new ArrayImgFactory(),
>>     options);
>>
>>             System.out.println(ret.**getName());
>>         }
>>
>>>     Hi Michael,
>>>
>>>      I was only able to reproduce this when trying to create a
>>>     SubRegion for Axes that weren't present.
>>>
>>>      In the case of ImgOpener, Axes of length 1 are discarded... so
>>>     they effectively "aren't present" and can't have a SubRegion
>>>     applied to them (since they are implicitly included anyway in the
>>>     image).
>>>
>>>      Unfortunately, I'm not sure how to make the error reporting
>>>     better, in general, on this issue.. since, when constructing a
>>>     SubRegion, there's no way to know what dataset(s) it will be
>>>     applied to... it's up to the consuming software to use the
>>>     SubRegion information when reading the dataset.
>>>
>>>      I could add some defensive checks to verify that axes are
>>>     present.. but this whole system is going to be reworked in 0.7.0
>>>     for N-dimensionality. So I'm going to add a comment to our N-dim
>>>     ticket <https://github.com/scifio/**scifio/issues/19<https://github.com/scifio/scifio/issues/19>>
>>> to test this.
>>>
>>>
>>>      For now, in your code, can you check if an axis length is < 2
>>>     before creating the SubRegion, and if so - don't add it to the
>>>     SubRegion specification?
>>>
>>>      Oh - if you are getting this issue for Axes you know have a
>>>     length > 1, send me the dataset, because something else is going
>>>     on there. :)
>>>
>>>     Thanks,
>>>     Mark
>>>
>>>
>>>
>>>
>>>     On Fri, Aug 23, 2013 at 2:55 AM, Michael Zinsmaier
>>>     <michael.zinsmaier at gmx.de <mailto:michael.zinsmaier at gmx.**de<michael.zinsmaier at gmx.de>>>
>>> wrote:
>>>
>>>         Hi together,
>>>
>>>         defining intervals via the ImgOptions mechanism seems not to
>>>         work if you define an Interval only for one Axes (except for
>>>         Channel).
>>>         E.g. consider that you want to select only time=0 from a 5dim
>>>         Image (x,y,Channel,z,Time) and define the SubRegion as follows
>>>         new SubRegion(new AxesType[]{Time}, new Range[]{0}). An array
>>>         index out of bounds exception is thrown.
>>>
>>>         It does however work if you do the same thing with Channel
>>>         and it works also if you specify Ranges for Channel, Z and Time.
>>>
>>>         The API of SubRegion (Map Constructor) gives me the feeling
>>>         that is should not be necessary to specify Axes that I want
>>>         to include completly.
>>>         I hope thats correct if not I would like to suggest to change it.
>>>
>>>         Best regards
>>>         Michael
>>>
>>>
>>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://scif.io/pipermail/scifio/attachments/20130826/cefaa0c3/attachment-0002.html>


More information about the SCIFIO mailing list