[Insight-developers] More orientation questions - dicom->nifti

Richard Beare richard.beare at gmail.com
Thu Sep 21 20:50:28 EDT 2006


Hi everyone,

I still haven't had any luck sorting out issues reagarding origin of
nifti files for use in spm5.

My current experiment uses ConvertBetweenFileFormats to create a nifti
file from dicom. The resulting file seems to be correctly interpreted
by spm5b, and has an origin that is close to the centre of the image
which means that spm's segmentation process seems to work OK.

However I'd like to get to the bottom of the issues regarding setting
the origin. I've noticed in Kent Williams' article "A definition of
spatial orientation for the Insight Toolkit" that origin definition is
different between ITK and dicom. I'm not sure where this is dealt with
or if I need to do anything special.

 I am using the following code to set origin, and it doesn't perform
as expected. The various diagnostics are below. Can anyone suggest how
I should address this issue?

Many thanks

-------------------------------------------------------------------
  typedef itk::Image<TPix, dim> ImType;

  typedef typename itk::ImageFileReader<ImType> ReaderType;
  typedef typename itk::ImageFileWriter<ImType> WriterType;
  typedef typename itk::ChangeInformationImageFilter<ImType> ChangeInfoType;
  typename ReaderType::Pointer reader = ReaderType::New();
  typename WriterType::Pointer writer = WriterType::New();
  typename OrienterType::Pointer orienter = OrienterType::New();
  reader->SetFileName(InputIm.c_str());
  reader->Update();

  changeInfo->SetInput(reader->GetOutput());
  changeInfo->CenterImageOn();
  writer->SetInput(changeInfo->GetOutput());
  writer->SetFileName(OutputIm.c_str());
  writer->Update();
------------------------------------------------------------------

However it doesn't seem to perform as it should. In spm display the
image details change :
before setting origin:
dimensions 256x256x248
vox 0.898 x 0.898 x 0.6
origin 156 134 120
dir cos [0 0 1, -1 0 0, -0 -1 0]

after setting origin
vox 0.898 x 0.898 x 0.6
origin 129 -81.5 -190
dir cos [0 0 1, -1 0 0, -0 -1 0]

and avwhd from fsl reports:
before
-----------------------------
qform_code     1
qto_xyz:1      0.000000  0.000000  0.599998  -71.458801
qto_xyz:2      -0.898438  0.000000  0.000000  139.233994
qto_xyz:3      0.000000  -0.898438  0.000000  119.819000
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Superior-to-Inferior
qform_zorient  Left-to-Right
sform_name     Scanner Anat
sform_code     1
sto_xyz:1      0.000000  0.000000  0.599998  -71.458801
sto_xyz:2      -0.898438  0.000000  0.000000  139.233994
sto_xyz:3      0.000000  -0.898438  0.000000  119.819000
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Anterior-to-Posterior
sform_yorient  Superior-to-Inferior
sform_zorient  Left-to-Right
--------------------------------------
after
qform_name     Scanner Anat
qform_code     1
qto_xyz:1      0.000000  0.000000  0.599998  114.550842
qto_xyz:2      -0.898438  0.000000  0.000000  114.550842
qto_xyz:3      0.000000  -0.898438  0.000000  -74.099808
qto_xyz:4      0.000000  0.000000  0.000000  1.000000
qform_xorient  Anterior-to-Posterior
qform_yorient  Superior-to-Inferior
qform_zorient  Left-to-Right
sform_name     Scanner Anat
sform_code     1
sto_xyz:1      -0.000000  0.000000  0.599998  114.550842
sto_xyz:2      -0.898438  -0.000000  -0.000000  114.550842
sto_xyz:3      0.000000  -0.898438  0.000000  -74.099808
sto_xyz:4      0.000000  0.000000  0.000000  1.000000
sform_xorient  Anterior-to-Posterior
sform_yorient  Superior-to-Inferior
sform_zorient  Left-to-Right
----------------------------------------------------------


More information about the Insight-developers mailing list