[Insight-users] incorrect z-spacing in GDCM reading

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed May 11 12:00:26 EDT 2005


George,

	Your code looks fine. The algorithm for finding the z spacing is kind 
of tricky. So I am wondering if:

1. Your images might not have proper 'Image Position Patient' / 'Image 
Orientation Patient'

2. If they have, maybe gdcm is not able to parse the string properly.

Could it be possible that you send me at least two images from this 
dataset ?

If not, you'll have to turn the code to be more verbose in particular 
when entering the function:


     gdcm::SerieHelper::ImagePositionPatientOrdering

Thanks,
Mathieu

Li, George (NIH/NCI) wrote:
> Hi, Luis and ITK users:
>  
> I recently tried to adopt the GDCM dicom code for loading dicom series 
> images,
> and then consequently saving images in dicom series. However, when I 
> read the
> images, the spacing in z-direction is incorrect, leading to a compressed 
> image
> in z-direction. Here is the related code, could you help me to identify 
> anything
> wrong?
>  
> class CMDIDataITKIO 
> {
>  public:
>   CMDIDataITKIO();
>   virtual ~CMDIDataITKIO();
>  public:
>   void ReadGDCM_DicomImages(const char*, SeriesReaderType::Pointer);
>   void WriteGDCM_DicomImages(const char*, ImageType::Pointer);
>  private:
>   // initiate in the ctor, and raise clean flag in dtor.
>   GDCMImageIOType::Pointer m_gdcmIO;
>   GDCMSeriesNames::Pointer m_gdcmNames;
>   SeriesReaderType::Pointer m_gdcmReader;
> }
>  
> 
> void CMDIDataITKIO::ReadGDCM_DicomImages(const char* folderName, 
>                                                                        
> SeriesReaderType::Pointer reader)
> {
>  if(!m_gdcmIO) m_gdcmIO = GDCMImageIOType::New();
>  if(!m_gdcmNames) m_gdcmNames = GDCMSeriesNames::New();
>  
>  // Get the DICOM filenames from the directory
>  m_gdcmNames->SetInputDirectory(folderName);
>  
>  reader->SetFileNames( m_gdcmNames->GetInputFileNames() );
>  reader->SetImageIO( m_gdcmIO );
>  
>  try {
>   reader->Update();
>     }
>  catch (itk::ExceptionObject &excp) {
>   std::cerr << "Exception thrown while writing the image" << std::endl;
>   std::cerr << excp << std::endl;
>     }
> }
> Thanks,
>  
> George
>  
> 
> 
> ------------------------------------------------------------------------
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users



More information about the Insight-users mailing list