Is there a way to perform simple mathematics on voxel values and then generate an image based on them?

Hello everyone!
I was having trouble performing a task at 3Dslicer. I wanted to do some simple mathematics on the voxel values on 3d slicer ( to be exact I wanted to subtract the In-phase voxel intensity values of an abdominal MR scan from an out of phase scan (same case and no need of registration) and then divide it by in phase voxel values multiplied by 2. I would like to generate a new set of images based on the obtained values ( to be concise : (Inphase-Outphase)/inphase X 2) ).
FYI our aim is to see if it would be possible to generate a quantification heat map of the liver.
Thank you very much for everything

It sounds like what you are trying to do can all be done efficiently by accessing the volumes as numpy arrays.

https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#modify-voxels-in-a-volume

1 Like

Thank you very much for the suggestion

Hi, I’m looking to do something quite similiar on 3d slicer but not having much luck getting the Python scripts working on my data set. Did you manage to figure it out? Thanks