]> Creatis software - creaBruker.git/commitdiff
#3218 gdcm1 to gdcm2 v3.3.0
authoreduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 22 May 2026 13:11:14 +0000 (15:11 +0200)
committereduardo.davila@creatis.insa-lyon.fr <eduardo.davila@creatis.insa-lyon.fr>
Fri, 22 May 2026 13:11:14 +0000 (15:11 +0200)
CMakeLists.txt
lib/src1/CMakeLists.txt
lib/src1/bruker2dicom2.cxx
lib/src1/bruker2dicom2.h

index 76dee9d0d189abe4cfd10395cd83c715da3c1318..9c953e4b7733445af94b14849f26aade5f80fd5d 100644 (file)
@@ -1,7 +1,7 @@
 # ---------------------------------------------------------------------
 #
 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
-#                        pour la Santé)
+#                        pour la Santé©
 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -112,7 +112,7 @@ OPTION(USE_GDCM2  "Use gdcm 2.0.14 at least"   OFF)
 # No interface for the moment, don't allow to add useless libraries
 SET(USE_WXWIDGETS OFF CACHE BOOL "Use wxWidgets" FORCE)
 SET(USE_KWWIDGETS OFF)
-SET(USE_VTK       OFF)
+SET(USE_VTK       ON)
 SET(USE_ITK       OFF)
 SET(USE_BOOST     ON)
 
@@ -149,6 +149,7 @@ MARK_AS_ADVANCED(
 
  #   ${PROJECT_SOURCE_DIR}/lib/_YOUR_OWN_LIBRARY_SOURCE_DIRECTORY_
     ${PROJECT_SOURCE_DIR}/lib/src1
+
     )
 #==================================
 
index a0fb5b4cc42db17502903680673758b3e8826c5f..72530b2055fb0de2528afd0a6264da17e1cea934 100644 (file)
@@ -1,7 +1,7 @@
 # ---------------------------------------------------------------------
 #
 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
-#                        pour la Santé)
+#                        pour la Santé©
 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -44,7 +44,7 @@ IF ( BUILD_${LIBRARY_NAME} )
     include
        ../../../
 )
-  
+
   #----------------------------------------------------------------------------
   # LIBRARY HEADERS (TO BE INSTALLED)
   # EITHER LIST ALL .h IN CURRENT DIR USING NEXT LINE:
