HI, Michael<br> 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.<br><br><div class="gmail_quote">On Sat, Mar 26, 2011 at 1:50 AM, Hsieh <span dir="ltr"><<a href="mailto:M.Hsieh@student.tudelft.nl">M.Hsieh@student.tudelft.nl</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Luis,<br>
<br>
This is a very helpful message that this filter does exactly what I need.<br>
<br>
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,<br>
int selectorIndex = 0;<br>
selector->SetIndex( selectorIndex );<br></blockquote><div> selector->Update();<br>ScalarImagePointer output0 = selector->GetOutput();<br> output0->DisconnectPipeline();<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
writer0->SetInput( output0);<br>
selectorIndex++;<br>
<br>
selector->SetIndex( selectorIndex );<br></blockquote><div> selector->Update();<br>
ScalarImagePointer output1 = selector->GetOutput();<br>
output1->DisconnectPipeline();<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
writer1->SetInput( output1);<br>
selectorIndex++;<br>
<br>
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.<br>
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:<br>
selector->GetComponentOne( );<br>
selector->GetComponentTwo( );<br>
and so on.<br>
Do you think that I have to write a new class capable of multiple outputs inherited from the itkVectorIndexSelectionCastImageFilter? Or any simpler way?<br>
<div class="im"><br>
<br>
<br>
Best regards,<br>
Meng-Kang Hsieh (Michael)<br>
<br>
<br>
</div><div><div></div><div class="h5">-----Original Message-----<br>
From: Luis Ibanez [mailto:<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>]<br>
Sent: Tuesday, February 22, 2011 12:54 AM<br>
To: robert tamburo<br>
Cc: Hsieh; <a href="mailto:insight-users@itk.org">insight-users@itk.org</a>; <a href="mailto:norman-k-williams@uiowa.edu">norman-k-williams@uiowa.edu</a><br>
Subject: Re: [Insight-users] Problem in reading nifti image<br>
<br>
Hi Michael<br>
<br>
As Robert described, the ImageAdaptor will not work before a Writer.<br>
<br>
You may want to use instead the filter:<br>
<br>
<a href="http://public.kitware.com/Insight/Doxygen/html/classitk_1_1VectorIndexSelectionCastImageFilter.html" target="_blank">http://public.kitware.com/Insight/Doxygen/html/classitk_1_1VectorIndexSelectionCastImageFilter.html</a><br>
<br>
<br>
Luis<br>
<br>
<br>
---------------------------------<br>
On Mon, Feb 21, 2011 at 2:06 PM, robert tamburo<br>
<<a href="mailto:robert.tamburo@gmail.com">robert.tamburo@gmail.com</a>> wrote:<br>
> Section 12.5 of the ITK software guide:<br>
> 12.5 Adaptors and Writers<br>
> Image adaptors will not behave correctly when connected directly to a<br>
> writer. The reason is<br>
> that writers tend to get direct access to the image buffer from their input,<br>
> since image adaptors<br>
> do not have a real buffer their behavior in this circumstances is incorrect.<br>
> You should avoid<br>
> instantiating the ImageFileWriter or the ImageSeriesWriter over an image<br>
> adaptor type.<br>
> From an email to the user list by Luis'<br>
> (<a href="http://www.itk.org/pipermail/insight-users/2005-April/012553.html" target="_blank">http://www.itk.org/pipermail/insight-users/2005-April/012553.html</a>):<br>
> This means that when you use ImageAdaptors, you must make sure<br>
> that the filter receiving the Adaptor is based on the use of the<br>
> "*WithIndex" iterators.<br>
><br>
> On Mon, Feb 21, 2011 at 1:36 PM, Hsieh <<a href="mailto:M.Hsieh@student.tudelft.nl">M.Hsieh@student.tudelft.nl</a>> wrote:<br>
>><br>
>> Hi,<br>
>><br>
>><br>
>><br>
>> Now I send it to Insight-Users mailing list.<br>
>><br>
>> My purpose is to extract elements from the tensor image to analyze and<br>
>> register the tensor channels. With your help now I can do so with vector<br>
>> image adaptor, which extracts one of the element of the vector. However, in<br>
>> the example of ImageAdaptor3.cxx, the adaptor itself cannot directly be fed<br>
>> into the writer to create a scalar image. It is shown that a filter, such as<br>
>> rescaling the intensity, has to be done and therefore the<br>
>> rescaler->GetOutput() can be set as the input image for writer. Is there a<br>
>> way not to modify the intensity of the image? Is there an identity filter or<br>
>> something like that?<br>
>><br>
>><br>
>><br>
>> Best regards,<br>
>><br>
>> Michael<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> This is more of a question for the Insight-Users mailing list.<br>
>><br>
>><br>
>><br>
>> That being said, you don't show your work, so I can't say exactly what<br>
>> you're doing wrong.<br>
>><br>
>><br>
>><br>
>> I wrote the NIfTI image reader, and as I remember there's some strange<br>
>> things that go on with respect to Images with dimension > 3.<br>
>><br>
>><br>
>><br>
>> If I recall correctly, in a NIfTI image dimensions of [ 128 128 64 1 6 ]<br>
>> would not correspond to an 5D scalar image at all. It would be a 3D image<br>
>> where each voxel is a 6-element vector. The 4th dimension is ALWAYS<br>
>> interpreted as a time dimension, and the sixth and subsequent dimensions are<br>
>> interpreted according to what the image modality actually was. Most often,<br>
>> and what's implemented in the reader, is to interpret it as an Image of<br>
>> Vector voxels. So NiftiImageIO reads in 6 3D volumes, and then constructs<br>
>> vector pixels by pulling one pixel from each of the volumes.<br>
>><br>
>><br>
>><br>
>> In other words if you used<br>
>><br>
>><br>
>><br>
>> typedef itk::Image< itk::Vector<float, 6>, 3 > ImageType;<br>
>><br>
>> typedef itk::ImageFileReader<Imagetype> ImageReaderType;<br>
>><br>
>><br>
>><br>
>> You would get all the data. If you use<br>
>><br>
>><br>
>><br>
>> typedef itk::Image<float, 3> ImageType;<br>
>><br>
>> typedef itk::ImageFileReader<ImageType> ImageReaderType;<br>
>><br>
>><br>
>><br>
>> the ImageFileReader will think that it's a vector image and try to convert<br>
>> the vector voxels to a scalar voxel, probably by taking the first value of<br>
>> each voxel's vector. It will then report the image size as you reported.<br>
>><br>
>><br>
>><br>
>> From: Hsieh <<a href="mailto:M.Hsieh@student.tudelft.nl">M.Hsieh@student.tudelft.nl</a>><br>
>> Date: Fri, 18 Feb 2011 16:35:07 +0100<br>
>> To: ITK <<a href="mailto:insight-developers@itk.org">insight-developers@itk.org</a>><br>
>> Subject: [Insight-developers] Problem in reading 5D nifti image<br>
>><br>
>><br>
>><br>
>> Hi,<br>
>><br>
>><br>
>><br>
>> I am trying to read a diffusion tensor image in nifti(.nii) format, which<br>
>> has dimension of [128 128 64 1 6]. However, the image I got after read by<br>
>> the itkImageFileReader.h had dimension only [128 128 64 1 1]. The last two<br>
>> dimension are suppressed by the reader. When I looked into the class (.h)<br>
>> and the .txx file, I found out that the numberOfDimensionsIO, which is 3, is<br>
>> smaller than TOutputImage::ImageDimension, which is set manually to 5, so<br>
>> that the 4th and the 5th dimension are set to 1 later. Why does that happen?<br>
>> numberOfDimensionsIO should be 5 in this case.<br>
>><br>
>><br>
>><br>
>> Best regards,<br>
>><br>
>> Meng-Kang Hsieh (Michael)<br>
>><br>
>> OpSciTech, Erasmus Mundus<br>
>><br>
>> Delft University of Technology<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> Best regards,<br>
>><br>
>> Meng-Kang Hsieh (Michael)<br>
>><br>
>> OpSciTech, Erasmus Mundus<br>
>><br>
>> Delft University of Technology<br>
>><br>
>><br>
>><br>
>><br>
>><br>
>> _____________________________________<br>
>> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
>><br>
>> Visit other Kitware open-source projects at<br>
>> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
>><br>
>> Kitware offers ITK Training Courses, for more information visit:<br>
>> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
>><br>
>> Please keep messages on-topic and check the ITK FAQ at:<br>
>> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
>><br>
>> Follow this link to subscribe/unsubscribe:<br>
>> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
>><br>
><br>
><br>
> _____________________________________<br>
> Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
><br>
> Visit other Kitware open-source projects at<br>
> <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
><br>
> Kitware offers ITK Training Courses, for more information visit:<br>
> <a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
><br>
> Please keep messages on-topic and check the ITK FAQ at:<br>
> <a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
><br>
> Follow this link to subscribe/unsubscribe:<br>
> <a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
><br>
><br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</div></div></blockquote></div><br>