X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FexCTPET.cxx;h=bcb52c8e2ce894d41de577cc65c1ef4a88ab3cf0;hb=9fc41d585113e37d4d1d1d511e61d2e638096fb3;hp=e52598b90f464f6ef960f4ea5679201f3240c7a5;hpb=81fad420603baa12112543c5fec0ebd362677c15;p=gdcm.git diff --git a/Example/exCTPET.cxx b/Example/exCTPET.cxx index e52598b9..bcb52c8e 100644 --- a/Example/exCTPET.cxx +++ b/Example/exCTPET.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: exCTPET.cxx,v $ Language: C++ - Date: $Date: 2006/01/02 21:54:23 $ - Version: $Revision: 1.1 $ + Date: $Date: 2007/05/23 14:18:05 $ + Version: $Revision: 1.3 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -23,48 +23,15 @@ int main(int argc, char *argv[]) { - if(argc < 2 ) + if(argc < 3 ) { - std::cerr << "RTFM" << std::endl; + std::cerr << argv[0] << " reference directory" << std::endl; return 1; } - // Get the directory name - const char *directory = argv[1]; -#if 0 - gdcm::SerieHelper *s; - std::cout << "Dir Name :[" << directory << "]" << std::endl; - - s = gdcm::SerieHelper::New(); - s->SetLoadMode(gdcm::LD_NOSHADOW | gdcm::LD_NOSEQ); - // 0008|0060 [CS] [Modality] [CT] - gdcm::TagKey modality(0x0008,0x0060); - s->AddRestriction(modality, "CT", gdcm::GDCM_EQUAL); // Keep only files where - // restriction is true - s->SetDirectory(directory, true); // true : recursive exploration - -// std::cout << " ---------------------------------------- Finish parsing :[" -// << directory << "]" << std::endl; -// -// s->Print(); -// std::cout << " ---------------------------------------- Finish printing (1)" -// << std::endl; - - int nbFiles; - // For all the Single SerieUID Files Sets of the gdcm::Serie - gdcm::FileList *l = s->GetFirstSingleSerieUIDFileSet(); - while (l) - { - nbFiles = l->size() ; - //if ( l->size() > 3 ) // Why not ? Just an example, for testing - { - //std::cout << "Sort list : " << nbFiles << " long" << std::endl; - s->OrderFileList(l); // sort the list - } - l = s->GetNextSingleSerieUIDFileSet(); - } - s->Delete(); -#endif + // Get the reference & directory name + const char *reference = argv[1]; + const char *directory = argv[2]; // Open a file A // Open another file B @@ -82,28 +49,28 @@ int main(int argc, char *argv[]) // No -> Return // Yes: We found a match - const char filename1[] = "/tmp/PETCT/case1/WHOLEB001_CT001.dcm"; - const char filename2[] = "/tmp/PETCT/case1/CT_PET001_CT100.dcm"; - gdcm::File *fileRef = gdcm::File::New(); - fileRef->SetFileName( filename2 ); + GDCM_NAME_SPACE::File *fileRef = GDCM_NAME_SPACE::File::New(); + fileRef->SetFileName( reference ); + fileRef->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOW | GDCM_NAME_SPACE::LD_NOSEQ); fileRef->Load(); // 0008 0060 CS 1 Modality std::string modalityRef = fileRef->GetEntryString(0x0008,0x0060); - if( modalityRef == gdcm::GDCM_UNFOUND ) return 1; - if ( !gdcm::Util::DicomStringEqual(modalityRef, "CT") ) return 1; - // 0020 000d UI 1 Study Instance UID - // 0020 000e UI REL Series Instance UID + if( modalityRef == GDCM_NAME_SPACE::GDCM_UNFOUND ) return 1; + if ( !GDCM_NAME_SPACE::Util::DicomStringEqual(modalityRef, "CT") ) return 1; + // 0020 000d UI 1 Study Instance UID + // 0020 000e UI REL Series Instance UID std::string series_uid_ref = fileRef->GetEntryString(0x0020, 0x000e); // 0020 0052 UI 1 Frame of Reference UID std::string frame_uid_ref = fileRef->GetEntryString(0x0020, 0x0052); // 0020 0032 DS 3 Image Position (Patient) - gdcm::DataEntry *imagePosRef = fileRef->GetDataEntry(0x0020,0x0032); + GDCM_NAME_SPACE::DataEntry *imagePosRef = fileRef->GetDataEntry(0x0020,0x0032); assert( imagePosRef->GetValueCount() == 3 ); - gdcm::DirList dirList( directory, true ); - const gdcm::DirListType filenames = dirList.GetFilenames(); - gdcm::DirListType::const_iterator it = filenames.begin(); - gdcm::File *file = gdcm::File::New(); + GDCM_NAME_SPACE::DirList dirList( directory, true ); + const GDCM_NAME_SPACE::DirListType filenames = dirList.GetFilenames(); + GDCM_NAME_SPACE::DirListType::const_iterator it = filenames.begin(); + GDCM_NAME_SPACE::File *file = GDCM_NAME_SPACE::File::New(); + file->SetLoadMode(GDCM_NAME_SPACE::LD_NOSHADOW | GDCM_NAME_SPACE::LD_NOSEQ); for( ; it != filenames.end(); ++it) { file->SetFileName( *it ); @@ -111,17 +78,17 @@ int main(int argc, char *argv[]) std::string modality = file->GetEntryString(0x0008,0x0060); // This is a dual modality: modality should be *different* if( modality == modalityRef ) continue; - if ( !gdcm::Util::DicomStringEqual(modality, "PT") ) continue; + if ( !GDCM_NAME_SPACE::Util::DicomStringEqual(modality, "PT") ) continue; std::string series_uid = file->GetEntryString(0x0020, 0x000e); // Not same series ! if( series_uid == series_uid_ref ) continue; std::string frame_uid = file->GetEntryString(0x0020, 0x0052); if( frame_uid_ref != frame_uid ) continue; - gdcm::DataEntry *imagePos = file->GetDataEntry(0x0020,0x0032); + GDCM_NAME_SPACE::DataEntry *imagePos = file->GetDataEntry(0x0020,0x0032); assert( imagePos->GetValueCount() == 3 ); if( imagePos->GetValue(0) == imagePosRef->GetValue(0) - && imagePos->GetValue(1) == imagePosRef->GetValue(1) - && imagePos->GetValue(2) == imagePosRef->GetValue(2) ) + && imagePos->GetValue(1) == imagePosRef->GetValue(1) + && imagePos->GetValue(2) == imagePosRef->GetValue(2) ) { std::cerr << "We found a match: " << *it << std::endl; }