[Insight-users] Re ITK to VTK for 4D images

David M. Welch david.m.welch at gmail.com
Mon Dec 3 11:49:47 EST 2012


Hi Brad, 

The docstring in the sample code is incorrect: the label image image comes
SECOND to the filter.

Thanks to Hans Johnson for pointing this error out.

Dave

From:  Bradley Lowekamp <blowekamp at mail.nih.gov>
Date:  Wed, 28 Nov 2012 15:22:10 -0500
To:  "David M. Welch" <david.m.welch at gmail.com>
Cc:  "insight-users at itk.org" <insight-users at itk.org>
Subject:  Re: [Insight-users] Re  ITK to VTK for 4D images

Hello David,

What is and is not working?
Is there an error being reported?
Can you compute the time dimension independently?

I am not sure what you mean by a 4D image. SimpleITK support 2D and 3D image
of scalars and vector components. Some may call a 3D image of
multi-components  4D others may call an array of 3D images a 4D image.
SimpleITK currently does not have plans to support images with 4 spacial
dimension, however either of the prior approaches may work just fine.

Are you able to load the image with ReadImage as a sitkImage of Vectors?

If you are an you are getting an error with the Statistics, just loop over
the number of components  ( it hopefully worked out to be the time dimension
),  and run the filer for each dimension.

Are you not able to Read?

It may be easiest to write the 4D as a series of 3D image and process the
time dimension independently.
An outstanding feature of the sitk Reader is the ability to specify the
region of interest. Generically, this feature would include being able to
specify the region such that it can map a 4D image into a 3D or even a 2D
image, in addition to stream like processing. If you need the feature create
a jira ticket.



On Nov 28, 2012, at 2:32 PM, David M. Welch <david.m.welch at gmail.com> wrote:

> Hi Brad, 
> 
> I'm running into this issue today with an fMRI dataset (3D + time) that I've
> preprocessed with AFNI and I want to register it with a label image and get
> out vectors for each 3D set in the time series.  I'd like to have this type of
> behavior:
> 
>>>> >>> from SimpleITK import *
>>>> >>> label = ReadImage(label_file)
>>>> >>> image = ReadImage(fMRI_file)
>>>> >>> stats = LabelStatistics(label, image)# TODO: Docstring should specify
>>>> that label comes first! second!

Thanks for the note there. The LabelStatistics filter is a manually written
one, only recently have we gotten to facilities to extract the doxygen
documentation from these classes and place it into the Python docstrings. So
if this documentation is updates in the code it will shortly show up in the
docstring.

The above line is not quite right. The procedure LabelStatistics returns a
MeasurementMap type object, while below appears to be manipulating a
LabelStatisticsImageFilter... I think.

Consider using the following lines ( I know two lines to run a SimpleITK
filter, such a burden :)

stats = LabelStatisticsImageFilter()
stats.Execute( label, image)




>>>> >>> for labelCode in stats.GetValidLabels():
>>>> >>>    print stats.GetSum(labelCode)
> [10, 30, 20, 15, Š]
> [15, 25, 20, 10, Š]
> Etc.
> 
> Is there a bug report/ticket for 4D support in SimpleITK?  What needs to be
> changed to extend LabelStatistics to handle 4D images?
> 
> Cheers, 
> David Welch, M.S.
> 
> 
> Applications Developer
> Department of Psychiatry
> University of Iowa
> (319)384-9413
> dmwelch at healthcare.iowa.edu <mailto:dmwelch at healthcare.uiowa.edu>
> david-welch at iowa.edu <mailto:david-welch at uiowa.edu>
> 
> 
> From: Bradley Lowekamp <blowekamp at mail.nih.gov>
> Date: Mon, 23 Apr 2012 11:00:26 -0400
> To: Mathieu Stumpf <mathieu.stumpf at etu.unistra.fr>
> Cc: "insight-users at itk.org" <insight-users at itk.org>
> Subject: Re: [Insight-users] ITK to VTK for 4D images
> 
> Hello, 
> 
> What is the current issue you are having with your SimpleITK implementation?
> 
> Currently, I am aware what we don't have support to convert VectorImage to
> numpy arrays. But that is near the top of my todo list this week.
> 
> Also, I am interested in your input data? What do you mean by 4D? 3D + time?
> 3D+ multichannel? What is your input file format and what is the meta data
> that is report? If there is an issue with SimpleITK reading it, I'd like to
> see a sample file to see if support could easily be added.
> 
> Brad
> 
> On Apr 23, 2012, at 8:22 AM, Mathieu Stumpf wrote:
> 
> ...
>> 
>> Well, it provide a vtkImageData (I checked with a print), but using it
>> instead of my previous solution using SimpleITK make my application
>> crash, without any debugging information. The previous working solution
>> being :
>> 
>>        self.sitk_image = sitk.ReadImage(str(file_path) )
>>        self.numpy_img = sitk.GetArrayFromImage( self.sitk_image )
>>        n2vtk = vtkImageImportFromArray() # Converter
>>        n2vtk.SetArray(self.numpy_img)
>>        n2vtk.Update()
>>        self.vtk_image = n2vtk.GetOutput()
>> 
>> I welcome any suggestion
>> kind regards,
>> mathieu
>> 
>> 
>> 
>> _____________________________________
>> Powered by www.kitware.com <http://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:
>> http://www.itk.org/mailman/listinfo/insight-users
> 
> ========================================================
> Bradley Lowekamp 
> Medical Science and Computing for
> Office of High Performance Computing and Communications
> National Library of Medicine
> blowekamp at mail.nih.gov
> 
> 
> 
> 
> 
> 
> Notice: This UI Health Care e-mail (including attachments) is covered by the
> Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential
> and may be legally privileged.  If you are not the intended recipient, you are
> hereby notified that any retention, dissemination, distribution, or copying of
> this communication is strictly prohibited.  Please reply to the sender that
> you have received the message in error, then delete it.  Thank you.
> 
> _____________________________________
> Powered by www.kitware.com <http://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:
> http://www.itk.org/mailman/listinfo/insight-users



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


More information about the Insight-users mailing list