I also need to export voxel intensities of a segmentation to analyse the histogram offline with my software. I applied this script in Python. What next? Where may I find the results?
You can get the histogram of a segment in 6 lines of Python code as shown here. Just copy paste the example code into Slicerâs Python console to try it.
Hi Andras,
Thank you very much for answering.
Your example doesnât work but most likely because it has to be adapted to my node names? Here a copy of an example with the data names. Could you adapt the script to my situation? It will allow me to understand how it works and then being capable to fit the script to my other situations.
I noticed that it is now possible to export the histogram in the Parenchyma Analysis module of CIP but the data are only available from -1024 to -350 HU and I need the whole data.
Thank you very much for your help.
I really appreciate it
Regards
Benjamin
The link above points to a complete example, including generating sample data, to make sure that you can start from something that works and you can modify it step-by-step to do exactly what you need. If you work with your own data then replace âGenerate input dataâ section and just set masterVolumeNode
and segmentationNode
to your nodes (e.g., segmentationNode=getNode('Segmentation')
).
It works !!! Thanks so much +++++
Sorry for my ignorance, Iâm just a beginner in codingâŚ
Much appreciate
Have a nice day
B
Hi,
Thanks for the really good example, I have an other problem.
I am trying to make a histogram of a segment made using the Grow From Seeds module, but i can´t make it work.
This is the output format from the function i see in 3D slicer
self.extentGrowthRatio = 0.1
masterImageExtent = (0, 447, 0, 447, 0, 111)
labelsEffectiveExtent = (100, 267, 61, 189, 35, 76)
labelsExpandedExtent = [84, 283, 49, 201, 31, 80]
It would be great if someone could help with some code!
It does not matter what segmentation tools you used for creating your segmentation. After you finished segmentation using Grow from seeds
, click Apply
and proceed the same way as you would do after using any other tool.
Thanks, Andreas, but I am still struggeling (sorry, real noobie here)
For my imput data i use
segmentationNode=getNode(âSegmentationâ)
masterVolumeNode=getNode(âSegmentationâ)
But i have no ideas on how to find the segmentID from the Grow From Seeds function
I really appreciate such a quick answer on an old thread!
Use the grayscale volume as masterVolumeNode.
You get the segment ID when you create the segment, you can store that and use later when you need it.
You can also get all the segment IDs by calling:
segmentationNode.GetSegmentation().GetSegmentIDs()
If you want to get the segment ID from the segment name that you see in the application GUI:
segmentId = segmentationNode.GetSegmentation().GetSegmentIdBySegmentName(segmentName)
Thank you very much! Now it works! This was very helpful