anyone can help how to flip the image either from right to left, or up to down?
In slice views or 3D views ?
in slicer view and also 3D viewer
In 3D views, you have the orientation widget already :
Additionally, you can rotate a 3D view with CTRL + left click + move.
In slice views, this module may help.
But, how to install in 3D Slicer
Like with any module that is not in the extension repository, download it from the source repository.
You may then add it using the GUI :
or make a custom start script with ‘–additional-module-paths </path/to/directory/containing/py_file>’.
This second method is in fact the best way to use any module.
Yes, there’s some work to do; there’s always some work to do.
You can flip slice views using “Reformat” module: select a slice view then set the LR, PA, or IS slider value to 180. We could add flip buttons there, but in general, it is not recommended to flip slice views, as using non-standard view orientations could lead to misinterpretation of the images.
If you always want Slicer to use “patient right is screen right” slice orientation convention instead of the default (and most widely used) “patient right is screen left”, then you can modify that in menu: Edit / Application settings / Views / Slice viewer defaults.
If you want to flip the image because the imaging technologist did not set the patient orientation correctly (e.g., image was acquired HFP, but the technologist forgot to switch from the default HFS patient orientation) then you must not change the slice views but instead apply a transform to the volume and rotate the volume to the correct orientation. Note that this is a rotation - it should never be necessary to flip (mirror) a 3D volume, except very few special cases (for example, create a mirrored image of the healthy side of the face to be used as a template for reconstructing the damaged other side).
@akmal871026 Which one is your case? Why do you need to flip the images?
Hi Andras,
I segmented a file and just learned that there was an orientation problem when the material was originally scanned so I would indeed like to flip (mirror) the resulting 3D volume. Is there a way to do this?
Thanks.
This python snippet will flip the dataset. The index can be 0, 1 or 2 depending on the way you want to flip. I use this code to flip nuclear medicine data that is acquired on 180 degree opposed heads. The display must be refreshed to see the change.
def flipNode(node, index):
import numpy
from vtk.util.numpy_support import vtk_to_numpy, numpy_to_vtk
imageData = node.GetImageData()
nshape = tuple(reversed(imageData.GetDimensions()))
narray = None
narray = vtk_to_numpy(imageData.GetPointData().GetScalars()).reshape(nshape)
print(narray.shape)
imgdata = numpy.flip(narray, index)
varr = numpy_to_vtk(imgdata.ravel())
imageData.GetPointData().SetScalars(varr)
import SampleData
sampleDataLogic = SampleData.SampleDataLogic()
mrHead = sampleDataLogic.downloadMRHead()
volumeNode = slicer.mrmlScene.GetFirstNodeByClass('vtkMRMLScalarVolumeNode')
flipNode(volumeNode, 0)
Mark
A post was split to a new topic: Flip image around an axis