[Insight-users] Using ITK with DICOM - extracting non-image information.

Simon Harris s.j.harris at imperial.ac.uk
Fri Aug 20 13:23:44 EDT 2004


We ran the application through the VC++ .NET debugger this afternoon
and tracked the problem down to non-terminated strings. I modified the
code in DICOMAppHelper a little changing...

From...

void DICOMAppHelper::PatientNameCallback(DICOMParser *,
                                    doublebyte,
                                    doublebyte,
                                    DICOMParser::VRTypes,
                                    unsigned char* val,
                                    quadbyte len)
{
   if (val)
     {
     strncpy(m_PatientName, (const char*)val, len<512 ? len:511);
     }
   else
     {
     m_PatientName[0] = '\0';
     }
}

to...

void DICOMAppHelper::PatientNameCallback(DICOMParser *,
                                    doublebyte,
                                    doublebyte,
                                    DICOMParser::VRTypes,
                                    unsigned char* val,
                                    quadbyte len)
{
   if (val)
     {
	quadbyte len1 = (len<512) ? len : 511;
       strncpy(m_PatientName, (const char*)val, len1);
	m_PatientName[len1]=0;
     }
   else
     {
     m_PatientName[0] = '\0';
     }
}

So that a null-terminator is added after each string. Also all the other
DICOM string callback functions were modified in the same way...

and after rebuilding... it works for all the DICOM files I threw at it.

I was working in Debug mode where it failed before. My colleague has just
informed me that the original worked in Release mode.

Regards,
Simon.


On Thu, 19 Aug 2004 16:53:17 -0400, Luis Ibanez <luis.ibanez at kitware.com>  
wrote:

>
> Hi Simon,
>
> Thanks for your report.
> Unfortunately, from the limited information that
> you provide there is no much that we can do.
>
>
> Possible options at this point are:
>
>
> 1) Can you make one slice of that DICOM
>     file available to us so we can debug this ?
>
> 2) Can you try the same code with another dataset ?
>     and let us know what you find.
>
> 3) You could also use GDCM. ITK has an daptor class
>     for GDCM, and takes advantage of a larger support
>     for variations of DICOM.
>
>
>     Documentation for GDCM is available at:
> http://www.creatis.insa-lyon.fr/Public/Gdcm/html.developper/index.html
>
>
>
>
>    Regards,
>
>
>
>      Luis
>
>
>
> ---------------------
> Simon Harris wrote:
>
>> Thanks for that - finally I managed to get ITK
>> built on my system and compiled the example code
>> ok...
>>  I've only tried it on one dataset so far, but it
>> appears to stall for a while at the:
>>    dicomIO->GetPatientName(  patientName  );
>>  and then bails out without printing anything. I don't
>> know if the files I have are bad DICOM - they come
>> from a Siemens scanner & my own DICOM reading software
>> and other software I have can extract the data ok.
>>  Simon.
>>   On Tue, 17 Aug 2004 11:09:49 -0400, Luis Ibanez  
>> <luis.ibanez at kitware.com>  wrote:
>>
>>>
>>> Hi Simon,
>>>
>>> Please look at the examples in
>>>
>>>    Insight/Examples/IO/
>>>      DicomPrintPatientImformation.cxx
>>>
>>> It illustrates how to get access to
>>> some of the DICOM tags in the input
>>> image.
>>>
>>> Please let us know if you have further
>>> questions.
>>>    Thanks
>>>      Luis
>>   _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>
>
>
>



-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/


More information about the Insight-users mailing list