[Dcmlib] Re: Patient Position
Jean-Pierre ROUX
jean-pierre.roux at creatis.insa-lyon.fr
Mon Sep 5 05:48:20 CEST 2005
>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
More information about the Dcmlib
mailing list