[Insight-users] Problem in reading nifti image

Hsieh M.Hsieh at student.tudelft.nl
Tue Apr 12 05:41:21 EDT 2011


Hi,

 

It works! Thank you very much.

 

Now there's another problem. If I want to combine them back to a vector
after doing some processing on each component, it seems a good idea to
use itkImageToVectorImageFilter.h. However, the original vector image is
of itk::Image< itk::Vector<float, 6>, 3 > type, while the output image
of the filter is of itk::VectorImage type. They are essentially
different in their way of storing components. Is there a way to make
them consistent? Say, casting VectorImage to Image<Vector<float, 6>, 3>
or another filter that works the same but gives Image<Vector<float, 6>,
3> as output.

 

Best regards,

Meng-Kang Hsieh (Michael)

OpSciTech, Erasmus Mundus

Delft University of Technology

 

 

From: wanlin [mailto:wanlinzhu at gmail.com] 
Sent: Saturday, March 26, 2011 2:44 AM
To: Hsieh
Cc: Luis Ibanez; insight-users at itk.org
Subject: Re: [Insight-users] Problem in reading nifti image

 

HI, Michael
      If your output image is the last selectorIndex component of input
vectorimage, you might need disconnect the output image before proceed
on. See embedded lines.

On Sat, Mar 26, 2011 at 1:50 AM, Hsieh <M.Hsieh at student.tudelft.nl>
wrote:

Hi Luis,

This is a very helpful message that this filter does exactly what I
need.

But, I am wondering if I can use only one instance of the filter to
generate multiple output by setting different index? I've tried
something as below,
 int selectorIndex = 0;
 selector->SetIndex( selectorIndex );

 selector->Update();
ScalarImagePointer output0 = selector->GetOutput();
output0->DisconnectPipeline();

	 writer0->SetInput( output0);
	 selectorIndex++;
	
	 selector->SetIndex( selectorIndex );

  selector->Update();
ScalarImagePointer output1 = selector->GetOutput();
output1->DisconnectPipeline();

	 writer1->SetInput( output1);
	 selectorIndex++;
	
	and so on. But all the writers give the same component of the
tensor image. Instead, I have to instantiate 6 selectors as many as the
writers to achieve the goal of saving six components of a DTI tensor
image.
	However, I'd like to have a single class and one instance that
can produce multiple outputs, say, extract all six components in the
tensor like:
	       selector->GetComponentOne( );
	       selector->GetComponentTwo( );
	and so on.
	Do you think that I have to write a new class capable of
multiple outputs inherited from the
itkVectorIndexSelectionCastImageFilter? Or any simpler way?

	
	
	
	Best regards,
	Meng-Kang Hsieh (Michael)
	
	

	-----Original Message-----
	From: Luis Ibanez [mailto:luis.ibanez at kitware.com]
	Sent: Tuesday, February 22, 2011 12:54 AM
	To: robert tamburo
	Cc: Hsieh; insight-users at itk.org; norman-k-williams at uiowa.edu
	Subject: Re: [Insight-users] Problem in reading nifti image
	
	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_1VectorIndexSe
lectionCastImageFilter.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
	>
	>
	_____________________________________
	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

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20110412/ce4f0980/attachment.htm>


More information about the Insight-users mailing list