Get image data from reformatted CT volume slice


I need to get image data (meaning pixel/voxel values) from a reformatted CT volume slice.

I have developed a simple scripted module to load a CT volume and used the “Reformat” module in Slicer to reformat a CT slice to contain 3 predefined fiducials. Now, I would like to obtain the image data from that reformatted slice, meaning pixel/voxel values.

Is there a simple way to get that information?

I would really appreciate your help,

Thank you very much in advance,



arrayFromVolume is what you need I think.

in the example below, a is the integer array of pixel values for the MRHead.

import SampleData

sampleDataLogic = SampleData.SampleDataLogic()
masterVolumeNode = sampleDataLogic.downloadMRHead()
a = arrayFromVolume(masterVolumeNode )


I have just tried that, but “arrayFromVolume” method gives me the whole volume (3D matrix). How can I get just the pixel values of my reformatted slice?



What comes to mind are the transforms that take you from RAS to slice view XY or back, see these functions for example

This example might also be useful from the Threshold effect that takes the image from a slice view:

I’m not sure if there is anything specific to using the Reformat module that these ideas don’t take into account, but I hope this helps!

Thanks @cpinter!! I think that’s what I needed!


There is also a short example showing how to get resliced image as a volume node and access it as a numpy array:

1 Like

Quite useful! Thank you Andras!