@@ -80,7 +80,7 @@ endif()
   SET ( ${LIBRARY_NAME}_LINK_LIBRARIES
       ${crea_LIBRARIES}
     #    ${WXWIDGETS_LIBRARIES}
-    #    ${VTK_LIBRARIES}
+        ${VTK_LIBRARIES}
     #    ${ITK_LIBRARIES}
       ${GDCM_LIBRARIES}
  #EED31jan2013     ${BOOST_LIBRARIES}
index 29da638669abc9712d57afeaea4d90c4f1298cc9..bd983cac96b3556e31c5ac4cffa77dcd6550076a 100644 (file)
@@ -2,7 +2,7 @@
        # ---------------------------------------------------------------------
        #
        # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
-       #                        pour la Santé)
+       #                        pour la Santé©
        # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
        # Previous Authors : Laurent Guigues, Jean-Pierre Roux
        # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -38,6 +38,7 @@
 
 bool Bruker2Dicom::Execute()
 {
+       int dimension = 1;
 
 //--- first, Test the system----//
    bool bigEndian = gdcm::ByteSwap<uint16_t>::SystemIsBigEndian();
@@ -94,11 +95,15 @@ bool Bruker2Dicom::Execute()
             {
                    if(! boost::filesystem::is_directory( (*it) ) )
                    {
-                       if( (*it).filename() == "subject")
+//EED 2026-05-19         
+//                       if( (*it).filename() == "subject")
+                       if( (*it).path().filename() == "subject")
                        {
                            subjectFound = true;
                        }
-                       if( (*it).filename() == "acqp")
+//EED 2026-05-19         
+//                       if( (*it).filename() == "acqp")
+                       if( (*it).path().filename() == "acqp")
                        {
                            acqpFound = true;
                        }
@@ -133,7 +138,7 @@ bool Bruker2Dicom::Execute()
                         subject_name = b_name.GetStringValue()[0];
                         strPatientName = subject_name;
                         cleanString(subject_name);
-                        DealWithSingleStudyDirectory (InputDirName, OutputDirName);
+                        DealWithSingleStudyDirectory (InputDirName, OutputDirName, dimension);
                        }
                     break;
                 }
@@ -142,7 +147,7 @@ bool Bruker2Dicom::Execute()
                     {
                      subject_name = "defaultPatName";
                         strPatientName = subject_name;
-                     DealWithSingleStudyDirectory (InputDirName,OutputDirName);
+                     DealWithSingleStudyDirectory (InputDirName,OutputDirName, dimension);
                         break;
                     }
       
@@ -157,7 +162,7 @@ bool Bruker2Dicom::Execute()
 
 // ----------------------------------------------------------------------------------------------------------
 
-void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames, const std::string &currentOutputDirName)
+void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &dirNames, const std::string &currentOutputDirName, int dimension)
 {
     gdcm::Directory::FilenamesType::iterator it;
 
@@ -204,7 +209,7 @@ void Bruker2Dicom::DealWithMultiStudyDirectory (gdcm::Directory::FilenamesType &
             strPatientName = subject_name;
             cleanString(subject_name);  
         
-            DealWithSingleStudyDirectory(dirList.GetDirectories().begin()->c_str(), currentOutputDirName);
+            DealWithSingleStudyDirectory(dirList.GetDirectories().begin()->c_str(), currentOutputDirName,dimension);
         }  
       }
       else
