[Insight-users] incorrect z-spacing in GDCM reading
Mathieu Malaterre
mathieu.malaterre at kitware.com
Wed May 11 13:11:28 EDT 2005
As long as sscanf is robust enough:
if( sscanf( strImPos.c_str(), "%f\\%f\\%f", &xImPos, &yImPos, &zImPos)
!= 3 )
we are safe.
I did receive the DICOM images and George is right. gdcm is not ordering
properly because SerieHelper::ImagePositionPatientOrdering is failing
due to (line 245):
if( dist == 0 )
{
return false;
}
I really cannot remember why I put that here. It has been there since
revision 1.1 of gdcmHeaderHelper...
I'll rerun all gdcm tests before changing those lines.
Anyway thanks George for the bug report,
Mathieu
Miller, James V (Research) wrote:
> It looks like the ImagePositionPatients in these headers
> are formatted like
>
> 0.00000 \0.0000 \0.0000
>
> with a space before the "\". Normally, these fields appears as
>
> 0.0000\0.0000\0.0000
>
> I have never seen spaces before the "\", does DICOM allow this?
>
> Jim
>
> -----Original Message-----
> From: insight-users-bounces+millerjv=crd.ge.com at itk.org
> [mailto:insight-users-bounces+millerjv=crd.ge.com at itk.org]On Behalf Of
> Li, George (NIH/NCI)
> Sent: Wednesday, May 11, 2005 12:44 PM
> To: Li, George (NIH/NCI); 'Mathieu Malaterre'
> Cc: 'insight-users at itk.org'; 'Luis Ibanez'
> Subject: RE: [Insight-users] incorrect z-spacing in GDCM reading
>
>
> Mathieu:
>
> Here are the dicom header information. The strings are direct dump,
> So should provide some info on the images. Hopefully, you can tell
> Me an alternative way to send images to you and test them from your
> End.
>
> Thanks,
>
> George
>
>
> -----Original Message-----
> From: Li, George (NIH/NCI)
> Sent: Wednesday, May 11, 2005 12:38 PM
> To: 'Mathieu Malaterre'
> Cc: 'insight-users at itk.org'; 'Luis Ibanez'
> Subject: RE: [Insight-users] incorrect z-spacing in GDCM reading
>
>
>
> Mathieu:
>
> I cannot send the 2 images as attachment, because they are 205KB each. I got
> a message from ITK, saying that there is limit of 40KB per mail And my
> following mail was discarded.
>
> Any other way I can send the images?
>
> Thanks,
>
> George
>
>
>
> -----Original Message-----
> From: Li, George (NIH/NCI)
> Sent: Wednesday, May 11, 2005 12:32 PM
> To: 'Mathieu Malaterre'
> Cc: 'Luis Ibanez'; insight-users at itk.org
> Subject: RE: [Insight-users] incorrect z-spacing in GDCM reading
>
>
> Thanks, Mathieu:
>
> I have included two image slices, together with their header information,
> which is printed into text files from one of my own program. Actually, the
> dicom image files are generated from my program, too. Theoretically, the
> syntax should follow dicom3 definition on 'Image Position Patient' / 'Image
> Orientation Patient'. I did not check how GDCM parses the string.
>
> The spacing should be 3.4mm, but GDCM got 1.00mm.
>
> Look forward to hearing from you.
>
> Thanks.
>
> George
>
>
> -----Original Message-----
> From: Mathieu Malaterre [mailto:mathieu.malaterre at kitware.com]
> Sent: Wednesday, May 11, 2005 12:00 PM
> To: Li, George (NIH/NCI)
> Cc: 'Luis Ibanez'; insight-users at itk.org
> Subject: Re: [Insight-users] incorrect z-spacing in GDCM reading
>
>
> 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
>
> _______________________________________________
> 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