]> Creatis software - creaBruker.git/commitdiff
Fix bug when checking incoherences
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 2 Jul 2009 16:06:18 +0000 (16:06 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 2 Jul 2009 16:06:18 +0000 (16:06 +0000)
lib/src1/bruker2dicom.cxx
lib/src1/brukerobjectvaryingproperties.cpp

index eac2702eb6f9c6d6e2c6901efdb822b757552f1c..a381993f822a9f4da8199105c03a77c690edcce6 100644 (file)
@@ -403,7 +403,13 @@ void Bruker2Dicom::DealWithNiveau2(std::string level2Directory, std::string curr
             std::cout << "And Exception was thrown in DealWithNiveau3 (" << e.what() << "); " 
                       << " We skip [" << level2Directory << "]" << std::endl;
             continue;
-         }          
+         }
+         catch (BrukerInitException &e)
+         {
+            std::cout << "And Init Exception was thrown in DealWithNiveau3 (" << e.what() << "); " 
+                      << " We skip [" << level2Directory << "]" << std::endl;
+            continue;
+         }                  
       }
    }
 }
@@ -509,7 +515,7 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr
    if (!canOpen)
    {
       std::cout << "Hopeless! FillMap failed on [" << str_reco << "]" << std::endl;
-      throw ( BrukerHopelessException ("Hopeless!FillMap failed on 'reco'"));  
+      throw ( BrukerHopelessException ("Hopeless! FillMap failed on 'reco'"));  
       //exit(0);  /// \TODO throw an exception !     
    }
    //std::cout << "------------------------------------------------------------------------------------------------" << std::cout;
@@ -608,8 +614,9 @@ void Bruker2Dicom::DealWithNiveau3(std::string level3Directory, std::string curr
    }
    catch (BrukerInitException& e)
    {
-      std::cout <<  "an Exception was throw in CreateImageSet ( ); " << e.what() 
-                << "catched in DealWithNiveau3" << std::endl;
+      if (verbose)
+         std::cout <<  "an Init Exception was thrown in CreateImageSet ( ); " << e.what() 
+                   <<  "catched in DealWithNiveau3" << std::endl;
       //return;
       throw (e);
    }
@@ -1118,11 +1125,12 @@ 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)
         {
-           throw ( BrukerInitException  ("Bruker2Dicom::CreateImageSet failure ") );
+           throw ( BrukerInitException  ("ObjectVaryingProperties.init() failure in Bruker2Dicom::CreateImageSet()") );
         }
 
          br_acqp.SetImageLoopStructure();
@@ -1153,7 +1161,7 @@ std::vector<BrukerImage> Bruker2Dicom::CreateImageSet ( )
            imageOrientation =  imageSet[i].getRotationMatrixRPS2XYZ();
            std::cout << "\t  Orientation " ;
            for(int i1=0; i1<3;i1++)for(int i2=0; i2<3;i2++)
-              std::cout << imageOrientation[i1][i2] << " ";
+              std::cout << imageOrientation[i1][i2] << " ";CreateImageSet
        
            //std::cout << "\t  Abs Time " << imageSet[i].getAbsoluteTimePosition();
            std::cout << "\t  Relat Time " << imageSet[i].getRelativeTimePosition();
index f33a396bb10a6754262e0d281d0867d8968e5a8b..1222eae8387f757e7d43a448bd55ed2f4b0a02c0 100644 (file)
@@ -100,15 +100,20 @@ int  BrukerObjectVaryingProperties::getAcquisitionOrder(unsigned int theValue) c
 }*/
 
 void BrukerObjectVaryingProperties::computeAcquisitionOrder(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct){
-   std::vector<int> AcqOrder;
-  if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) throw 7;
+  std::vector<int> AcqOrder;
+  
+  if (BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() != LoopStruct[3]*LoopStruct[1]) {
+     std::cout << "BrukerHM[(std::string) 'ACQ_obj_order'].GetIntValue().size() " << BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue().size() 
+               << " LoopStruct[3] : " << LoopStruct[3] << " * LoopStruct[1] : " << LoopStruct[1] << " = " << LoopStruct[3]*LoopStruct[1] << std::endl;  
+     throw 7;
+  }
   if (LoopStruct.size() < 4 ) throw 8;
   for (int i =0 ;i<LoopStruct[3];i++)
      AcqOrder.push_back((int) BrukerHM[(std::string) "ACQ_obj_order"].GetIntValue()[i*LoopStruct[1]]/LoopStruct[1]);
   AcquisitionOrder=AcqOrder;
 };
 
-std :: vector < std :: vector < double > >  BrukerObjectVaryingProperties::getOrientation(unsigned int theValue) const{
+std :: vector < std :: vector < double > >  BrukerObjectVaryingProperties::getOrientation(unsigned int theValue) const {
    if (theValue < Orientation.size())return Orientation[theValue];
    //else throw 9;
    else throw BrukerSizeException("Orientation", theValue, Orientation.size() );
@@ -205,7 +210,7 @@ void BrukerObjectVaryingProperties::computePositionTimePerNR(std::map<std::strin
 /*!
     \fn BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> BrukerHM,std::vector<int> LoopStruct)
  */
-bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> & BrukerHM, std::vector<int> & LoopStruct)
+bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData> &BrukerHM, std::vector<int> &LoopStruct)
 {
    try {
       computeAcquisitionOrder (BrukerHM, LoopStruct);
@@ -216,7 +221,13 @@ bool BrukerObjectVaryingProperties::init(std::map<std::string, BrukerFieldData>
       computePositionTimePerNR(BrukerHM, LoopStruct);
       computeTE               (BrukerHM);
    }
-   
+   catch (int i)
+   {
+      std::cout << "Failure during BrukerObjectVaryingProperties::init err code : " << i << std::endl;
+      if (i==7)
+         std::cout << "Probabely non standard acquisition (extra loop not yet dealt with)" << std::endl;
+      return false;   
+   }   
    catch (...)
    {
       std::cout << "Failure during BrukerObjectVaryingProperties::init " << std::endl;