mstritt/orbit-image-analysis

Generating Masks from Annotations

GiovannaMariaDimitri opened this issue · 7 comments

Hi Manuel,

I want to train your resnet glomeruli segmentation model on the dataset of mice with the segmentation you provided with the article.
The segmentation are in the db file format, but to run the segmentation model, I need to export them into png to save them then in the mask folders, as you show in the deep learning scripts.
Could you provide with the script needed to export the annotations in the relevant format for the masks, to then run the relative deep learning scripts?

Thanks
Giovanna

Hi Giovanna,

I didn't use this script myself, but I think that it is a good starting point:
https://github.com/mstritt/orbit-image-analysis/blob/master/src/main/groovy/com/actelion/research/orbit/imageAnalysis/scripts/deepLearning/Annotations2Maps.groovy

Either you need to figure out the orbit IDs of the images that you are looking at. Or you can use the image provider local method: LoadRawDataFilesSearch() to search and return the list of image ids that you need.

Best,

Jon

Dear Jon,

thanks for getting back to me on this!
Very much appreciated. Te id of the images.
What is the groovy function to get the id of the image which is currently displayed?
I cannot find it in previous scripts.

Thanks!

Giovanna

Hi @GiovannaMariaDimitri ,
with
'''OrbitImageAnalysis.getInstance().getIFrame()''
you get the current focused image.
(and with getIFrames() all open images).
Then you can call getRDF().getRdfId() to get the Id or use use the (in the IFrame embedded) RecognitionFrame directly.
Hope that helps!
Cheers,
Manuel

Dear Manuel,

thanks!
I have tried the code you suggested, but the function getRdfId() is not recognized. The getRDF should be lower case, and I fixed it, but for the second function I can't find which function you meant.

I attach for you my code:

MY CODE

final OrbitImageAnalysis OIA = OrbitImageAnalysis.getInstance();
ImageFrame iFrame = OIA.getIFrame();
//println("selected image: "+iFrame);
IdImage=iFrame.getRdf().getRdfId()
######## END OF MY CODE #####

ERROR GENERATED

groovy.lang.MissingMethodException: No signature of method: com.actelion.research.orbit.beans.RawDataFile.getRdfId() is applicable for argument types: () values: []
Possible solutions: getMd5(), getUserId(), getClass(), getEnding(), getFlags()
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:70)
at org.codehaus.groovy.runtime.callsite.PojoMetaClassSite.call(PojoMetaClassSite.java:46)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:47)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:115)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:119)
at Script1.run(Script1.groovy:26)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:437)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:475)
at groovy.lang.GroovyShell.evaluate(GroovyShell.java:446)
at com.actelion.research.orbit.imageAnalysis.components.ScriptEditor$1$2.run(ScriptEditor.java:123)
at java.base/java.lang.Thread.run(Unknown Source)

Could you suggest what is the problem?
Also once this is solved, then I should pass directly the variable obtained which I called IdImage in the sample above, to the code to get the snippet? For example in the example Jon pointed at (https://github.com/mstritt/orbit-image-analysis/blob/master/src/main/groovy/com/actelion/research/orbit/imageAnalysis/scripts/deepLearning/Annotations2Maps.groovy) the IdImage should be saved in the images=[IdImage] ?

Thanks

Giovanna

Also @mstritt could you provide directly the script you use to export from the orbit.db file the annotations, into masks and images in jpg e png format?

Thanks!

Giovanna

You need to use: getRawDataId()

If you're not already using an IDE (recommend IntelliJ) to write your script then I would recommend seeing about getting it set up so that you can use the auto-completion functionality. Then copy-paste the script into Orbit to run it.

The Annotations2Maps.groovy file linked in my first post shows how to convert an annotation into a mask and write it as a png file.

Dear Jon and Manuel,

thanks for all of your feedbacks! I kind of made the first script you linked to work, and I am now generating the tiles. However I have a few questions:

  1. the exclusions regions, I see annotated in the image, are they supposed to be non-glomeruli objects?. In the masks glomeruli are white, background image blue, and non-image is black, right?
  2. these exclusions regions I assume are never them saved in the masks right? From the script it looks like the masks are only generated with the objects, where the annotations of the normal groups are saved

Thanks so much for your help with this and for all of your immediate feedbacks..very much helpfull and appreciated!!!
Giovanna