X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fsrc1%2Fbruker2dicom.cxx;h=0473bb3ac3be310019cbbc36da201c6b931604c2;hb=c4aa711c5d7c94a0a7ace93cabc977f06a9703f9;hp=737131192fa455e3b24bcd6484f30d1331931bd0;hpb=0bc6c532e6f065b3b6664c7c6fa831b68757dea5;p=creaBruker.git diff --git a/lib/src1/bruker2dicom.cxx b/lib/src1/bruker2dicom.cxx index 7371311..0473bb3 100644 --- a/lib/src1/bruker2dicom.cxx +++ b/lib/src1/bruker2dicom.cxx @@ -3,7 +3,7 @@ #include #ifndef PATH_MAX // If not defined yet : do it - #define PATH_MAX 2048 + #define PATH_MAX 2048 #endif @@ -37,7 +37,7 @@ bool Bruker2Dicom::Execute() GDCM_NAME_SPACE::DirList dirList(strDirNamein, false, true); // DON'T get recursively the list of files std::string strDirNameout(OutputDirName); -/* +/* if (listonly) { std::cout << "------------List of found files ------------" << std::endl; @@ -58,6 +58,7 @@ bool Bruker2Dicom::Execute() bool canOpen; std::string outputFileName; + // BrukerDataSet br_subject; std::string subject; subject = GDCM_NAME_SPACE::Util::GetPath(*(fileNames.begin()))+ @@ -80,42 +81,39 @@ bool Bruker2Dicom::Execute() // get info for 'Study Description' - /* - BrukerFieldData b_protocol_location=br_acqp.GetFieldData("ACQ_protocol_location"); - acqp_protocol_location = b_protocol_location.GetStringValue()[0]; - cleanString(acqp_protocol_location); -*/ + BrukerFieldData b_name=br_subject.GetFieldData("SUBJECT_name_string"); std::string subject_name = b_name.GetStringValue()[0]; - strPatientName = subject_name; + strPatientName = subject_name; cleanString(subject_name); - + BrukerFieldData b_entry=br_subject.GetFieldData("SUBJECT_entry"); std::string subject_entry = b_entry.GetStringValue()[0]; //cleanString(subject_entry); - subject_entry = subject_entry.substr(11, subject_entry.size()-11); - + subject_entry = subject_entry.substr(11, subject_entry.size()-11); + BrukerFieldData b_position=br_subject.GetFieldData("SUBJECT_position"); std::string subject_position = b_position.GetStringValue()[0]; //cleanString(subject_position); - subject_position = subject_position.substr(9, subject_position.size()-9); - + subject_position = subject_position.substr(9, subject_position.size()-9); + BrukerFieldData b_date=br_subject.GetFieldData("SUBJECT_date"); std::string subject_date = b_date.GetStringValue()[0]; - strStudyTimeDate = subject_date; + strStudyTimeDate = subject_date; cleanString(subject_date); - + BrukerFieldData b_study_name=br_subject.GetFieldData("SUBJECT_study_name"); std::string subject_study_name = b_study_name.GetStringValue()[0]; - subject_study_name = subject_study_name.substr(1, subject_study_name.size()-2); + subject_study_name = subject_study_name.substr(1, subject_study_name.size()-2); cleanString(subject_date); - - strStudyDescr = subject_name + "." + subject_study_name + "." + subject_entry + "." + subject_position + "." + subject_date; - + + // subject_name is already in 'Patient Name' + strStudyDescr = /*subject_name + "." + */ subject_study_name + "." + subject_entry + "." + subject_position + "." + subject_date; + char outputDirName[(unsigned int) PATH_MAX+2]; strStudyUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); - + serieNumber = 0; // ----------------------------------------------------- // Iterate to ALL the objets(files/directories) found in the input directory // (this is level ZERO) @@ -128,7 +126,6 @@ bool Bruker2Dicom::Execute() it != fileNames.end(); ++it) { - if ( !boost::filesystem::is_regular(*it) ) // check twice ! if ( boost::filesystem::is_directory(*it) ) { if (verbose) @@ -165,29 +162,20 @@ bool Bruker2Dicom::Execute() nbSlices = b_list_size.GetIntValue()[0]; strSerieDescr = GDCM_NAME_SPACE::Util::GetName(*it) - + "." + acqp_protocol_location + /* + "." + acqp_protocol_location */ // always the same (in each acquisition) + "." + acqp_scan_name + "." + acqp_method.c_str(); sprintf(outputDirName, "%s%c%s", OutputDirName.c_str(), GDCM_NAME_SPACE::GDCM_FILESEPARATOR, strSerieDescr.c_str() ); - + std::cout << " ================================================================================\n" - << " === [" << GDCM_NAME_SPACE::Util::GetName(*it) << "] -> [" << strSerieDescr << "]\n" + << " === [" << GDCM_NAME_SPACE::Util::GetName(*it) << "] -> [" << strSerieDescr << "]\n" << " ================================================================================" << std::endl; -/* - std::cout << " ================================================================================\n" - << " ========================= [" << GDCM_NAME_SPACE::Util::GetName(*it).c_str() - << acqp_protocol_location.c_str() - << acqp_scan_name.c_str() - << acqp_method.c_str() - << "]\n" - << " ================================================================================" - << std::endl; -*/ + if (verbose) printf ("outputDirName [%s]\n", outputDirName); @@ -227,7 +215,7 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr //if ( ! boost::filesystem::is_directory(*it) ) { if (verbose) - std::cout << "--- [" << *it << "] is a file" << std::endl; + std::cout << "--- [" << *it << "] is a file." << std::endl; } } @@ -238,7 +226,6 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr it != fileNames.end(); ++it) { - if ( !boost::filesystem::is_regular(*it) ) // check twice ! if ( boost::filesystem::is_directory(*it) ) { // will be always "pdata" ... @@ -335,10 +322,9 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr it != fileNames.end(); ++it) { - if ( !boost::filesystem::is_regular(*it) ) - //if ( ! boost::filesystem::is_directory(*it) ) + if ( ! boost::filesystem::is_directory(*it) ) { - std::cout << "--- --- [" << *it << "] is a file" << std::endl; + std::cout << "--- --- [" << *it << "] is a file.." << std::endl; } } @@ -347,7 +333,6 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr it != fileNames.end(); ++it) { - if ( !boost::filesystem::is_regular(*it) ) // check twice ! if ( boost::filesystem::is_directory(*it) ) { @@ -438,7 +423,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr sprintf(char_d3proc,"%s%c%s", level3Directory.c_str(), GDCM_NAME_SPACE::GDCM_FILESEPARATOR,"d3proc" ); if (verbose) - std::cout << "--- => [" << char_d3proc << "]" << std::endl; + std::cout << "try d3proc: --- => [" << char_d3proc << "]" << std::endl; std::string str_d3proc(char_d3proc); canOpen = br_d3proc.LoadFile(str_d3proc); @@ -467,7 +452,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr // GDCM_NAME_SPACE::GDCM_FILESEPARATOR + // "d3proc"; if (verbose) - std::cout << "--- => [" << char_reco << "]" << std::endl; + std::cout << "try reco --- => [" << char_reco << "]" << std::endl; std::string str_reco(char_reco); canOpen = br_reco.LoadFile(str_reco); @@ -529,7 +514,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr std::cout << "FOV (ds method) " << fovX << " " << fovY << std::endl; /// \TODO probabely a more sophisticated accessor will be necessary : - /// (cf : non contiguous slices, overlapping, slice thickness, space between clices, etc) + /// (cf : non contiguous slices, overlapping, slice thickness, space between slices, etc) BrukerFieldData bsliceDistance = br_method.GetFieldData("PVM_SPackArrSliceDistance"); double sliceDistance = bsliceDistance.GetDoubleValue()[0]; @@ -578,6 +563,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr // --------------------------- imageSet = CreateImageSet ( ); + serieNumber++; strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); if (nbInstants==1) // creer un seul fichier .mhd pour toutes les Slices! (images natives) { @@ -621,6 +607,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr fwrite( buffer_2dseq, NX*NY*pixelSize, nbSlices, fp); } fclose(fp); + serieNumber ++; strSerieUID = GDCM_NAME_SPACE::Util::CreateUniqueUID(); } // end if mhd if (dicom) @@ -640,9 +627,9 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr day, strStudyUID, strSerieUID, - strStudyDescr, + strStudyDescr, strSerieDescr, - strStudyTimeDate, + strStudyTimeDate, 0,// index frame number GDCM_NAME_SPACE::UNMODIFIED_PIXELS_IMAGE ); @@ -659,8 +646,8 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr k = 0; for (sliceNb=0; sliceNb Bruker2Dicom::CreateImageSet ( ) return imageSet; } - // =========================================================================================== void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, @@ -1133,7 +1119,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, std::string &serieUID, std::string &studyDescr, std::string &serieDescr, - std::string &strStudyTimeDate, + std::string &strStudyTimeDate, int imgNum, GDCM_NAME_SPACE::ImageContentType contentType )