X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=lib%2Fsrc1%2Fbruker2dicom2.cxx;fp=lib%2Fsrc1%2Fbruker2dicom2.cxx;h=ee9dab446d7c9d83798e8112fa97b63cae6141af;hb=cc4fb89e6ab8668e7e8830a2e65dc53dc1773de5;hp=df045995c45c964e31018ee99821f94f4f08e2c1;hpb=98b3f017715cfc0207bda87f08afe0c565607baa;p=creaBruker.git diff --git a/lib/src1/bruker2dicom2.cxx b/lib/src1/bruker2dicom2.cxx index df04599..ee9dab4 100644 --- a/lib/src1/bruker2dicom2.cxx +++ b/lib/src1/bruker2dicom2.cxx @@ -10,26 +10,26 @@ #define PATH_MAX 2048 #endif - bool Bruker2Dicom::Execute() - { - - //--- first, Test the system----// - bool bigEndian = gdcm::ByteSwap::SystemIsBigEndian(); - gdcm::SwapCode sc = gdcm::SwapCode::Unknown; - if ( gdcm::ByteSwap::SystemIsBigEndian() ) - { - sc = gdcm::SwapCode::BigEndian; - } - else if ( gdcm::ByteSwap::SystemIsLittleEndian() ) - { - sc = gdcm::SwapCode::LittleEndian; - } - else // sc == gdcm::SwapCode::Unknown - { - return 1; - } +bool Bruker2Dicom::Execute() +{ + +//--- first, Test the system----// + bool bigEndian = gdcm::ByteSwap::SystemIsBigEndian(); + gdcm::SwapCode sc = gdcm::SwapCode::Unknown; + if ( gdcm::ByteSwap::SystemIsBigEndian() ) + { + sc = gdcm::SwapCode::BigEndian; + } + else if ( gdcm::ByteSwap::SystemIsLittleEndian() ) + { + sc = gdcm::SwapCode::LittleEndian; + } + else // sc == gdcm::SwapCode::Unknown + { + return 1; + } - // ----- Check input directory name ----- + // ----- Check input directory name ----- if ( ! boost::filesystem::is_directory(InputDirName) ) { std::cout << "KO : [" << InputDirName << "] is not a Directory." << std::endl; @@ -41,7 +41,7 @@ std::cout << "OK : [" << InputDirName << "] is a Directory." << std::endl; } - // ----- Check output directory name ----- + // ----- Check output directory name ----- if ( ! boost::filesystem::is_directory(OutputDirName) ) { bool res=CreateDirectory(OutputDirName); @@ -131,7 +131,7 @@ // ---------------------------------------------------------------------------------------------------------- -void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames,const std::string ¤tOutputDirName) +void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames, const std::string ¤tOutputDirName) { gdcm::Directory::FilenamesType::iterator it; @@ -144,7 +144,7 @@ void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType & subjectFound = false; if (verbose) std::cout << "in 'DealWithMultiStudyDirectory' [" << *it << "] is a directory" << std::endl; - + gdcm::Directory dirList; dirList.Load(*it); gdcm::Directory::FilenamesType fileNames; @@ -191,13 +191,14 @@ void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType & // ---------------------------------------------------------------------------------------------------------- -void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string &dirname, const std::string &i_outputDir) //(gdcm::Directory::FilenamesType &fileNames) +//void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string &dirname, const std::string &i_outputDir) //(gdcm::Directory::FilenamesType &fileNames) +void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string dirname, const std::string i_outputDir) { bool res; - // creation directory : 'nom du patient' + // creation directory : 'nom du patient' std::string output = createDirectory(subject_name.c_str(), i_outputDir); - + if (subjectFound) { BrukerFieldData b_entry=br_subject.GetFieldData("SUBJECT_entry"); @@ -262,7 +263,7 @@ void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string &dirname, co { strAcqp = (*it_level).string(); nameAcqp = (*it_level).filename(); - boost::algorithm::replace_all( strAcqp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); + boost::algorithm::replace_all( strAcqp, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR); bAcqp = true; } else if (boost::filesystem::is_directory( (*it_level) ) && nextLevel == "") @@ -286,7 +287,7 @@ void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string &dirname, co BrukerFieldData b_protocol_location=br_acqp.GetFieldData("ACQ_protocol_location"); acqp_protocol_location = b_protocol_location.GetStringValue()[0]; cleanString(acqp_protocol_location); - + BrukerFieldData b_scan_name=br_acqp.GetFieldData("ACQ_scan_name"); acqp_scan_name = b_scan_name.GetStringValue()[0]; cleanString(acqp_scan_name); @@ -295,48 +296,47 @@ void Bruker2Dicom::DealWithSingleStudyDirectory (const std::string &dirname, co b_method.PrintSelf(); // why? acqp_method = b_method.GetStringValue()[0]; cleanString(acqp_method); - + BrukerFieldData b_list_size = br_acqp.GetFieldData("ACQ_O1_list_size"); nbSlices = b_list_size.GetIntValue()[0]; - strSerieDescr = fname + strSerieDescr = fname + "." + acqp_scan_name + "." + acqp_method.c_str(); /*sprintf(outputDirName, "%s%c%s", i_outputDir.c_str(), VALID_FILE_SEPARATOR, strSerieDescr.c_str() ); std::string temp(outputDirName); - boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR);*/ + boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);*/ output = createDirectory(strSerieDescr, output); if (verbose) - printf ("outputDirName [%s]\n", output); + printf ("outputDirName [%s]\n", output.c_str()); try { - - DealWithNiveau1( (*it).string(), output); - } - catch (BrukerHopelessException &e) - { - std::cout << "And Exception was thrown in DealWithNiveau1 (" << e.what() << ") " << std::endl; - continue; - } - } + DealWithNiveau1( (*it).string(), output); + } + catch (BrukerHopelessException &e) + { + std::cout << "And Exception was thrown in DealWithNiveau1 (" << e.what() << ") " << std::endl; + continue; + } + } } } // end of : for (GDCM_NAME_SPACE::DirListType::iterator it } // ===================================================================== -void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string ¤tOutputDirName) { +void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName) { // // e.g. : at level 1, in B67d1.Bp1/6 // // acqp fid imnd pdata pulseprogram spnam0 spnam1 - + //gdcm::Directory dirList; //dirList.Load(level1Directory); // DON'T get recursively the list of files //gdcm::Directory::FilenamesType fileNames; //fileNames = dirList.GetFilenames(); - + // ----------------------------------------------------- // Iterate to ALL the objets(files/directories) found in the input directory // ----------------------------------------------------- @@ -381,9 +381,9 @@ void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string &cu ##$PVM_NSPacks=2 ##$PVM_SPackArrNSlices=( 2 ) 7 1 - */ + */ br_method.FillMap(); - + try { boost::filesystem::directory_iterator itDir(level1Directory), it_end; @@ -394,28 +394,28 @@ void Bruker2Dicom::DealWithNiveau1(std::string &level1Directory, std::string &cu std::string output = createDirectory( (*itDir).leaf() , currentOutputDirName); // will be always "pdata" ... boost::filesystem::directory_iterator itDirInside(*itDir), it_inside_end; - for(; itDirInside != it_end; ++it) - { - // we take the first and hope that we have only one! - if ( boost::filesystem::is_directory(*itDirInside)) - { - output = createDirectory( (*itDirInside).leaf() , output); - DealWithNiveau2( (*itDirInside).string(), output); - } - } - } - } + for(; itDirInside != it_end; ++it) + { + // we take the first and hope that we have only one! + if ( boost::filesystem::is_directory(*itDirInside)) + { + output = createDirectory( (*itDirInside).leaf() , output); + DealWithNiveau2( (*itDirInside).string(), output); + } + } + } + } } catch(BrukerHopelessException &e) { std::cout << "And Exception was thrown in DealWithNiveau2 (" << e.what() << ") " << std::endl; } - + } // ===================================================================== -void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string ¤tOutputDirName) { +void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName) { // e.g. : at level 2 in B67d1.Bp1/6/pdata // @@ -438,7 +438,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu std::string str_isa_func_name = b_isa_func_name.GetStringValue()[0]; cleanString(str_isa_func_name); output = createDirectory(str_isa_func_name, currentOutputDirName); - + } break; } @@ -450,15 +450,14 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu { std::cout << "And Exception was thrown in DealWithNiveau3 (" << e.what() << "); " << " We skip [" << level2Directory << "]" << std::endl; - + } catch (BrukerInitException &e) { std::cout << "And Init Exception was thrown in DealWithNiveau3 (" << e.what() << "); " << " We skip [" << level2Directory << "]" << std::endl; - - } - + + } } // @@ -520,7 +519,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu // -------------------try reco - + std::string str_reco = level3Directory + VALID_FILE_SEPARATOR + "reco"; canOpen = br_reco.LoadFile(findFile( level3Directory, "reco")); if (!canOpen) @@ -528,9 +527,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu std::cout << "Hopeless! cannot find 'reco' in [" << str_reco << "]" << std::endl; throw ( BrukerHopelessException ("Hopeless! cannot find 'reco'")); //exit(0); /// \TODO throw an exception ! - } - - else { + } else { if (verbose) std::cout << "[" << str_reco << "] successfully Loaded " << std::endl; canOpen = br_reco.FillMap(); @@ -539,12 +536,11 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu std::cout << "Hopeless! FillMap failed on [" << str_reco << "]" << std::endl; throw ( BrukerHopelessException ("Hopeless! FillMap failed on 'reco'")); - } - else { + } else { if (verbose) std::cout << "[" << str_reco << "] successfully Mapped" << std::endl; } - } + } //std::cout << "------------------------------------------------------------------------------------------------" << std::cout; // br_reco.PrintSelf(); @@ -640,7 +636,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu VALID_FILE_SEPARATOR, "MhdFiles"); std::string temp(currentOutputMhdDirName); boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(currentOutputMhdDirName, "%s", temp); + sprintf(currentOutputMhdDirName, "%s", temp.c_str()); std::string strCurrentOutputMhdDirName(currentOutputMhdDirName); res = CreateDirectory( strCurrentOutputMhdDirName ); if (!res) { @@ -668,20 +664,20 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu sprintf( original2dseqName, "%s%c%s", level3Directory.c_str(),VALID_FILE_SEPARATOR, "2dseq"); temp = level3Directory + VALID_FILE_SEPARATOR + "2dseq" ; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(original2dseqName, "%s", temp); + sprintf(original2dseqName, "%s", temp.c_str()); /**/ // \TODO : tenir compte du bazar precedent // load 2dseq in memory - + fp = fopen(temp.c_str(), "rb"); if (!fp) { // try 2dseq_Angio2D ?!? temp = original2dseqName_XXX; sprintf( original2dseqName_XXX, "%s%s", original2dseqName, "_Angio2D"); - sprintf(original2dseqName_XXX, "%s", temp); + sprintf(original2dseqName_XXX, "%s", temp.c_str()); fp = fopen(original2dseqName_XXX, "rb"); if (!fp) { @@ -713,7 +709,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu serieNumber++; gdcm::UIDGenerator uid; strSerieUID = uid.Generate(); - + if (nbInstants==1) // creer un seul fichier .mhd pour toutes les Slices! (images natives) { if (verbose) @@ -722,9 +718,9 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu { sprintf(outputMhdFileName, "%s%cMhdData_All_the_Slices.mhd", currentOutputMhdDirName, VALID_FILE_SEPARATOR); - temp = currentOutputDirName + VALID_FILE_SEPARATOR + "MhdFiles" + VALID_FILE_SEPARATOR +"MhdData_All_the_Slices.mhd"; + temp = currentOutputDirName + VALID_FILE_SEPARATOR + "MhdFiles" + VALID_FILE_SEPARATOR +"MhdData_All_the_Slices.mhd"; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(outputMhdFileName,"%s", temp); + sprintf(outputMhdFileName,"%s", temp.c_str()); fp=fopen(temp.c_str(), "w"); if (!fp) { @@ -754,7 +750,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu currentOutputDirName.c_str(), VALID_FILE_SEPARATOR); temp = currentOutputDirName + VALID_FILE_SEPARATOR + "2dseq_All_the_Slices"; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(output2dseqSliceFileName,"%s",temp); + sprintf(output2dseqSliceFileName,"%s",temp.c_str()); fp=fopen(temp.c_str(), "wb"); if (!fp) { @@ -768,8 +764,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu fclose(fp); serieNumber ++; gdcm::UIDGenerator uid; - strSerieUID = uid.Generate(); - + strSerieUID = uid.Generate(); } // end if mhd if (dicom) { @@ -777,7 +772,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu VALID_FILE_SEPARATOR); temp = currentOutputDirName + VALID_FILE_SEPARATOR + "2dseq_All_the_Slices.dcm"; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(output2dseqSliceFileName, "%s", temp); + sprintf(output2dseqSliceFileName, "%s", temp.c_str()); /* ----------- Write Dicom Image ---------------*/ MakeDicomImage(buffer_2dseq, @@ -816,7 +811,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu VALID_FILE_SEPARATOR, k ); temp = outputMhdFileName; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(outputMhdFileName, "%s", temp); + sprintf(outputMhdFileName, "%s", temp.c_str()); if (verbose) std::cout << "--- Output MHD file [" << outputMhdFileName << "]" << std::endl; fp=fopen(outputMhdFileName, "w"); @@ -852,7 +847,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu currentOutputDirName.c_str(), VALID_FILE_SEPARATOR,sliceNb); temp = output2dseqSliceFileName; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(output2dseqSliceFileName, "%s", temp); + sprintf(output2dseqSliceFileName, "%s", temp.c_str()); fp=fopen(output2dseqSliceFileName, "wb"); if (!fp) { @@ -921,7 +916,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu currentOutputDirName.c_str(), VALID_FILE_SEPARATOR, sliceNb); temp= output2dseqSliceFileName; boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(output2dseqSliceFileName, "%s", temp); + sprintf(output2dseqSliceFileName, "%s", temp.c_str()); MakeDicomImage( pixelsForCurrentSlice, @@ -1028,16 +1023,16 @@ void Bruker2Dicom::dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int sprintf(copyFile, "cp %s %s%c%s", (*it).c_str() , currentOutputDirName.c_str(), VALID_FILE_SEPARATOR, lastFileName.c_str()); std::string temp(copyFile); - boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(copyFile, "%s", temp); - + boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); + sprintf(copyFile, "%s", temp.c_str()); + system(copyFile); sprintf(outputMhdFileName, "%s%c%s%s", currentOutputDirName.c_str(),VALID_FILE_SEPARATOR, lastFileName.c_str(), ".mhd" ); temp = outputMhdFileName; - boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(outputMhdFileName, "%s", temp); - + boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); + sprintf(outputMhdFileName, "%s", temp.c_str()); + if (verbose) std::cout << "--- Output Carto MHD file [" << outputMhdFileName << "]" << std::endl; @@ -1075,18 +1070,18 @@ void Bruker2Dicom::dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int { sprintf(output2dseqCartoName, "%s%c%s%s", currentOutputDirName.c_str(), VALID_FILE_SEPARATOR, lastFileName.c_str(), ".dcm" ); - + std::string temp(output2dseqCartoName); boost::algorithm::replace_all( temp, INVALID_FILE_SEPARATOR , VALID_FILE_SEPARATOR); - sprintf(output2dseqCartoName,"%s", temp); - + sprintf(output2dseqCartoName,"%s", temp.c_str()); + if (verbose) std::cout << "--- end create name output2dseqCartoName file [" << output2dseqCartoName << "]" << std::endl; gdcm::UIDGenerator uid; strSerieUID = uid.Generate(); - + gdcm::Filename file( (*it).c_str() ); - std::string strNewSerieDescr(strSerieDescr+ "_" + file.GetName()); + std::string strNewSerieDescr(strSerieDescr+ "_" + file.GetName()); MakeDicomImage(buffer_carto, NX, NY, @@ -1127,7 +1122,7 @@ int Bruker2Dicom::CheckUserDirectory(std::string &userDirName) { gdcm::Directory dirList; dirList.Load(userDirName); // DON'T get recursively the list of files - + gdcm::Directory::FilenamesType fileNames; fileNames = dirList.GetFilenames(); @@ -1151,7 +1146,7 @@ int Bruker2Dicom::CheckUserDirectory(std::string &userDirName) acqpFound= true; // user passes a 'serie', not a 'study' else acqpFound = false; // user passed a 'non study' directory; Hope it's a 'set of studies' directory! - + int type; if (subjectFound ) type = 1; // user passed a 'study else if (acqpFound) type = 2; // user passed a 'serie' @@ -1214,10 +1209,11 @@ void Bruker2Dicom::cleanString(std::string &s) l--; s = s.substr(0, l); } - + if (s[0] == '<') s= s.substr(1,l-2); - std::string repChar("_"); + std::string repChar("_"); + /// \TODO use boost::algorithm::replace_all( ////boost::algorithm::replace_all( //GDCM_NAME_SPACE::Util::ReplaceSpecChar(s, repChar); } @@ -1298,7 +1294,7 @@ std::vector Bruker2Dicom::CreateImageSet ( ) br_acqp.SetLoopStructure(); std::vector tempVect = br_acqp.GetLoopStructure() ; std::map map = br_acqp.GetBrukerHeaderMap(); - + bool result = br_acqp.ObjectVaryingProperties.init(map,tempVect); if (result == false) @@ -1365,7 +1361,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, std::string &serieDescr, std::string &strStudyTimeDate, int imgNum, - int contentType + int contentType ) { std::ostringstream str; @@ -1389,11 +1385,11 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, ds.Replace(at.GetAsDataElement()); } - //file.SetDataSet( createDataSet(str.str(),0x0028,0x0011,"US")); + //file.SetDataSet( createDataSet(str.str(),0x0028,0x0011,"US")); // Set the image size str.str(""); str << X; - + // file->InsertEntryString(str.str(),0x0028,0x0011,"US"); // Columns str.str(""); str << Y; @@ -1510,7 +1506,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, at.SetValue(serieUID); ds.Replace(at.GetAsDataElement()); } - { + { gdcm::Attribute< 0x0008,0x0020, gdcm::VR::DA> at; at.SetValue(strStudyTimeDate.substr(10,11).c_str()); ds.Replace(at.GetAsDataElement()); @@ -1542,44 +1538,44 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, // //8, 16, 32, 64 (for double ?) str.str(""); - str << pixelSize*8; + str << pixelSize*8; // file->InsertEntryString(str.str(),0x0028,0x0100,"US"); // Bits Allocated // file->InsertEntryString(str.str(),0x0028,0x0101,"US"); // Bits Stored - str.str(""); - str << pixelSize*8-1; + //str.str(""); + //str << pixelSize*8-1; // file->InsertEntryString(str.str(),0x0028,0x0102,"US"); // High Bit // Set the pixel representation // 0/1 , 0=unsigned // file->InsertEntryString("1",0x0028,0x0103, "US"); // Pixel Representation - + // Set the samples per pixel // 1:Grey level, 3:RGB // file->InsertEntryString("1",0x0028,0x0002, "US"); // Samples per Pixel // 0028 0030 DS 2 Pixel Spacing - str.str(""); - str << spacingX << "\\" << spacingY; + //str.str(""); + //str << spacingX << "\\" << spacingY; // file->InsertEntryString(str.str(),0x0028,0x0030, "DS"); // Pixel Spacing - + // 0018 0050 DS 1 Slice Thickness - str.str(""); - str << sliceDistance; + //str.str(""); + //str << sliceDistance; // file->InsertEntryString(str.str(),0x0018,0x0050, "DS"); - + // 0020 0011 IS 1 Series Number - str.str(""); - str << serieNumber; + //str.str(""); + //str << serieNumber; // file->InsertEntryString(str.str(),0x0020,0x0011, "IS"); - + // 0020|0013 [IS] [Instance Number] instanceNumber++; - str.str(""); - str << instanceNumber; + //str.str(""); + //str << instanceNumber; // file->InsertEntryString(str.str(),0x0020,0x0013, "IS"); - + // 1.2.840.10008.5.1.4.1.1.4.1 : Enhanced MR Image Storage - // file->InsertEntryString("1.2.840.10008.5.1.4.1.1.4.1" , 0x0002, 0x0002, "UI"); // [Media Storage SOP Class UID] + // file->InsertEntryString("1.2.840.10008.5.1.4.1.1.4.1" , 0x0002, 0x0002, "UI"); // [Media Storage SOP Class UID] // file->InsertEntryString("1.2.840.10008.5.1.4.1.1.4.1" , 0x0008, 0x0016, "UI"); // [SOP Class UID] // OK : MR is NOT multiframe, but I want just a quick an dirty solution @@ -1594,7 +1590,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, // // file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI"); // file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI"); -// +// //// 0008 0020 DA 1 Study Date //// 0008 0030 TM 1 Study Time // @@ -1609,7 +1605,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels, // file->InsertEntryString("MR",0x0008,0x0060, "CS"); // // 0020 0037 DS 6 Image Orientation (Patient) - char charImageOrientation[256]; +// char charImageOrientation[256]; /* std::cout << "charImageOrientation " << @@ -1623,12 +1619,12 @@ std::cout << "charImageOrientation " << { gdcm::Attribute< 0x0020,0x0037, gdcm::VR::DS> at; - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][0], 0); - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][1], 1); - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][2], 2); - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][0], 3); - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][1], 4); - at.SetValue( imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][2], 4); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][0], 0); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][1], 1); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[0][2], 2); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][0], 3); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][1], 4); + at.SetValue(imageSet[imgNum].getRotationMatrixRPS2XYZ()[1][2], 4); ds.Replace(at.GetAsDataElement()); } // file->InsertEntryString(charImageOrientation,0x0020,0x0037, "DS"); @@ -1638,22 +1634,21 @@ std::cout << "charImageOrientation " << imageSet[imgNum].getTranslationVectorRPS2XYZ()[0], imageSet[imgNum].getTranslationVectorRPS2XYZ()[1], imageSet[imgNum].getTranslationVectorRPS2XYZ()[2]); - + //file->InsertEntryString(charImagePosition,0x0020,0x0032, "DS"); //0020 0032 DS 3 Image Position (Patient) - + // 0020 0032 DS 3 Image Position (Patient) { gdcm::Attribute< 0x0020,0x0032,gdcm::VR::DS> at; - at.SetValue( imageSet[imgNum].getTranslationVectorRPS2XYZ()[0], 0); - at.SetValue( imageSet[imgNum].getTranslationVectorRPS2XYZ()[1], 1); - at.SetValue(imageSet[imgNum].getTranslationVectorRPS2XYZ()[2], 2); - ds.Replace(at.GetAsDataElement()); + at.SetValue(imageSet[imgNum].getTranslationVectorRPS2XYZ()[0], 0); + at.SetValue(imageSet[imgNum].getTranslationVectorRPS2XYZ()[1], 1); + at.SetValue(imageSet[imgNum].getTranslationVectorRPS2XYZ()[2], 2); + ds.Replace(at.GetAsDataElement()); } - - + // Private creator /* - + 0029|0010 [LO] [Private Creator] [CREATIS HEADER ] 0029|0011 [LO] [Private Creator] [CREATIS for BRUKER to DICOM] 0029|1031 [LO] [] [4.0.7571167 ] @@ -1690,17 +1685,17 @@ std::cout << "charImageOrientation " << //{ // gdcm::Attribute< 0x0029,0x0010, gdcm::VR::LO> at; // at.SetValue(.SetValue( "CREATIS HEADER"); - // ds.Replace(at.GetAsDataElement()); + // ds.Replace(at.GetAsDataElement()); //} //{ - // gdcm::Attribute< 0x0029,0x0011, gdcm::VR::LO> at; - // // at.SetValue( "CREATIS FOR BRUKER-TO-DICOM"); + // gdcm::Attribute< 0x0029,0x0011, gdcm::VR::LO> at; + // // at.SetValue( "CREATIS FOR BRUKER-TO-DICOM"); // ds.Replace(at.GetAsDataElement()); //} // file->InsertEntryString("CREATIS HEADER", 0x0029,0x0010, "LO"); - //file->InsertEntryString("CREATIS FOR BRUKER-TO-DICOM", 0x0029,0x0011, "LO"); - + // file->InsertEntryString("CREATIS FOR BRUKER-TO-DICOM", 0x0029,0x0011, "LO"); + BrukerFieldData brf_method = br_method.GetFieldData("Method"); const std::vector method = brf_method.GetStringValue(); @@ -1711,28 +1706,28 @@ std::cout << "charImageOrientation " << // ds.Replace(at.GetAsDataElement()); //} //file->InsertEntryString(method[0], 0x0029,0x0100, "LO"); - + std::cout << " method[" << method[0] << "]" << std::endl; if (method[0] == "DtiEpi" || method[0] == "DtiStandard") { // const std::vector NDiffDir = br_method.GetFieldData("PVM_DwNDiffDir").GetIntValue(); BrukerFieldData brf_NDiffDir = br_method.GetFieldData("PVM_DwNDiffDir"); const std::vector NDiffDir = brf_NDiffDir.GetIntValue(); - + //const std::vector NDiffExpEach = br_method.GetFieldData("PVM_DwNDiffExpEach").GetIntValue(); BrukerFieldData brf_NDiffExpEach = br_method.GetFieldData("PVM_DwNDiffExpEach"); const std::vector NDiffExpEach =brf_NDiffExpEach.GetIntValue(); - + // const std::vector AoImages = br_method.GetFieldData("PVM_DwAoImages").GetIntValue(); BrukerFieldData brf_AoImages = br_method.GetFieldData("PVM_DwAoImages"); const std::vector AoImages = brf_AoImages.GetIntValue(); - + BrukerFieldData brf_DwBvalEach = br_method.GetFieldData("PVM_DwBvalEach"); const std::vector DwBvalEach = brf_DwBvalEach.GetDoubleValue(); - + std::cout << "nb directions : " << NDiffDir[0] << " nb valeurs de b par direction : " << NDiffExpEach[0] << " nb images for b=0 : " << AoImages[0] << std::endl; - + str.str(""); str << NDiffDir[0]; { @@ -1764,7 +1759,7 @@ std::cout << "charImageOrientation " << at.SetValue( DwBvalEach[i], i); ds.Replace(at.GetAsDataElement()); } - // file->InsertEntryString(str.str(),0x0029,0x0104,"DS"); // Valeurs de b + // file->InsertEntryString(str.str(),0x0029,0x0104,"DS"); // Valeurs de b } file.SetDataSet(ds); @@ -1799,8 +1794,8 @@ std::cout << "charImageOrientation " << // GDCM_NAME_SPACE::FileHelper *fileH; // fileH = GDCM_NAME_SPACE::FileHelper::New(file); -// fileH->SetContentType(contentType); -// +// fileH->SetContentType(contentType); +// // // cast is just to avoid warnings (*no* conversion is performed) // //fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float! // @@ -1875,8 +1870,8 @@ const std::string Bruker2Dicom::createDirectory(const std::string &i_name, cons //const gdcm::DataSet Bruker2Dicom::createDataSet(const std::string &i_val, -// const uint16_t &i_gr, const uint16_t &i_el, -// const gdcm::VR &i_vr) +// const uint16_t &i_gr, const uint16_t &i_el, +// const gdcm::VR &i_vr) // //{ // gdcm::Attribute at;