[Insight-users] Read DICOM series with Python wrap

Paul Novotny paul.novotny at gmail.com
Wed Jun 30 09:44:41 EDT 2010


In my experience you can't get the SeriesUIDS with Python. I think that
function returns a string representation of pointer? Anyway, the way I
have been able to read DICOM series in Python is with the following:

        name_generator = itk.GDCMSeriesFileNames.New()
        name_generator.SetDirectory(directory)
        filenames = name_generator.GetInputFileNames()
        reader.SetFileNames(filenames)

The key is the GetInputFileNames instead of using GetFileNames. I am not
sure if this reads all files in the directory, or the first Series. For
me, these have been the same thing. So you might have to play with it to
get a specific SeriesUUID.

-Paul

On Tue, 2010-06-29 at 17:35 -0700, Seth Gilchrist wrote:
> Hello all,
> I am having a hard time reading a series of files using the python wrappings.
> 
> Currently, I get this far:
> 
>     import itk
> 
>     PixelType = ikt.US
>     ImageDimesion = 3
>     directory = '/home/user/Documents/DICOM/WholeScanUndeformed-NDRI529L'
> 
>     ImageType = itk.Image[PixelType,ImageDimesion]
> 
>     reader = itk.ImageSeriesReader[ ImageType ].New()
>     ImageIOType = itk.GDCMImageIO.New()
>     reader.SetImageIO( ImageIOType.GetPointer() )
> 
>     namesGenerator = itk.GDCMSeriesFileNames.New()
>     namesGenerator.SetUseSeriesDetails( 1 )
>     namesGenerator.SetDirectory( directory )
> 
>     SeriesUIDs = namesGenerator.GetSeriesUIDs()
> 
> From this point, I can't seem to access any of the UIDs imported into
> SeriesUIDs.  My current goal is to read in the dicoms and create a
> single mha file for visualization in ParaView.
> 
> I am quite new to the python wrapping world, but have previously
> accomplished this task in C++.  Is there an example or can anyone
> provide some help on this topic?
> 
> Thanks,
> Seth
> _____________________________________
> 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




More information about the Insight-users mailing list