@@ -218,7 +223,7 @@ 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)
+void Bruker2Dicom::DealWithSingleStudyDirectory  (const std::string dirname, const std::string i_outputDir, int dimension)
 {
      bool res;  
      // creation directory : 'nom du patient'
@@ -276,7 +281,9 @@ void Bruker2Dicom::DealWithSingleStudyDirectory  (const std::string dirname, con
         {
          if(boost::filesystem::is_directory(*it))
             {
-             std::string fname = (*it).filename() ;
+//EED 2026-05-19         
+//             std::string fname = (*it).filename() ;
+             std::string fname = (*it).path().filename().c_str() ;
               //if (fname == "AdjResult")                  continue; what's the point?
              boost::filesystem::directory_iterator it_level((*it));
             bool bAcqp = false;
@@ -285,16 +292,23 @@ void Bruker2Dicom::DealWithSingleStudyDirectory  (const std::string dirname, con
             std::string nameAcqp;
             for(; it_level != end_iter; ++it_level)
             {
-                if( (*it_level).filename() == "acqp")
+//EED 2026-05-19         
+//                if( (*it_level).filename() == "acqp")
+                if( (*it_level).path().filename() == "acqp")
                 {
-                    strAcqp =  (*it_level).string();
-                    nameAcqp = (*it_level).filename();
+//EED 2026-05-19         
+//                    strAcqp =  (*it_level).string();
+//                    nameAcqp = (*it_level).filename();
+                    strAcqp =  (*it_level).path().string().c_str();
+                    nameAcqp = (*it_level).path().filename().c_str();
                     boost::algorithm::replace_all( strAcqp, INVALID_FILE_SEPARATOR, VALID_FILE_SEPARATOR);
                     bAcqp = true;
                }
                else if (boost::filesystem::is_directory( (*it_level) ) && nextLevel == "")
                {
-                   nextLevel = (*it_level).string(); // Hope we found only one directory
+//EED 2026-05-19         
+//                   nextLevel = (*it_level).string(); // Hope we found only one directory
+                   nextLevel = (*it_level).path().string(); // Hope we found only one directory
                }
                else
                {
@@ -337,7 +351,9 @@ void Bruker2Dicom::DealWithSingleStudyDirectory  (const std::string dirname, con
         if (verbose)
            printf ("outputDirName [%s]\n", output.c_str());
         try {
-               DealWithNiveau1( (*it).string(), output);
+//EED 2026-05-19         
+//               DealWithNiveau1( (*it).string(), output);
+               DealWithNiveau1( (*it).path().string(), output, dimension);
             }
        catch (BrukerHopelessException &e)
            {
@@ -351,7 +367,7 @@ void Bruker2Dicom::DealWithSingleStudyDirectory  (const std::string dirname, con
 
 // =====================================================================
 
-void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName) {
+void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName, int dimension) {
 //
 // e.g. : at level 1, in B67d1.Bp1/6
 //
@@ -371,9 +387,13 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
      boost::filesystem::directory_iterator it(level1Directory), it_end;
    for(; it != it_end; it++)
    {
-       if((*it).leaf() == "method")
+//EED 2026-05-19         
+//       if((*it).leaf() == "method")
+       if((*it).path().filename() == "method")
        {
-          bmethod = br_method.LoadFile((*it).string());
+//EED 2026-05-19         
+//          bmethod = br_method.LoadFile((*it).string());
+          bmethod = br_method.LoadFile((*it).path().string());
           break;
        }
    }
@@ -383,9 +403,13 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
    {
           for(; it != it_end; it++)
           {
-                if((*it).leaf() == "imnd")
+//EED 2026-05-19         
+//                if((*it).leaf() == "imnd")
+                if((*it).path().filename() == "imnd")
                  {
-                     bmethod = br_method.LoadFile((*it).string());
+//EED 2026-05-19         
+//                     bmethod = br_method.LoadFile((*it).string());
+                     bmethod = br_method.LoadFile((*it).path().string());
                      break;
                 }
             }
@@ -415,9 +439,13 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
        boost::filesystem::directory_iterator itDir(level1Directory), it_end;
        for(; itDir != it_end; ++itDir)
        {
-           if ( boost::filesystem::is_directory(*itDir) && (*itDir).leaf() == "pdata")
+//EED 2026-05-19         
+//           if ( boost::filesystem::is_directory(*itDir) && (*itDir).leaf() == "pdata")
+           if ( boost::filesystem::is_directory(*itDir) && (*itDir).path().filename() == "pdata")
            {
-               std::string output = createDirectory( (*itDir).leaf() , currentOutputDirName);
+//EED 2026-05-19         
+//               std::string output = createDirectory( (*itDir).leaf() , currentOutputDirName);
+               std::string output = createDirectory( (*itDir).path().filename().c_str() , currentOutputDirName);
                  // will be always "pdata" ...
                boost::filesystem::directory_iterator itDirInside(*itDir), it_inside_end;
                for(; itDirInside != it_end; ++it)
@@ -425,8 +453,11 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
                   // 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);
+//EED 2026-05-19         
+//                     output = createDirectory( (*itDirInside).leaf() , output);
+//                     DealWithNiveau2( (*itDirInside).string(), output);
+                     output = createDirectory( (*itDirInside).path().filename().c_str() , output);
+                     DealWithNiveau2( (*itDirInside).path().string(), output,dimension);
                   }
                }
            }
@@ -441,7 +472,7 @@ void Bruker2Dicom::DealWithNiveau1(std::string level1Directory, std::string curr
 
 // =====================================================================
 
-void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName) {
+void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName, int dimension) {
 
 // e.g. : at level 2 in B67d1.Bp1/6/pdata
 //
@@ -453,9 +484,13 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
     boost::filesystem::directory_iterator it(level2Directory), it_end;
     for(; it != it_end; ++it)
     {
-        if((*it).leaf() == "isa")
+//EED 2026-05-19         
+//        if((*it).path().leaf() == "isa")
+        if((*it).path().filename() == "isa")
         {
-            bisa =  br_isa.LoadFile((*it).string());
+//EED 2026-05-19         
+//            bisa =  br_isa.LoadFile((*it).string());
+            bisa =  br_isa.LoadFile((*it).path().string());
           if (bisa)
           {
              br_isa.FillMap();
@@ -470,7 +505,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
         }
     }
          try {
-             DealWithNiveau3(level2Directory, output);
+             DealWithNiveau3(level2Directory, output,dimension);
          }
          catch (BrukerHopelessException &e)
          {
@@ -490,7 +525,7 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
 // =====================================================================
 //
 
-void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName){
+void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName,int dimension){
 
 //
 // e.g. at level 3, in
@@ -721,7 +756,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string &level3Directory, std::string &cu
    // This one will be important!
    // ---------------------------
    try {
-      imageSet = CreateImageSet ( );
+      imageSet = CreateImageSet( dimension );
    }
    catch (BrukerInitException& e)
    {
@@ -1314,10 +1349,10 @@ void Bruker2Dicom::getImhDataType(BrukerFieldData &bDPT, std::string &mhdDataPix
 
 // ===========================================================================================
 
-std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( )
+std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( int dimension )
 {
          std::vector<BrukerImage> imageSet;      
-         br_acqp.SetLoopStructure();
+         br_acqp.SetLoopStructure( dimension );
          std::vector<int> tempVect                      = br_acqp.GetLoopStructure() ;
          std::map<std::string, BrukerFieldData> map     = br_acqp.GetBrukerHeaderMap();
 
@@ -1869,9 +1904,13 @@ const std::string  Bruker2Dicom::createDirectory(const std::string &i_name, cons
      boost::filesystem::directory_iterator it(i_dir), it_end;
      for(; it != it_end; ++it)
      {
-         if((*it).leaf() == i_name)
+//EED 2026-05-19         
+//         if((*it).path().leaf() == i_name)
+         if((*it).path().filename() == i_name)
          {
-             file = (*it).string();
+//EED 2026-05-19         
+//             file = (*it).string();
+             file = (*it).path().string();
              bres = true;
              break;
          }
@@ -1883,9 +1922,13 @@ const std::string  Bruker2Dicom::createDirectory(const std::string &i_name, cons
          boost::filesystem::directory_iterator itless(pth.branch_path()), it_end;
          for(; itless != it_end; ++itless)
         {
-            if((*itless).leaf() == i_name)
+//EED 2026-05-19         
+//            if((*itless).leaf() == i_name)
+            if((*itless).path().filename() == i_name)
            {
-                file = (*itless).string();
+//EED 2026-05-19         
+//                file = (*itless).string();
+                file = (*itless).path().string();
                 bres = true;
                 break;
             }
index 483d408964fdb0937e4722227b492ce6b6890301..8d265900e499d80a915c16354b2faf5a1db6de7e 100644 (file)
@@ -2,7 +2,7 @@
        # ---------------------------------------------------------------------
        #
        # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image 
-       #                        pour la Santé)
+       #                        pour la Santé©
        # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
        # Previous Authors : Laurent Guigues, Jean-Pierre Roux
        # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
@@ -114,7 +114,7 @@ void MakeDicomImage(unsigned char *tabPixels,
               int imgNum, int  imagecontenttype//gdcm2 dont have such things, I think, as ImageContentTYpe 
       );
       
-std::vector<BrukerImage> CreateImageSet ( );
+std::vector<BrukerImage> CreateImageSet ( int dimension );
 
 void getImhDataType(BrukerFieldData &bDPT, 
                     std::string &mhdDataPixelType, 
@@ -125,12 +125,12 @@ 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,int dimension);
+void DealWithSingleStudyDirectory (const std::string dirname,               const std::string currentOutputDirName,int dimension) ;
 
-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 DealWithNiveau1(std::string level1Directory, std::string currentOutputDirName, int dimension);
+void DealWithNiveau2(std::string level2Directory, std::string currentOutputDirName, int dimension);
+void DealWithNiveau3(std::string &level3Directory, std::string &currentOutputDirName, int dimension);
                    
 void dealWithCarto(gdcm::Directory::FilenamesType &fileNames, int NX, int NY, int nbSlices, 
                    double fovX, double fovY, double sliceDistance,