[Insight-users] SimpleITK and DTI

Francois Budin fbudin at unc.edu
Thu Jun 6 11:39:51 EDT 2013


Thank you for your help. I realized that the easiest for me now was 
simply to hack my DTI file and "convert" it to a vector image since what 
I want to do it very limited for now. I wrote a very basic python script 
to do that. I can then just open that image with SimpleITK.

#!/usr/bin/python
import sys

if len(sys.argv) != 3:
   print "Usage: "+sys.argv[0]+" inputFileName outputFileName"
   exit(-1)
inputFile = sys.argv[1]
outputFile = sys.argv[2]
fi=open(inputFile,'r')
fo=open(outputFile,'w')
for line in iter(fi.readline, b''):
   count = line.find("3D-symmetric-matrix")
   if count >= 0:
     line = line.replace( "3D-symmetric-matrix", "vector" )
   fo.write(line)
fi.close()
fo.close()


On 06/06/2013 11:17 AM, Bradley Lowekamp wrote:
> Hello,
>
> You might be able to hack it to load it as VectorImage if that's all you want.
>
> You may be able to just add ImageIOBase::SYMMETRICSECONDRANKTENSOR and DIFFUSIONTENSOR3D to the code I linked to below. That may load it up as a itk::VectorImage inside SimpleITK. I don't know for certain, but I would expect itk::ImageFileReader to be able to convert those types to a VectorImage. However, you are not going to get that pixel type when you write it out.
>
> If you give it a try let us know how it works for you!
>
> To summarize, you'd just like basic pixel operators in SimpleITK to support DTI.
>
> Thanks,
> Brad
>
> On Jun 6, 2013, at 11:11 AM, Francois Budin <fbudin at unc.edu> wrote:
>
>> Hello,
>>
>> Thanks for your quick answer. I was just playing around with SimpleITK and trying to discover how to use it. At that point, I was just trying to see the value of a chosen voxel with GetPixel(), so even if the DTI was opened as a vector image that would still have worked for me. Doing simple operations on Diffusion Tensor images, such as masking, could be useful to me when the development of a complex software is not necessary.
>>
>> Francois
>>
>> On 06/06/2013 10:55 AM, Bradley Lowekamp wrote:
>>> Hello,
>>>
>>> SimpleITK does not have currently have support for images of tensors. I would like to add some basic support for this in the near future.
>>>
>>> This is where you exception is coming from:
>>> https://github.com/SimpleITK/SimpleITK/blob/master/Code/IO/src/sitkImageReaderBase.cxx#L86
>>>
>>> What were you hoping to be able to do in SimpleITK? What algorithms/filters were you hoping to do?
>>>
>>> I am hopping for some users to help drive and test this addition to SimpleITK.
>>>
>>> Thanks,
>>> Brad
>>>
>>>
>>> On Jun 6, 2013, at 10:43 AM, Francois Budin <fbudin at unc.edu> wrote:
>>>
>>>> Hello,
>>>>
>>>> I was trying to open a Diffusion Tensor Image (DTI) file using SimpleITK (in a python console) and I got the following error: ========================================================= [30]: image=sitk.ReadImage( "/rodent/FAS_sulik/DTI2013/Processing/N50848/2-Registration/N50848_dwi_MFcorrected_shuffled_dti_f_reg.nrrd") --------------------------------------------------------------------------- RuntimeError Traceback (most recent call last) <ipython-input-30-99f941f49428> in <module>() ----> 1 image=sitk.ReadImage( "/rodent/FAS_sulik/DTI2013/Processing/N50848/2-Registration/N50848_dwi_MFcorrected_shuffled_dti_f_reg.nrrd") /NIRAL/devel/linux/Python/ThirdParty/SimpleITK-0.6.1-py2.6-linux-x86_64.egg/SimpleITK.pyc in ReadImage(*args) 4388 4389 """ -> 4390 return _SimpleITK.ReadImage(*args) 4391 class HashImageFilter(_object): 4392 """ RuntimeError: Exception thrown in SimpleITK ReadImage: /scratch/blowekamp/dashboards/Ubuntu10-release/SimpleITK/Code/IO/src/sitkImageReaderBase.cxx:104: sitk::ERROR: Unknown PixelType: 9 ==============================================
>>>> Is there a way to read DTI with SimpleITK? It reads well Diffusion Weighted Images (DWI) which are vector images.
>>>>
>>>> Sincerely,
>>>>
>>>> Francois
>>>>
>>>> _____________________________________
>>>> 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.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
>>




More information about the Insight-users mailing list