Calculation between two scalar volumes

Dear respected experts,

I have two Dicom volumes (Volume A, Volume B). The positions are exactly same.

I would like to create a new volume by performing calculations on each voxel value.
Specifically, I would like to perform the calculation α*A + (1-α)*B and create a new volume, but what function should I use to do this in 3D Slicer?
I have already tried the “Add Scalar Volume” function, but I couldn’t make it.

I can visualize the image, but I need a dicom volume data for the image.

Thank you in advance.

A neurosurgeon from Japan

I would use numpy to do this. It is easy to get the numpy array from volumes and then moving the result back to a volume. You can get the idea looking for example at this script in the script repository:
https://slicer.readthedocs.io/en/latest/developer_guide/script_repository.html#combine-multiple-volumes-into-one

1 Like

Thank you for your kind advice. It is a bit difficut for me, but I am going to try the method you taught me. Thanks again.

I was managed to make a script to make a fusion of two volumes. Thanks, cpinter!

#  name of volume data, BONE and VESSEL
#  alfa-blending of BONE and VESSEL with a certain alfa value.

volumenode_A = slicer.util.getNode("BONE")
array_A = slicer.util.arrayFromVolume(volumenode_A)
volumenode_B = slicer.util.getNode("VESSEL")
array_B = slicer.util.arrayFromVolume(volumenode_B)
alfa = 0.05  # change this value as you like
array_C = array_A * (1 - alfa) + array_B * alfa
volumenode_C = slicer.modules.volumes.logic().CloneVolume(volumenode_A, "Calc")
slicer.util.updateVolumeFromArray(volumenode_C, array_C)