I’m reading a Nifti File and writing it back without applying any other filter:
using ReaderType = itk::ImageFileReader;
in->SetFileName( ifname );
using WriterType = itk::ImageFileWriter< ImageType >;
WriterType::Pointer writer = WriterType::New();
writer->SetFileName( ofname );
writer->SetInput( in->GetOutput() );
This modifies [qs]form_code from ALIGNED_ANAT to SCANNER_ANAT and the matrix
srow_x = -0.428775 0.0278672 -0.0339817 90.6655
srow_y = 0.0272898 0.425193 0.712428 -117.436
srow_z = -0.00623679 -0.0553715 5.45356 -28.6827
srow_x = -0.428775 0.0278674 -0.034018 90.6655
srow_y = 0.0272896 0.425193 0.712429 -117.436
srow_z = -0.00623959 -0.0553715 5.45356 -28.6827
What is the reason for this modification?
Loss of precision. See these:
I’m having discrepancies between the orientation matrix read from DICOMs or from a Nifti generated from the same DICOM series. I’d like to understand what is going on.
I have a DICOM series that I read in the normal way using the ImageSeriesReader:
itkreader = sitk.ImageSeriesReader()
dicom_names = itkreader.GetGDCMSeriesFileNames(r"C:\tmp\DICOM_series")
itkImage = itkreader.Execute()
Then, I save this image as Nifti and MHD using a ImageFileW…
When writing a Nifti image, NiftiImageIO seems to
silently orthogonalize the IJK to LPS matrix that is written to the file.
Is this normalization really necessary? Can nifti store images with non-orthogonal axes?
(I’ve tried to decode this from nifti’s documentation, but I’ve found image orientation definition extremely complicated, with lots of ambiguities and redundancy. I hope that there is someone here who knows nifti format well.)
The difference to the problem described by RaC in the first answer is that I’m reading a Nifti file which should already be limited in precision, so it’s not a precision but a orthogonalization problem. My input Nifti was created with Matlab which seems to be more relaxed wrt orthogonality.
And yes: I’m working in the neuroimaging field.