X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FToInTag.cxx;h=f7e18ec8fb1019db38bcdae622fd9de42aaedc55;hb=888439e26839d7963a380256453361bdbecd1826;hp=fbc2cc129703b2bb406d34db7083a07c175cffca;hpb=bb1ab5267dc422b14306458809d13d6a3e5ebb47;p=gdcm.git diff --git a/Example/ToInTag.cxx b/Example/ToInTag.cxx index fbc2cc12..f7e18ec8 100755 --- a/Example/ToInTag.cxx +++ b/Example/ToInTag.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: ToInTag.cxx,v $ Language: C++ - Date: $Date: 2007/05/29 10:36:10 $ - Version: $Revision: 1.12 $ + Date: $Date: 2007/07/04 17:39:28 $ + Version: $Revision: 1.17 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -83,9 +83,9 @@ int main(int argc, char *argv[]) " { [keep= list of seriesNumber to process] ", " | [drop= list of seriesNumber to ignore] } ", " [taggrid] [skel] ", - " [input = {ACR|DCM}] ", + " [input = {ACR|DCM|IDO}] ", " [extent=image suffix (.IMA, .NEMA, .DCM, ...)] ", - " [listonly] [split] ", + " [listonly] [split] [rubout] ", " [noshadowseq][noshadow][noseq] [verbose] [debug] ", " ", " dirout : will be created if doesn't exist ", @@ -97,6 +97,7 @@ int main(int argc, char *argv[]) " e.g : 1030,1035,1043 ", " taggrid : user knows all the images are 'grid' -ie: not 'col', not 'raw'-", " extent : DO NOT forget the leading '.' ! ", + " input : IDO when *realy* old libIDO images ", " skel: name skeleton eg : patName_1.nema -> skel=patName_ ", " split: creates a tree-like structure of directories as : ", " - Patient ", @@ -104,6 +105,7 @@ int main(int argc, char *argv[]) " --- Position ", " ---- Images (sorted by Trigger Time / ", " Encoding Direction (Row, Column) ", + " rubout : user asks to rubout burnt-in image number ", " noshadowseq: user doesn't want to load Private Sequences ", " noshadow : user doesn't want to load Private groups (odd number) ", " noseq : user doesn't want to load Sequences ", @@ -147,7 +149,9 @@ int main(int argc, char *argv[]) int verbose = am->ArgMgrDefined("verbose"); int split = am->ArgMgrDefined("split"); int listonly = am->ArgMgrDefined("listonly"); - + + bool rubout = ( 0 != am->ArgMgrDefined("rubout") ); + int nbSeriesToKeep; int *seriesToKeep = am->ArgMgrGetListOfInt("keep", &nbSeriesToKeep); int nbSeriesToDrop; @@ -168,6 +172,7 @@ int main(int argc, char *argv[]) skel = am->ArgMgrGetString("skel"); const char *extent = am->ArgMgrGetString("extent",".DCM"); + const char *input = am->ArgMgrGetString("input","DCM"); // if unused Param we give up if ( am->ArgMgrPrintUnusedLabels() ) @@ -351,7 +356,7 @@ int main(int argc, char *argv[]) f->Delete(); continue; } - } + } userFileIdentifier=s->CreateUserDefinedFileIdentifier(f); tokens.clear(); @@ -360,7 +365,7 @@ int main(int argc, char *argv[]) int imageNum; // Within FileName char newName[1024]; - if ( tokens[3] == "gdcmUnfound") // sometimes Trigger Time is not found. CreateUserDefinedFileIdentifier is not aware of the pb. + if ( tokens[3] == GDCM_NAME_SPACE::GDCM_UNFOUND) // sometimes Trigger Time is not found. CreateUserDefinedFileIdentifier is not aware of the pb. { ///this is a trick to build up a lexicographical compliant name : /// eg : fich001.ima vs fich100.ima as opposed to fich1.ima vs fich100.ima @@ -377,10 +382,18 @@ int main(int argc, char *argv[]) else tokens[3] = name; + // Patient's Name + // Series Instance UID + // Image Position (Patient) + // Trigger Time + // In-plane Phase Encoding Direction + // Series Description + // FileName userFileIdentifier = tokens[0] + token + tokens[1] + token + tokens[2] + token - + tokens[3] + token + tokens[4] + token + tokens[5] + token; - } + + tokens[3] + token + tokens[4] + token + tokens[5] + token + tokens[6] + token; + } + if (verbose) std::cout << "[" << userFileIdentifier << "] : " << *it << std::endl; @@ -436,7 +449,8 @@ int main(int argc, char *argv[]) currentFile = it2->second; fullFilename = currentFile->GetFileName(); - lastFilename = GDCM_NAME_SPACE::Util::GetName( fullFilename ); + lastFilename = GDCM_NAME_SPACE::Util::GetName( fullFilename ); + if (verbose) std::cout <<" ------------------------------------------------------------------------------" << std::endl << " Deal with [" << it2->first << "] : ["<GetEntryString(0x0020,0x000d) == GDCM_NAME_SPACE::GDCM_UNFOUND) + if ( currentFile->GetEntryString(0x0020,0x000d) == GDCM_NAME_SPACE::GDCM_UNFOUND) // Study UID { if (verbose) std::cout << "--- new Study UID created" << std::endl; defaultStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); - currentFile->InsertEntryString(defaultStudyUID, 0x0020, 0x000d, "UI" ); } previousPatientName = currentPatientName; @@ -499,6 +512,8 @@ int main(int argc, char *argv[]) system ( systemCommand.c_str() ); } } + currentFile->InsertEntryString(defaultStudyUID, 0x0020, 0x000d, "UI" ); + if ( GDCM_NAME_SPACE::Util::DicomStringEqual(modelName,"TrioTim") ) // for Siemens TrioTim , don't deal with 'Series Instance UID' @@ -513,7 +528,7 @@ int main(int argc, char *argv[]) if (verbose) std::cout << "--- --- new Serie UID created" << std::endl; defaultSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); - currentFile->InsertEntryString(defaultSerieUID, 0x0020, 0x000e, "UI" ); + // currentFile->InsertEntryString(defaultSerieUID, 0x0020, 0x000e, "UI" ); } if (split) @@ -527,6 +542,8 @@ int main(int argc, char *argv[]) previousImagePosition = ""; //currentImagePosition; previousPhaseEncodingDirection = ""; //currentPhaseEncodingDirection; } + currentFile->InsertEntryString(defaultSerieUID, 0x0020, 0x000e, "UI" ); + // end of modelName != "TrioTim " if (previousImagePosition != currentImagePosition) @@ -614,9 +631,9 @@ int main(int argc, char *argv[]) if ( GDCM_NAME_SPACE::Util::DicomStringEqual(modelName,"TrioTim") ) { - if (seriesDescription.find("90", 0) != -1) + if (seriesDescription.find("90", 0) != std::string::npos) chSessionIndex = "1"; // 90 deg -> COL - else if (seriesDescription.find("0", 0)!= -1) + else if (seriesDescription.find("0", 0)!= std::string::npos) chSessionIndex = "2"; // 0 deg -> ROW else { @@ -686,8 +703,8 @@ int main(int argc, char *argv[]) std::cout << "Duplicate ImageOrientation into ImageOrientationPatient" << std::endl; currentFile->InsertEntryString(currentFile->GetEntryString(0x0020, 0x0035), 0x0020, 0x0037, "DS" ); } - - if (taggrid) + + if (taggrid || strcmp(input, "IDO")==0 || strcmp(input, "ido")==0 ) frameIndex++; else { @@ -718,13 +735,15 @@ int main(int argc, char *argv[]) uint8_t *imageData = fh->GetImageDataRaw(); // Don't convert (Gray Pixels + LUT) into (RGB pixels) ?!? fh->SetWriteTypeToDcmExplVR(); - // Put to Black the burnt-in number. - nX = currentFile->GetXSize(); - nY = currentFile->GetYSize(); - for(int y=nY-15; yGetXSize(); + nY = currentFile->GetYSize(); + for(int y=nY-15; y keep unchanged the following : // 'Media Storage SOP Class UID' (0x0002,0x0002) // 'SOP Class UID' (0x0008,0x0016)