Hi all,
I’m having some problem reading data in .nii format in a vtkMRMLScalarVolumeNode in python scripted module.
I currently use
data ,header= load(‘/‘directoryodmydata’/Sag.nii.gz’)
to read data from my dataset, and since I have loaded my image in Slicer, I want to use a different approach by reading data from the node.
Is there any way to read both the data and the header from the vtkMRMLScalarVolumeNode? I tried but my code didn’t work. Does anyone know the way of implementing this?
Hi, thanks for reply and sorry for I didn’t make my question clear. I know how to load a Volume, but I have problem reading data from the node. For instance, I loaded a .nii file as a volume, then I want to read the data and header data from that volume. I don’t know which function to use. Can someone help with this?
Hi Andras,
If I load a vtkScalarVolume in Slicer. How can I read the header of this loaded volume within slicer if I dont want to read using nrrd.read(). I can get the data of volume using
slicer.util.arrayFromVolume( volumeNode )
but how can the header be read directly using vtkMRMLscalarvolume
Hi Andras,
If I load a vtkScalarVolume in Slicer. How can I read the header of this loaded volume within slicer if I dont want to read using nrrd.read(). I can get the data of volume using
slicer.util.arrayFromVolume( volumeNode )
but how can the header be read directly using vtkMRMLscalarvolume
You can get the image geometry (origin, spacing, and axis directions), voxel type, number of components, image type from the volume node. If you store other metadata in the header then you probably need to parse the header using pynrrd or similar packages.