]> Creatis software - creaBruker.git/commitdiff
- use creaBruker_EXPORT
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Mon, 22 Nov 2010 16:19:02 +0000 (16:19 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Mon, 22 Nov 2010 16:19:02 +0000 (16:19 +0000)
- don't pass std::string to sprintf().
(causes warning cannot pass objects of non-POD type 'struct std::string' through '...';

CMakeLists.txt
doc/UserDocumentation/CMakeLists.txt
lib/src1/bruker2dicom.cxx
lib/src1/bruker2dicom2.cxx
lib/src1/bruker2dicom2.h
lib/src1/brukerdataset.cpp
lib/src1/brukerdataset.h

index aaf2631c6c08db72a7afc6f11754942d55f9bc53..d127a67d68004d1b28467c9aba749b592ed58361 100644 (file)
@@ -18,6 +18,7 @@ IF(COMMAND cmake_policy AND ${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VER
   CMAKE_POLICY(SET CMP0011 NEW)
 ENDIF(COMMAND cmake_policy AND ${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} GREATER 4)
 
+
 ###################################
 PROJECT(creaBruker)
 ###################################
@@ -58,7 +59,7 @@ CREA_PREVENT_IN_SOURCE_BUILD()
 SET(USE_CREA      ON)
 OPTION(USE_GDCM   "Use GDCM"   ON)
 SET(USE_GDCM_VTK  ON)
-OPTION(USE_GDCM2  "Use GDCM2"   OFF)
+OPTION(USE_GDCM2  "Use gdcm 2.0.14 at least"   OFF)
 SET(USE_WXWIDGETS OFF)
 SET(USE_KWWIDGETS OFF)
 SET(USE_VTK       OFF)
index f12e4d11269ceb29bb484ecca3e68698345af51e..37efffd9c004f54e1635a9ab0f1e9c788a713772 100644 (file)
@@ -1,7 +1,7 @@
 MESSAGE(STATUS "")
 MESSAGE(STATUS "=======================================")
-MESSAGE(STATUS "Configuring bbtk Package Developers' Guide build ")
-USER_DOC_INSTALL_IMAGES(UserDocumentation)
-USER_BUILD_LATEX_DOC(UserDocumentation UserDocumentation)
-USER_BUILD_HTML_DOC_FROM_LATEX(UserDocumentation UserDocumentation)
+MESSAGE(STATUS "Configuring creaBruker Package Developers' Guide build ")
+#USER_DOC_INSTALL_IMAGES(UserDocumentation)
+#USER_BUILD_LATEX_DOC(UserDocumentation UserDocumentation)
+#USER_BUILD_HTML_DOC_FROM_LATEX(UserDocumentation UserDocumentation)
 MESSAGE(STATUS "=======================================")
index b1e939267edf00570b4358100149a86862cd1f40..8ac2129b0de2295420f5f5e902cac9f002fc028d 100644 (file)
@@ -83,7 +83,7 @@ bool Bruker2Dicom::Execute()
  
    switch (type)
    {
-      case 1: {   
+      case 1: {
          bool canOpen = br_subject.LoadFile(subject);
          if (!canOpen)
          {
@@ -491,32 +491,32 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu
        ++it)
    {
       if ( boost::filesystem::is_directory(*it) )
-      { 
-  
+      {
+
          if (verbose)
             std::cout << "--- --- [" << *it << "] is a directory" << std::endl;
 
-        // sprintf(outputDirName, "%s%c%s", currentOutputDirName.c_str(), 
+        // sprintf(outputDirName, "%s%c%s", currentOutputDirName.c_str(),
         //                          GDCM_NAME_SPACE::GDCM_FILESEPARATOR,
         //                                GDCM_NAME_SPACE::Util::GetName(*it).c_str() );
   // MUST be 'pdata'!
 
 //
 // (interest of previous method :
-// If unaware user changed the pdata name, it goes on working   
+// If unaware user changed the pdata name, it goes on working
 //
           std::string str_isa;
           str_isa = (*it) + 
                     GDCM_NAME_SPACE::GDCM_FILESEPARATOR +
                    "isa";
 
-          std::string str_isa_func_name;    
+          std::string str_isa_func_name
           canOpen = br_isa.LoadFile(str_isa);
           if (!canOpen)
           {
              sprintf(outputDirName, "%s%c%s", currentOutputDirName.c_str(), 
                                           GDCM_NAME_SPACE::GDCM_FILESEPARATOR,
-                                          GDCM_NAME_SPACE::Util::GetName(*it).c_str() );        
+                                          GDCM_NAME_SPACE::Util::GetName(*it).c_str() )
           }
           else
           {
@@ -546,7 +546,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string &level2Directory, std::string &cu
             std::cout << "And Init Exception was thrown in DealWithNiveau3 (" << e.what() << "); " 
                       << " We skip [" << level2Directory << "]" << std::endl;
             continue;
-         }          
+         }
       }
    }
 }
@@ -597,7 +597,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu
 
    if (verbose)
       std::cout << "d3proc: --- => [" << char_d3proc << "]" << std::endl;
-   std::string str_d3proc(char_d3proc);       
+   std::string str_d3proc(char_d3proc);     
    canOpen = br_d3proc.LoadFile(str_d3proc);
 
    if (!canOpen)
@@ -612,7 +612,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu
    {
       std::cout << "Hopeless! FillMap failed on 'd3proc'" << std::endl;
       throw ( BrukerHopelessException ("Hopeless! FillMap failed on 'd3proc'"));      
-      //exit(0);  /// \TODO throw an exception !     
+      //exit(0);  /// \TODO throw an exception !
    }
 
    //-------------- end try d3proc;
@@ -661,7 +661,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu
    } else {
       if (verbose)
          std::cout << "[" << str_reco << "] successfully Mapped" << std::endl;
-   }   
+   }
 
    //std::cout << "------------------------------------------------------------------------------------------------" << std::cout;
    // br_reco.PrintSelf();
@@ -1287,7 +1287,7 @@ void Bruker2Dicom::cleanString(std::string &s)
 
    if (s[0] == '<')      
       s= s.substr(1,l-2);
-   std::string repChar("_");   
+   std::string repChar("_");
    GDCM_NAME_SPACE::Util::ReplaceSpecChar(s, repChar);
 }
 
@@ -1390,6 +1390,7 @@ std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( )
 
  // Just for checking
  /*
+
          std::vector<std::vector <double> > imageOrientation;
          std::vector <double> imagePosition; 
          for(int i=0;i<brukerImageList.size();i++)
@@ -1439,7 +1440,7 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels,
    std::ostringstream str;
 
    GDCM_NAME_SPACE::File *file;
-   file = GDCM_NAME_SPACE::File::New();       
+   file = GDCM_NAME_SPACE::File::New();
 
   // Set the image size
    str.str(""); 
@@ -1459,7 +1460,9 @@ void Bruker2Dicom::MakeDicomImage(unsigned char *tabPixels,
   // Set the pixel type
   //      //8, 16, 32, 64 (for double ?)
    str.str("");
-   str << pixelSize*8;     
+   str << pixelSize*8;
+
+  // Bits Allocated
    file->InsertEntryString(str.str(),0x0028,0x0100,"US"); // Bits Allocated
 
    file->InsertEntryString(str.str(),0x0028,0x0101,"US"); // Bits Stored
@@ -1640,7 +1643,7 @@ std::cout << "charImageOrientation  " <<
           if (i!=AoImages[0])
              str << "\\";
       }
-      file->InsertEntryString(str.str(),0x0029,0x0104,"DS"); // Valeurs de b          
+      file->InsertEntryString(str.str(),0x0029,0x0104,"DS"); // Valeurs de b
    }   
 
 // 0020 0x1041 DS 1 Slice Location 
@@ -1660,7 +1663,7 @@ 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!
index df045995c45c964e31018ee99821f94f4f08e2c1..ee9dab446d7c9d83798e8112fa97b63cae6141af 100644 (file)
    #define PATH_MAX 2048
 #endif 
 
-        bool Bruker2Dicom::Execute()
-        {
-            
-            //--- first, Test the system----//
-             bool bigEndian = gdcm::ByteSwap<uint16_t>::SystemIsBigEndian();
-            gdcm::SwapCode sc = gdcm::SwapCode::Unknown;
-            if ( gdcm::ByteSwap<uint16_t>::SystemIsBigEndian() )
-            {
-                sc = gdcm::SwapCode::BigEndian;
-             }
-            else if ( gdcm::ByteSwap<uint16_t>::SystemIsLittleEndian() )
-            {
-                sc = gdcm::SwapCode::LittleEndian;
-            }
-            else // sc == gdcm::SwapCode::Unknown
-            {
-                return 1;
-            }
+bool Bruker2Dicom::Execute()
+{
+
+//--- first, Test the system----//
+   bool bigEndian = gdcm::ByteSwap<uint16_t>::SystemIsBigEndian();
+   gdcm::SwapCode sc = gdcm::SwapCode::Unknown;
+   if ( gdcm::ByteSwap<uint16_t>::SystemIsBigEndian() )
+   {
+      sc = gdcm::SwapCode::BigEndian;
+   }
+   else if ( gdcm::ByteSwap<uint16_t>::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);
 
 // ----------------------------------------------------------------------------------------------------------
 
-void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames,const  std::string &currentOutputDirName)
+void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames, const std::string &currentOutputDirName)
 {
     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 &currentOutputDirName) {
+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 &currentOutputDirName) {
+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<BrukerImage> Bruker2Dicom::CreateImageSet ( )
          br_acqp.SetLoopStructure();
          std::vector<int> tempVect                      = br_acqp.GetLoopStructure() ;
          std::map<std::string, BrukerFieldData> 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<std::string> 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<int> NDiffDir       = br_method.GetFieldData("PVM_DwNDiffDir").GetIntValue();
       BrukerFieldData brf_NDiffDir    = br_method.GetFieldData("PVM_DwNDiffDir");
       const std::vector<int> NDiffDir = brf_NDiffDir.GetIntValue();
-      
+
       //const std::vector<int> NDiffExpEach   = br_method.GetFieldData("PVM_DwNDiffExpEach").GetIntValue();
       BrukerFieldData brf_NDiffExpEach      = br_method.GetFieldData("PVM_DwNDiffExpEach");
       const std::vector<int> NDiffExpEach   =brf_NDiffExpEach.GetIntValue();
-      
+
 //      const std::vector<int> AoImages     = br_method.GetFieldData("PVM_DwAoImages").GetIntValue();
       BrukerFieldData brf_AoImages        = br_method.GetFieldData("PVM_DwAoImages");
       const std::vector<int> AoImages     = brf_AoImages.GetIntValue();
-      
+
       BrukerFieldData brf_DwBvalEach       = br_method.GetFieldData("PVM_DwBvalEach");
       const std::vector<double> 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<i_gr, i_el> at;
index d0478650e5ab2c264c0a77b5524b52c3664539a8..285fe8bd53bf1ef1eb8441692924deec6ee2b234 100644 (file)
@@ -42,7 +42,8 @@
 #define VALID_FILE_SEPARATOR "/"
 #endif
 
-class __declspec( dllexport ) Bruker2Dicom {
+//class __declspec( dllexport ) Bruker2Dicom {
+class creaBruker_EXPORT  Bruker2Dicom {
 
 public:
  /*! \brief Constructor
@@ -97,11 +98,11 @@ void cleanString(std::string &s);
 bool CreateDirectory(const std::string &dirNameout);
 
 int CheckUserDirectory(std::string &userDirName);
-void DealWithMultiStudyDirectory(gdcm::Directory::FilenamesType &fileNames,const  std::string &currentOutputDirName);
-void DealWithSingleStudyDirectory (const std::string &dirname,const  std::string &currentOutputDirName) ;
+void DealWithMultiStudyDirectory(gdcm::Directory::FilenamesType &fileNames, const std::string &currentOutputDirName);
+void DealWithSingleStudyDirectory (const std::string dirname,              const std::string currentOutputDirName) ;
 
-void DealWithNiveau1(std::string &level1Directory, std::string &currentOutputDirName);
-void DealWithNiveau2(std::string &level2Directory, std::string &currentOutputDirName);
+void DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName);
+void DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName);
 void DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName);
                    
 void dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int NX, int NY, int nbSlices, 
@@ -110,7 +111,7 @@ void dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int NX, int NY, in
                   char *outputMhdFileName, char *output2dseqCartoName);
 
 const std::string createDirectory(const std::string &i_name,const std::string &i_dir);
- std::string findFile(const std::string &i_dir,  const std::string i_name);
+ std::string findFile(const std::string &i_dir, const std::string i_name);
 public:
 
 // these ones are for debugging only
index 853199d6e7a9b904500425c0945524859a81d26d..936696ee87ea3074d14e42dfbf0a44fc54f260fe 100644 (file)
@@ -21,7 +21,7 @@ BrukerDataSet::BrukerDataSet(){}
 BrukerDataSet::~BrukerDataSet(){}
 
 
-bool BrukerDataSet::LoadFile(std::string& fileToRead)
+bool BrukerDataSet::LoadFile(std::string fileToRead)
 {
 
 //std::cout <<
index 1056c111d82079510b13c3e452d7d505aac8b9a9..e9cdacbe438744c04b201150573a194b7cdde5e3 100644 (file)
@@ -53,7 +53,7 @@ friend class BrukerKspaceObject;
 public:
        BrukerDataSet();
        ~BrukerDataSet();
-       bool LoadFile(std::string& FileToRead);
+       bool LoadFile(std::string FileToRead);
        bool FillMap();
        void PrintKey(std::string &);
        void PrintSelf();