[ITK] Reading 4D Nifti into a 3D Vector Image

Matt McCormick matt.mccormick at kitware.com
Tue Jan 13 10:14:47 EST 2015


Hi Tobias,

Good to hear you have a solution.

Did reading in the image as VectorImage< float, 4 > or Image< Vector<
float, NElements >, 4 > not work in step 1) ?

Thanks,
Matt

On Tue, Jan 13, 2015 at 6:04 AM, Wood, Tobias <tobias.wood at kcl.ac.uk> wrote:
> Thanks Matt - with your hint I think I have a solution:
> 1 - Read in the file as an Image<float, 4>
> 2 - Iterate over the volumes and create an ExtractImageFilter<Image<float, 4>, Image<float, 3>> for each one
> 3 - Set the ExtractImageFilter outputs as the inputs to a ComposeImageFilter<Image<float, 3>, VectorImage<float, 3>>
> 4 - Use the output of the ComposeImageFilter as the input for my filter
>
> The only thing that has confused me is that I have to call Update() on each ExtractImageFilter in the loop, otherwise the final image has size (0,0,0). I think I'll wrap this up as a composite filter I can re-use. This feels like a sledgehammer-to-crack-a-nut type approach, but it works. If any one has any other suggestions I'm all ears.
>
> Thanks again,
> Tobias
>
> ________________________________________
> From: Matt McCormick <matt.mccormick at kitware.com>
> Sent: 12 January 2015 22:27
> To: Wood, Tobias
> Cc: community at itk.org
> Subject: Re: [ITK] Reading 4D Nifti into a 3D Vector Image
>
> Hi Tobias,
>
> This may be the case -- I am not an NIFTI expert.  Another alternative
> may then be to use a 4D vector image type, then use ExtractImageFilter
> to remove the fourth dimension.
>
> HTH,
> Matt
>
> On Mon, Jan 12, 2015 at 4:51 PM, Wood, Tobias <tobias.wood at kcl.ac.uk> wrote:
>> Dear Matt and Brad,
>> Thanks for the quick response. The approach you suggested sounds good, so I gave it a try using itk::VectorImage<float, 3> and itk::ImageFileReader. However, this appears to read 4D niftis as only having 1 component (using the GetNumberOfComponentsPerPixel() method). I confirmed this by compiling the example at http://www.itk.org/Wiki/ITK/Examples/IO/ReadVectorImage and running it with multiple files that I have - it reported each one as having only 1 component.
>>
>> Is this to do with the choice of nifti format? Technically, vector images are supposed to use the 5th dimension as the vector length in nifti, not the 4th.
>>
>> Thanks,
>> Tobias
>>
>> ________________________________________
>> From: Matt McCormick <matt.mccormick at kitware.com>
>> Sent: 12 January 2015 17:24
>> To: Wood, Tobias
>> Cc: community at itk.org
>> Subject: Re: [ITK] Reading 4D Nifti into a 3D Vector Image
>>
>> Hi Tobias,
>>
>> For this case, it may be better to read in the image as an
>>
>>   itk::Image< itk::Vector< float, NumberOfComponents >, 3 >
>>
>> or
>>
>>   itk::VectorImage< float, 3 >
>>
>> HTH,
>> Matt
>>
>> On Mon, Jan 12, 2015 at 11:33 AM, Wood, Tobias <tobias.wood at kcl.ac.uk> wrote:
>>> Hello,
>>>
>>> I am new to ITK and am working with datasets that are stored as 4D niftis of
>>> variable length in the 4th dimension. The algorithm I need to write takes
>>> the "vector" stored in the 4th dimension as input at each voxel, and
>>> produces some scalar values as output. I would like to write a filter to
>>> contain this algorithm, but I am struggling to work out how to specify the
>>> input and iterate efficiently over it.
>>>
>>>
>>> My output image type is itk::Image<float, 3>. I assume that my input image
>>> type should be itk::Image<float, 4>. Inside the filter, I was planning on
>>> using ImageRegionIterator with GetLargestPossibleRegion() to iterate over
>>> the output voxels.
>>>
>>>
>>> Is there a suitable iterator and region to obtain the vector of values for
>>> each input voxel efficiently? Or, alternatively, is there another approach
>>> that I should be taking? Perhaps using another filter to convert the input
>>> data first?
>>>
>>>
>>> Thanks in advance and I hope my question is clear,
>>>
>>> Tobias Wood
>>>
>>>
>>> _______________________________________________
>>> Community mailing list
>>> Community at itk.org
>>> http://public.kitware.com/mailman/listinfo/community
>>>


More information about the Community mailing list