[Insight-users] Problem in reading nifti image
Luis Ibanez
luis.ibanez at kitware.com
Mon Feb 21 18:54:10 EST 2011
Hi Michael
As Robert described, the ImageAdaptor will not work before a Writer.
You may want to use instead the filter:
http://public.kitware.com/Insight/Doxygen/html/classitk_1_1VectorIndexSelectionCastImageFilter.html
Luis
---------------------------------
On Mon, Feb 21, 2011 at 2:06 PM, robert tamburo
<robert.tamburo at gmail.com> wrote:
> Section 12.5 of the ITK software guide:
> 12.5 Adaptors and Writers
> Image adaptors will not behave correctly when connected directly to a
> writer. The reason is
> that writers tend to get direct access to the image buffer from their input,
> since image adaptors
> do not have a real buffer their behavior in this circumstances is incorrect.
> You should avoid
> instantiating the ImageFileWriter or the ImageSeriesWriter over an image
> adaptor type.
> From an email to the user list by Luis'
> (http://www.itk.org/pipermail/insight-users/2005-April/012553.html):
> This means that when you use ImageAdaptors, you must make sure
> that the filter receiving the Adaptor is based on the use of the
> "*WithIndex" iterators.
>
> On Mon, Feb 21, 2011 at 1:36 PM, Hsieh <M.Hsieh at student.tudelft.nl> wrote:
>>
>> Hi,
>>
>>
>>
>> Now I send it to Insight-Users mailing list.
>>
>> My purpose is to extract elements from the tensor image to analyze and
>> register the tensor channels. With your help now I can do so with vector
>> image adaptor, which extracts one of the element of the vector. However, in
>> the example of ImageAdaptor3.cxx, the adaptor itself cannot directly be fed
>> into the writer to create a scalar image. It is shown that a filter, such as
>> rescaling the intensity, has to be done and therefore the
>> rescaler->GetOutput() can be set as the input image for writer. Is there a
>> way not to modify the intensity of the image? Is there an identity filter or
>> something like that?
>>
>>
>>
>> Best regards,
>>
>> Michael
>>
>>
>>
>>
>>
>>
>>
>> This is more of a question for the Insight-Users mailing list.
>>
>>
>>
>> That being said, you don't show your work, so I can't say exactly what
>> you're doing wrong.
>>
>>
>>
>> I wrote the NIfTI image reader, and as I remember there's some strange
>> things that go on with respect to Images with dimension > 3.
>>
>>
>>
>> If I recall correctly, in a NIfTI image dimensions of [ 128 128 64 1 6 ]
>> would not correspond to an 5D scalar image at all. It would be a 3D image
>> where each voxel is a 6-element vector. The 4th dimension is ALWAYS
>> interpreted as a time dimension, and the sixth and subsequent dimensions are
>> interpreted according to what the image modality actually was. Most often,
>> and what's implemented in the reader, is to interpret it as an Image of
>> Vector voxels. So NiftiImageIO reads in 6 3D volumes, and then constructs
>> vector pixels by pulling one pixel from each of the volumes.
>>
>>
>>
>> In other words if you used
>>
>>
>>
>> typedef itk::Image< itk::Vector<float, 6>, 3 > ImageType;
>>
>> typedef itk::ImageFileReader<Imagetype> ImageReaderType;
>>
>>
>>
>> You would get all the data. If you use
>>
>>
>>
>> typedef itk::Image<float, 3> ImageType;
>>
>> typedef itk::ImageFileReader<ImageType> ImageReaderType;
>>
>>
>>
>> the ImageFileReader will think that it's a vector image and try to convert
>> the vector voxels to a scalar voxel, probably by taking the first value of
>> each voxel's vector. It will then report the image size as you reported.
>>
>>
>>
>> From: Hsieh <M.Hsieh at student.tudelft.nl>
>> Date: Fri, 18 Feb 2011 16:35:07 +0100
>> To: ITK <insight-developers at itk.org>
>> Subject: [Insight-developers] Problem in reading 5D nifti image
>>
>>
>>
>> Hi,
>>
>>
>>
>> I am trying to read a diffusion tensor image in nifti(.nii) format, which
>> has dimension of [128 128 64 1 6]. However, the image I got after read by
>> the itkImageFileReader.h had dimension only [128 128 64 1 1]. The last two
>> dimension are suppressed by the reader. When I looked into the class (.h)
>> and the .txx file, I found out that the numberOfDimensionsIO, which is 3, is
>> smaller than TOutputImage::ImageDimension, which is set manually to 5, so
>> that the 4th and the 5th dimension are set to 1 later. Why does that happen?
>> numberOfDimensionsIO should be 5 in this case.
>>
>>
>>
>> Best regards,
>>
>> Meng-Kang Hsieh (Michael)
>>
>> OpSciTech, Erasmus Mundus
>>
>> Delft University of Technology
>>
>>
>>
>>
>>
>> Best regards,
>>
>> Meng-Kang Hsieh (Michael)
>>
>> OpSciTech, Erasmus Mundus
>>
>> Delft University of Technology
>>
>>
>>
>>
>>
>> _____________________________________
>> 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.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
>
> _____________________________________
> 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.html
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>
>
More information about the Insight-users
mailing list