How to export voxel intensity


(Happyle123456) #1

Operating system:windows 7
Slicer version:both slicer 4.6 and 4.7
I made a segmentation and clip a volume with module,then how can i get the intensity value of each voxel list in a spreadsheet?the coordinate is not necessary.thanks


(Andras Lasso) #2

Probably Segment statistics module provides this information. If not, then please describe in more detail what exactly you would need.


(Happyle123456) #3

I need the data of every voxel which have been shown at data probe,just simply a list of voxel value,coordinate included is fine,but not the statistical parametre of them.
maybe it would be like:
x,y,z,value



(Andras Lasso) #4

Probably the simplest would be to get the volume as a numpy array and then write out the voxel indices and values you are interested in. Something like this (this outputs all voxels that has value >260):

import numpy as np
voxelArray = slicer.util.arrayFromVolume(getNode('MRHead'))
indices = np.where(voxelArray>260)
numberOfVoxels = len(indices[0])
for pointIndex in range(numberOfVoxels):
  i = indices[0][pointIndex]
  j = indices[1][pointIndex]
  k = indices[2][pointIndex]
  print("%d %d %d %d" % (i, j, k, voxelArray[i,j,k]))

See some more examples in the script repository: https://www.slicer.org/wiki/Documentation/Nightly/ScriptRepository#Modify_voxels_in_a_volume

If you need physical (RAS) coordinates instead of voxel coordinates (IJK) then you have to multiply the (x,y,z,1) vector from the left with the volume’s IJKToRAS matrix.


(Happyle123456) #5

it’s awesome,thank you very much,it’a great help:smiley::smiley:


(Costas Papadopoulos) #6

I still try to convert ijk to LPS? Is it possible to provide an example for the vector multiplication? Thanks in advance


(Andras Lasso) #7

Search for “ijktoras.multiplypoint” in Slicer script repository for examples.