Skip to content

Conversation

@dietzc
Copy link

@dietzc dietzc commented Sep 1, 2016

I experienced an IndexOutOfBoundsException when running the following code:

public static void main(String[] args) {
        Context ctx = new Context();
        try {
            FormatService service = ctx.getService(FormatService.class);
            for (Format f : service.getAllFormats()) {
                System.out.println(Arrays.toString(f.getSuffixes()));
            }
            final Format format = ctx.getService(FormatService.class).getFormat("/home/dietzc/Downloads/example.czi",
                    new SCIFIOConfig().checkerSetOpen(true));

            Reader reader = format.createReader();
            final Parser p = format.createParser();

            reader.setMetadata(p.parse("/home/dietzc/Downloads/example.czi"));

            final Metadata meta = reader.getMetadata();

            final OMEMetadata omexml = new OMEMetadata(ctx);

            ctx.getService(TranslatorService.class).translate(meta, omexml, false);

            final String xml = omexml.getRoot().dumpXML();

            System.out.println(xml);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }

The proposed fix doesn't rely on the existence of a bin anymore, rather uses only the imageindex to get the information about the BigEndian. I've no idea why the other method with index,binIdx was called before, maybe @hinerm can comment on this?

Also I don't know if this fix has side-effects, I can just say that the IndexOutOfBoundsException is resolved with this PR. @ctrueden what do you think?

images may not have bins attached. This will cause an
IndexOutOfBoundsException.
@dietzc
Copy link
Author

dietzc commented Sep 1, 2016

I've the feeling it has something to do with: ome/bioformats@9878804.

@maierl
Copy link

maierl commented Sep 4, 2016

Thanks @dietzc for the fix, without that I couldn't read any of my images.
👍

@ctrueden
Copy link
Member

ctrueden commented May 9, 2017

@dietzc Sorry for the dropping the ball here. Is this still an outstanding issue which needs to be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants