BIOP / ijp-LaRoMe

some useful function to get Label from ROIs and vice versa , and more!
BSD 3-Clause "New" or "Revised" License
12 stars 4 forks source link

issues when using multichannel image (ROI to label) #21

Open pr4deepr opened 1 year ago

pr4deepr commented 1 year ago

Hi Thanks for making this tool available.

If I have a multichannel image and ROI manager open at the same time, and I run

run("ROIs to Label image");

I get the following error:

(Fiji Is Just) ImageJ 2.9.0/1.53t; Java 1.8.0_322 [64-bit]; Windows 10 10.0; 3385MB of 24368MB (13%)

java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Module threw exception
    at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:308)
    at net.imagej.legacy.DefaultLegacyHooks.interceptRunPlugIn(DefaultLegacyHooks.java:166)
    at ij.IJ.runPlugIn(IJ.java)
    at ij.Executer.runCommand(Executer.java:152)
    at ij.Executer.run(Executer.java:70)
    at java.lang.Thread.run(Thread.java:750)
Caused by: java.util.concurrent.ExecutionException: java.lang.RuntimeException: Module threw exception
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at net.imagej.legacy.LegacyService.runLegacyCompatibleCommand(LegacyService.java:304)
    ... 5 more
Caused by: java.lang.RuntimeException: Module threw exception
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:127)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:63)
    at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:225)
    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)
    ... 1 more
Caused by: java.lang.IllegalArgumentException: n out of range: 0
    at ij.ImagePlus.convertIndexToPosition(ImagePlus.java:1932)
    at ij.ImagePlus.setPosition(ImagePlus.java:1925)
    at ch.epfl.biop.ij2command.Rois2Labels.R2L(Rois2Labels.java:114)
    at ch.epfl.biop.ij2command.Rois2Labels.run(Rois2Labels.java:79)
    at org.scijava.command.CommandModule.run(CommandModule.java:196)
    at org.scijava.module.ModuleRunner.run(ModuleRunner.java:163)
    at org.scijava.module.ModuleRunner.call(ModuleRunner.java:124)
    ... 6 more

The reason I use multichannel image is because I'd like to verify if the ROIs are correct on a reference image before converting to label image. The quickfix is of course to convert to a single channel image, but it'd be convenient if LaRoMe could handle this.. :)

Cheers Pradeep

romainGuiet commented 1 year ago

Hi Pradeep,

Thank you for your bug report.

I think at the time we wrote the code, we didn't want to bother with handling ROIs and hyperStack image as it could quickly become a nightmare 😅

Could you provide me with the image and the Roiset you are using? Are the ROIs in different channels? or all in the same channel? An "issue" is that if all the ROIs are in a single channel, then the Label image will have channels which are just empty.

Another issue is that if the ROIs are associated to a channel they won't be visible in other channels (except if you remove the information of the channel associated with the ROI)

I'll try to look into it,

Best

R

pr4deepr commented 1 year ago

Hi @romainGuiet

Thanks.. It does work sometimes, but it creates a multichannel image with labels in one of the channels.

I think the ROIs are in the same channel, but sometimes users may use a different channel as a reference to draw ROIs. So, there is a possibility that it can come from a different channel Here is a sample dataset that is giving me errors biop_test.zip In this instance it throws an error. perhaps its to do with the ROIs.

The workflow I'm interested in is that irrespective of the channel no, it should create a single channel label image. I can see the value in having mutlichannel label images. That is really useful.

Cheers Pradeep