[Dcmlib] [Fwd: Re: Patient Position]

Luca Picello luca.picello at libero.it
Sun Sep 11 18:49:41 CEST 2005



-------- Original Message --------
Subject: 	Re: Patient Position
Date: 	Sun, 11 Sep 2005 18:45:57 +0200
From: 	Luca Picello <luca.picello at libero.it>
To: 	Jean-Pierre ROUX <jean-pierre.roux at creatis.univ-lyon1.fr>, 
dcmlib at creatis.insa-lyon.fr
References: 	<v0421010ebf41706f510a@[134.214.195.163]>



Hello Jean-Pierre,
thank you for the code. Unfortunately it seems to not work...

using  
  gdcm::Orientation o;
  double typeOrientation = o.TypeOrientation(f);

my typeOrientation is 0 where it should means
 *   #   0 :   Not Applicable (neither 0020,0037 Image Orientation Patient
 *   #                         nor     0020,0032 Image Position    found )

however stepping into the source I can see the tags are read (they are 
found):
bool succ = f->GetImageOrientationPatient( iop );
returns true and iop values are:
iop[0] = 1
iop[1] = 0
iop[2] = 0
iop[3] = 0
iop[4] = 0.979535
iop[5] = 0.201274

in attachment a slice of my dataset.

in gdcmOrientation.cxx I can see a suspicious line:
ori1.x = iop[3]; ori2.y = iop[4]; ori2.z = iop[5];
I changed to:
ori2.x = iop[3]; ori2.y = iop[4]; ori2.z = iop[5];

but I have same result. (always return 0)

Luca




Jean-Pierre ROUX wrote:

>> I am really sorry JP but I need to abuse of your patience again 
>> because I cannot understand gdcm classes functions!!
>
>
> No problem.
> It's the best way for us to know what's easy to understand and what 
> it's not.
>
>> Here it follows my sourc to read dicoms but I can't get patient 
>> position...
>> "de" is NULL and I do not know what to do.
>> I really believe the best gdcm feature to be introduced is... 
>> documentation :-)
>
>
> You're right !
> I started writting something, during the summer, but I never finished 
> it ...
> I think I have to do it ...
>
>>
>>
>> gdcm::DicomDir *e1;
>
>
> Probabely, your main error comes from this line...
> a DICOMDIR is *not* a directory, with DICOM images, but a 'Dicom 
> document' (its header has the same structure than Dicom images.
> It contains a summary of a tree-like stucture :
> --> Patient
>   --> Study
>     --> Serie
>       -->Image
> for all the files held in a 'root directory'.
> It's mainly used on CD, in order to avoid clinical softwares to have 
> to open *all* the images to get, for instance, all the patients names 
> that are stored on the CD ...
>
>> AnsiString fold;
>> fold = dicom_folder;
>> fold = fold + "\\."; // root directory to scan
>
>
> OK.
> Let's suppose the directory contains only one Serie (the 'pronto' 
> images are like that)
>
> std::string fName = "anyone of the files";
> gdcm::File *f = new gdcm::File();
> f->SetFileName(fName);
> f->Load();
>
>> if( !f->IsReadable() )
>> {
>>   AnsiString error_str;
>>   error_str = "File " + AnsiString(fName) + " is not readable. 
>> Operation failed.";
>>   Application->MessageBox( error_str.c_str() , NULL, MB_OK | 
>> MB_ICONERROR );
>>
>>   delete f;
>>   return false;
>
>  }
>
> // One of the files is loaded.
>
>   gdcm::DocEntry *de1 = f->GetDocEntry(0x0018,0x5100);
>   gdcm::DocEntry *de2 = f->GetDocEntry(0x0020,0x0020);
>   if (!de1 or !de2)
>   {
>          --> no Patient Position / Patient Orientation ?!
>          --> stop everything.
>
>   }
>
>   std::string patPosition = GetDocEntryValue(de1);
>   std::string patOrientation = GetDocEntryValue(de2);
>
>   gdcm::Orientation o;
>   double typeOrientation = o.TypeOrientation(f);
>
>  gdcm::SerieHelper *sh = new gdcm::SerieHelper();
>  sh->SetDirectory( fold, true);
>  gdcm::FileList *l = sh->GetFirstCoherentFileList();
>
> // according to typeOrientation, you can decide to 'reverse sort' or not.
>  sh->SetSortOrderToReverse();
>
>  sh->OrderFileList(l);
>
>  vtkGdcmReader *reader = vtkGdcmReader::New();
>  reader->SetCoherentFileList(l);
>
> // according to what you get in patPosition and patOrientation
> // and what you know your soft has to display,
> // you pass a fonction you wrote to reorganize the pixel
> // (you can find in Examples/vtkgdcmSerieViewer.cxx
> // an example of 'mirror' function, and some others)
>  reader->SetUserFunction (userSuppliedFunction);
>  reader->Update();
>
> With no coding, you can see what you'll get bu using :
>
> vtkgdcmViewer dirname=yourProntoImageDirectory mirror
> or
> vtkgdcmViewer dirname=yourProntoImageDirectory reverse
> etc
> (just hit any key to see all the images, one by one, as they are loaded)
>
> JP
>
>>
>> e1 = new gdcm::DicomDir();
>> e1->SetDirectoryName(fold.c_str());
>> e1->Load();
>>
>> // Test if the DicomDir is readable
>> if( !e1->IsReadable() )
>> {
>>   AnsiString error_str;
>>   error_str = "Directory " + AnsiString(dicom_folder) + " is not 
>> readable. Operation failed.";
>>   Application->MessageBox( error_str.c_str() , NULL, MB_OK | 
>> MB_ICONERROR );
>>
>>   delete e1;
>>   return false;
>> }
>>
>> gdcm::DocEntry* de = e1->GetDocEntry(0x0018,0x5100);
>> if (!de) <<<---- NULL
>> {
>>   Application->MessageBox( "no Patient Position ?!?", NULL, MB_OK | 
>> MB_ICONERROR );
>>   delete e1;
>>   return false;
>> }
>>
>> patient position and patient orientation tags exists and with dicom2 
>> utility:
>>       Patient Position (0018,5100)            1    CS [HFS]
>>       Patient Orientation (0020,0020)        2    CS [L\P]
>>
>> thank you again,
>> Luca
>
>
>   Jean-Pierre ROUX
>   CREATIS - CNRS UMR 5515, INSERM U 630
>   Laboratoire de Radiologie Experimentale
>   Hopital Cardiologique
>   28 Avenue du Doyen LEPINE
>   B.P. Lyon-Montchat
>   69394 Lyon Cedex 03
>
>   Tel      : (+33) 04 72 35 74 12
>   Fax      : (+33) 04 72 68 49 16
>   URL      : http://www.creatis.univ-lyon1.fr
>   e-mail   : jpr at creatis.univ-lyon1.fr
>                                    .
>


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.creatis.insa-lyon.fr/pipermail/dcmlib/attachments/20050911/8184d214/attachment.html>


More information about the Dcmlib mailing list