X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=Example%2FDenseMultiFramesToDicom.cxx;h=5b652de1974f11f7577c85b4fa056a903a4e7cd6;hb=88a0e8d8c47070a680d71eb6a7ac349993e81a5f;hp=48a74617dac09a7e04cf99297fc17a7536addbf0;hpb=42934e5879027aede60de92af326c3ebe1b9b8ef;p=gdcm.git diff --git a/Example/DenseMultiFramesToDicom.cxx b/Example/DenseMultiFramesToDicom.cxx index 48a74617..5b652de1 100755 --- a/Example/DenseMultiFramesToDicom.cxx +++ b/Example/DenseMultiFramesToDicom.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: DenseMultiFramesToDicom.cxx,v $ Language: C++ - Date: $Date: 2007/06/21 15:06:12 $ - Version: $Revision: 1.5 $ + Date: $Date: 2007/09/18 11:01:55 $ + Version: $Revision: 1.8 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -36,9 +36,8 @@ * WARNING : directory must contain ONLY .txt files */ - void Load(std::ifstream &from, std::string imageName, std::string patName, - std::string strStudyUID, int serieNumber); + std::string strStudyUID, std::string strSerieUID, int serieNumber, int verbose); //std::ifstream& eatwhite(std::ifstream& is); @@ -93,7 +92,7 @@ The terms brightness and contrast are not used in radiology imaging int main(int argc, char *argv[]) { START_USAGE(usage) - " \n DenseMultiFramessToDicom : \n", + " \n DenseMultiFramesToDicom : \n", " - explores recursively the given (single Patient, single Study) directory", " - examines the '.txt' files ", " - Converts the files into 16 bits Dicom files, ", @@ -103,7 +102,7 @@ int main(int argc, char *argv[]) " [studyUID = ] [patName = ] ", " [listonly] [verbose] [debug] ", " ", - "studyUID : *aware* user wants to add the serie ", + " studyUID : *aware* user wants to add the serie ", " to an already existing study ", " verbose : user wants to run the program in 'verbose mode' ", " debug : *developer* wants to run the program in 'debug mode' ", @@ -129,15 +128,20 @@ int main(int argc, char *argv[]) int verbose = am->ArgMgrDefined("verbose"); int listonly = am->ArgMgrDefined("listonly"); std::string patName = am->ArgMgrGetString("patname", dirNamein); + + bool userDefinedStudy = ( 0 != am->ArgMgrDefined("studyUID") ); - bool userDefinedStudy = am->ArgMgrDefined("studyUID"); - const char *studyUID = am->ArgMgrGetString("studyUID"); + const char *studyUID; + if (userDefinedStudy) + studyUID = am->ArgMgrGetString("studyUID"); + + // not described *on purpose* in the Usage ! + bool userDefinedSerie = ( 0 != am->ArgMgrDefined("serieUID") ); + + const char *serieUID; + if(userDefinedSerie) + serieUID = am->ArgMgrGetString("serieUID"); -// not described *on purpose* in the Usage ! - bool userDefinedSerie = am->ArgMgrDefined("serieUID"); - const char *serieUID = am->ArgMgrGetString("serieUID"); - - // if unused Param we give up if ( am->ArgMgrPrintUnusedLabels() ) { @@ -157,7 +161,8 @@ int main(int argc, char *argv[]) } else { - std::cout << "OK : [" << dirNamein << "] is a Directory." << std::endl; + if (verbose) + std::cout << "OK : [" << dirNamein << "] is a Directory." << std::endl; } std::string strDirNamein(dirNamein); @@ -173,8 +178,23 @@ int main(int argc, char *argv[]) std::string filenameout; + + + std::string strStudyUID; - strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); + std::string strSerieUID; + + if (userDefinedStudy) + strSerieUID = studyUID; + else + strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); + + if (userDefinedStudy) + strSerieUID = serieUID; + else + strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); + + int serieNumber =0; GDCM_NAME_SPACE::DirListType fileNames; fileNames = dirList.GetFilenames(); @@ -201,8 +221,9 @@ int main(int argc, char *argv[]) } else { - std::cout << "Success in open file" << *it << std::endl; - Load(from, *it, patName, strStudyUID, serieNumber); + if (verbose) + std::cout << "Success in open file" << *it << std::endl; + Load(from, *it, patName, strStudyUID, strSerieUID, serieNumber, verbose); serieNumber+=2; //return 0; } @@ -211,12 +232,14 @@ int main(int argc, char *argv[]) void Load(std::ifstream &from, std::string imageName, std::string patName, - std::string strStudyUID, int serieNumber) + std::string strStudyUID, std::string strSerieUID, int serieNumber, int verbose) { - std::cout << " ========= Deal with file [" << imageName << "]" << std::endl; + if (verbose) + std::cout << " ========= Deal with file [" << imageName << "]" << std::endl; if (!from) return; - std::cout << " ========= Create Parametric images" << std::endl; + if (verbose) + std::cout << " ========= Create Parametric images" << std::endl; /* was OK for single frames eg : --------------------------- @@ -269,7 +292,8 @@ All pixels with zero strain values are outside the masks. from >> str1; from >> str1; // 52x59x14 - std::cout << "[" << str1 << "]" << std::endl; + if(verbose) + std::cout << "[" << str1 << "]" << std::endl; sscanf( str1.c_str(),"%dx%dx%d", &nx,&ny,&nf); std::cout << nx << " " << ny << " " << nf << std::endl; @@ -284,7 +308,8 @@ All pixels with zero strain values are outside the masks. float temporalResolution; sscanf( str1.c_str(),"%f",&temporalResolution); - std::cout << "temporal Resolution = " << temporalResolution << std::endl; + if(verbose) + std::cout << "temporal Resolution = " << temporalResolution << std::endl; std::getline(from, str1); from >> str1; // First @@ -306,18 +331,18 @@ All pixels with zero strain values are outside the masks. } //float *f = new float(nx*ny); + // -->float *f = new float[nx*ny]; // Would be better ! float *f = (float *) malloc(nx*ny*nf*sizeof(float)); // float mini = FLT_MAX, maxi = FLT_MIN; float val; - - std::string strSerieUID; - strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); + int imageNumber = 0; float currentTime; currentTime = timeStart; - for (int l=0; lInsertEntryString(charImagePosition,0x0020,0x1041, "DS"); //0008 103e LO 1 Series Description @@ -495,9 +520,10 @@ All pixels with zero strain values are outside the masks. fh->SetWriteTypeToDcmExplVR(); char numero[10]; - sprintf(numero, "%02d", l); + sprintf(numero, "%02d", l1); std::string fileName = imageName + "." + numero + ".dcm"; - std::cout << "fileName " << fileName << std::endl; + if(verbose) + std::cout << "fileName " << fileName << std::endl; if( !fh->Write(fileName)) std::cout << "Failed for [" << fileName << "]\n" @@ -517,7 +543,7 @@ All pixels with zero strain values are outside the masks. imageNumber = 0; currentTime = timeStart; - for (int l=0; lInsertEntryString(charImagePosition,0x0020,0x1041, "DS"); //0008 103e LO 1 Series Description @@ -641,7 +667,7 @@ All pixels with zero strain values are outside the masks. fh->SetWriteTypeToDcmExplVR(); char numero[10]; - sprintf(numero, "%02d", l); + sprintf(numero, "%02d", l1); std::string fileName = imageName + ".Anatomical." + numero + ".dcm"; std::cout << "fileName " << fileName << std::endl; @@ -656,4 +682,4 @@ All pixels with zero strain values are outside the masks. } // end loop on frames from.close(); -} +} // end void Load(