Discussion:
[ITK-users] OrientImageFilter flipping VectorImage
mbcx9rb9
2018-06-11 14:17:59 UTC
Permalink
I have a multicomponent nifti image. It's a 3D volume and each voxel contains
3 values. I can then either save this to disk as a multicomponent nifti
image or as 3 single component images.

Using fslhd, I verify that all the headers of the single- and
multi-component files are identical, except for the obvious fact that one is
single component and the other is multi (e.g., dim0=3 vs. dim0=5). One thing
that is particularly important is that they both are in RAS, as shown in
this snippet:

qform_xorient Right-to-Left
qform_yorient Anterior-to-Posterior
qform_zorient Superior-to-Inferior

I read and reorient the images with a templated method:

typedef itk::ImageFileReader<ITKImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(filename);
reader->Update();
ITKImageType::Pointer itk_image_orig = reader->GetOutput();

typename
itk::OrientImageFilter<ITKImageType,ITKImageType>::Pointer orienter =

itk::OrientImageFilter<ITKImageType,ITKImageType>::New();
orienter->UseImageDirectionOn();
orienter->SetInput(itk_image_orig);
orienter->SetDesiredCoordinateOrientation(

itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAS);
orienter->Update();
ITKImageType::Pointer itk_image = orienter->GetOutput();
std::cout << "\nflip axis:\n" << orienter->GetFlipAxes() << "\n";

Where the template is:
- itk::Image<float, 3> for the single component images
or
- itk::VectorImage<float, 3> for the multi component images

========
The problem
========
The images are given in RAS and the desired output is RAS, so no changes
should take place.
output for single component images: "flip axis: [0, 0, 0]"
output for multi component images: "flip axis: [0, 0, 1]"

This is causing problems as the origin moves accordingly for multicomponent
images. Is there any obvious reason as to why this is happening? Have I made
a mistake somewhere? Is this a bug?

Thanks



--
Sent from: http://itk-users.7.n7.nabble.com/
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users
mbcx9rb9
2018-06-11 14:12:07 UTC
Permalink
I have a multicomponent nifti image. It's a 3D volume and each voxel contains
3 values. I can then either save this to disk as a multicomponent nifti
image or as 3 single component images.

Using fslhd, I verify that all the headers of the single- and
multi-component files are identical, except for the obvious fact that one is
single component and the other is multi (e.g., dim0=3 vs. dim0=5). One thing
that is particularly important is that they both are in RAS, as shown in
this snippet:

qform_xorient Right-to-Left
qform_yorient Anterior-to-Posterior
qform_zorient Superior-to-Inferior

I read and reorient the images with a templated method:

typedef itk::ImageFileReader<ITKImageType> ReaderType;
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName(filename);
reader->Update();
ITKImageType::Pointer itk_image_orig = reader->GetOutput();

typename
itk::OrientImageFilter<ITKImageType,ITKImageType>::Pointer orienter =

itk::OrientImageFilter<ITKImageType,ITKImageType>::New();
orienter->UseImageDirectionOn();
orienter->SetInput(itk_image_orig);
orienter->SetDesiredCoordinateOrientation(

itk::SpatialOrientation::ITK_COORDINATE_ORIENTATION_RAS);
orienter->Update();
ITKImageType::Pointer itk_image = orienter->GetOutput();
std::cout << "\nflip axis:\n" << orienter->GetFlipAxes() << "\n";

Where the template is:
- itk::Image<float, 3> for the single component images
or
- itk::VectorImage<float, 3> for the multi component images

========
The problem
========
The images are given in RAS and the desired output is RAS, so no changes
should take place.
output for single component images: "flip axis: [0, 0, 0]"
output for multi component images: "flip axis: [0, 0, 1]"

This is causing problems as the origin moves accordingly for multicomponent
images. Is there any obvious reason as to why this is happening? Have I made
a mistake somewhere? Is this a bug?

Thanks



--
Sent from: http://itk-users.7.n7.nabble.com/
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users
mbcx9rb9
2018-06-11 16:04:09 UTC
Permalink
After further investigation, the problem starts when the image is read.

std::cout << itk_image_orig->GetDirection();

for itk::Image<float, 3> gives:
1 0 0
0 1 0
0 0 -1

but for itk::VectorImage<float, 3> gives:
1 0 0
0 1 0
0 0 1

As I said, the headers are identical (the bits I can see, at least):
sizeof_hdr 348
data_type FLOAT32
dim0 5
dim1 285
dim2 285
dim3 127
dim4 1
dim5 3
dim6 1
dim7 1
vox_units mm
time_units Unknown
datatype 16
nbyper 4
bitpix 32
pixdim0 0.000000
pixdim1 2.086260
pixdim2 2.086260
pixdim3 2.031250
pixdim4 1.000000
pixdim5 1.000000
pixdim6 1.000000
pixdim7 1.000000
vox_offset 352
cal_max 0.0000
cal_min 0.0000
scl_slope 1.000000
scl_inter 0.000000
phase_dim 0
freq_dim 0
slice_dim 0
slice_name Unknown
slice_code 0
slice_start 0
slice_end 0
slice_duration 0.000000
time_offset 0.000000
intent Unknown
intent_code 0
intent_name
intent_p1 0.000000
intent_p2 0.000000
intent_p3 0.000000
qform_name Scanner Anat
qform_code 1
qto_xyz:1 -2.086260 0.000000 -0.000000 296.248932
qto_xyz:2 0.000000 -2.086260 -0.000000 296.248932
qto_xyz:3 0.000000 0.000000 -2.031250 0.000000
qto_xyz:4 0.000000 0.000000 0.000000 1.000000
qform_xorient Right-to-Left
qform_yorient Anterior-to-Posterior
qform_zorient Superior-to-Inferior
sform_name Unknown
sform_code 0
sto_xyz:1 0.000000 0.000000 0.000000 0.000000
sto_xyz:2 0.000000 0.000000 0.000000 0.000000
sto_xyz:3 0.000000 0.000000 0.000000 0.000000
sto_xyz:4 0.000000 0.000000 0.000000 0.000000
sform_xorient Unknown
sform_yorient Unknown
sform_zorient Unknown
file_type NIFTI-1+
file_code 1
descrip
aux_file



--
Sent from: http://itk-users.7.n7.nabble.com/
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users

Loading...