[SCIFIO] ImgOpener - ImgOptions - SubRegions
Michael Zinsmaier
michael.zinsmaier at gmx.de
Mon Aug 26 01:07:48 CDT 2013
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> 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>> 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/182c451d/attachment-0002.html>
More information about the SCIFIO
mailing list