Get image intensity histogram of a segment

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 past 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

1 Like