Automation of functionality in Slicer #1004
Replies: 3 comments 3 replies
-
@tangy5 can you look into this question |
Beta Was this translation helpful? Give feedback.
-
Hi @lukasvdstricht, Do you want to use the exact code in Slicer? If you're running the MONAI Label server on the same PC, you could create a post-transform on the server side that preprocess the predicted label and store the output CSV file. Here is the post transforms for the segmentation model that processed the model prediction: https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/infers/segmentation.py#L69-L79 You may want to add a custom transform after the AsDiscreted transform. This is another idea. I'm sure @tangy5 can also help here :) |
Beta Was this translation helpful? Give feedback.
-
HI @lukasvdstricht , thank you for raising the request and question. I think @diazandr3s mentioned above is a better choice, instead of changing the MONAI Label Plugin module source code, which required recompile afterward, or reinstall local MONAI Label package. The better option is to create your function/ script in the Sample-App directory here: https://github.com/Project-MONAI/MONAILabel/tree/main/sample-apps/radiology/lib, for example: if you would like an automated metric calculation after inference/training, you could add function to the post-processing in /radiology/lib/infer/.py or in /trainer, etc... Also, it would be convenient and easy to add customize code to config for defining different models, inferer/trainer in the config folder such as spleen segmentation: https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/configs/segmentation_spleen.py Thank you, hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone
I am using MONAILabel together with Slicer to train models to automatically segment certain body parts on MRI/CT images.
The training went well and I have a decent model. I am interested in volumetric properties of the segmentation I have made with Automatic segmentation.
With the help of some existing blog posts and such, I have already succeeded in writing a Python script to generate a table with the SegmentStatistics module and save it locally as a .csv file. I would however want to automate this process even further and include in my script the step where I press Run for the automatic segmentation in MONAILabel. I am looking for how I can translate this step to Python code, similar to this.
I found the source code for this module, and I suspect that the function I’m looking for is onClickSegmentation on line 1446. The only problem is that I don’t know how to invoke this function in a Python script.
Thanks in advance!
Lukas
Beta Was this translation helpful? Give feedback.
All reactions