Extract values at voxels within a segment

Hello everyone,

I want to extract HU values at each voxel from my CT scan files, which for I use the following command:

HU_Array = slicer.util.array(‘myfile.nrrd’)

However, using “nrrd” file I get the values at all voxels. I was wondering if there is a way that I can extract values in a specific area after segmenting?

Thank you,
Zahra

Run either the maskvolume or Split Volume effect with your segmentaiton and then run your one liner.

MaskVolume will set all voxels out of segmentation are to 0 (or your value of your choosing). While SplitVolume will crop out everything outside of the segmentation area.

Thank you @muratmaga for your reply. Do you know how I can get " the coordinates of voxels" inside a specific segmentation, instead of the whole nrrd file?

If you mean the physical (RAS) coordinates, I think you can rework this example:

Thank you @muratmaga for your help.

If you want to know the coordinates of all voxels with a specific value you can work from this example: https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#get-the-values-of-all-voxels-for-a-label-value

That’s very useful, I appreciate that.