mobie / mobie-viewer-fiji

BSD 2-Clause "Simplified" License
29 stars 12 forks source link

trouble opening files via regex #1101

Closed k-dominik closed 4 months ago

k-dominik commented 4 months ago

I currently have troubles opening files via regexes in MoBiE:

I go via the menu: MoBiE -> open -> Open Image and Labels... and get the following error

[ERROR] Command errored: Open Image and Labels...
java.lang.IndexOutOfBoundsException: Index (1) is greater than or equal to list size (1)
    at it.unimi.dsi.fastutil.bytes.ByteArrayList.getByte(ByteArrayList.java:267)
    at tech.tablesaw.columns.strings.ByteDictionaryMap.getValueForIndex(ByteDictionaryMap.java:142)
    at tech.tablesaw.api.StringColumn.get(StringColumn.java:185)
    at tech.tablesaw.columns.strings.AbstractStringColumn.getString(AbstractStringColumn.java:42)
    at tech.tablesaw.table.Relation.getString(Relation.java:713)
    at tech.tablesaw.table.Relation.getString(Relation.java:701)
    at org.embl.mobie.lib.files.FileSourcesDataSetter.addGridView(FileSourcesDataSetter.java:158)
    at org.embl.mobie.lib.files.FileSourcesDataSetter.addDataAndDisplaysAndViews(FileSourcesDataSetter.java:115)
    at org.embl.mobie.MoBIE.openImagesAndLabels(MoBIE.java:221)
    at org.embl.mobie.MoBIE.<init>(MoBIE.java:175)
    at org.embl.mobie.command.open.OpenImageAndLabelsCommand.run(OpenImageAndLabelsCommand.java:79)
    at org.scijava.command.CommandModule.run(CommandModule.java:196)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
    at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:750)

example regex for these files would be iso-.*.png

example-png-no-open.zip

tischi commented 4 months ago

WOW, there were many things broken 🤯 ...not sure when this happened; MoBIE needs tests....

If all your images look the same then this would work now:

image

Would you have more complex scenarios for me to test, maybe also something with labels and/or pixel probabilities? Ideal would be a minimal dataset that would cover everything that ilastik could produce; then we could build a test around this data....

k-dominik commented 4 months ago

I'll produce something!

tischi commented 4 months ago

In fact, we have something already for single images:

https://github.com/mobie/mobie-viewer-fiji/blob/main/src/test/java/org/embl/mobie/command/OpenIlastik2DImageAndSegmentationCommandTest.java

Another issue here is that the test are not run....

k-dominik commented 4 months ago

Hi Tischi,

I created some data that could be used for testing. It contains raw (raw data) pc (pixel classification prediction maps) and oc (object classification label image + tables):

data layout ``` . ├── README.txt ├── oc # object classification results │   ├── iso.2602_Object Identities.h5 │   ├── iso.2602_table.csv │   ├── iso.2603_Object Identities.h5 │   ├── iso.2603_table.csv │   ├── iso.2604_Object Identities.h5 │   └── iso.2604_table.csv ├── pc # pixel classification results │   ├── iso.2602_Probabilities.h5 │   ├── iso.2603_Probabilities.h5 │   └── iso.2604_Probabilities.h5 └── raw # raw data ├── iso.2602.png ├── iso.2603.png └── iso.2604.png ```

I have confirmed that I can open these individually in MoBiE (not using regexes).

MoBiE-ilastik-example-output-multiple.zip

tischi commented 4 months ago

Thanks! Great test case!

Spaces in file names... iso.2603_Object Identities.h5 not ideal... ;-)

k-dominik commented 4 months ago

I know, but that is default output of ilastik (unfortunately). Plus I thought it adds to the challenge :). While you can enforce no spaces for your own work, people will be adding spaces :D

tischi commented 4 months ago

Works:

        final OpenMultipleImagesAndLabelsCommand command = new OpenMultipleImagesAndLabelsCommand();
        command.image0 = new File( "src/test/resources/ilastik-multiple/raw/iso.*.png" );
        command.image1 = new File( "src/test/resources/ilastik-multiple/pc/iso..*_Probabilities.h5" );
        command.labels0 = new File( "src/test/resources/ilastik-multiple/oc/iso..*_Object Identities.h5" );
        command.table0 = new File( "src/test/resources/ilastik-multiple/oc/iso..*_table.csv" );
        command.run();
image
tischi commented 4 months ago

This is still not ideal.