]> Creatis software - gdcm.git/commitdiff
Allow user to create mutiframes
authorjpr <jpr>
Fri, 28 Mar 2008 15:36:57 +0000 (15:36 +0000)
committerjpr <jpr>
Fri, 28 Mar 2008 15:36:57 +0000 (15:36 +0000)
Example/Dense2007ToDicom.cxx

index afeb9b5be2aa02558dd7745e2e13df7749a990e7..bf76dcee397034af2c3af41e4541c28281753330 100755 (executable)
@@ -3,8 +3,8 @@
   Program:   gdcm
   Module:    $RCSfile: Dense2007ToDicom.cxx,v $
   Language:  C++
-  Date:      $Date: 2008/03/17 13:16:10 $
-  Version:   $Revision: 1.6 $
+  Date:      $Date: 2008/03/28 15:36:57 $
+  Version:   $Revision: 1.7 $
                                                                                 
   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
   l'Image). All rights reserved. See Doc/License.txt or
@@ -28,7 +28,7 @@
 #include "gdcmFileHelper.h"
 #include "gdcmDebug.h"
 #include "gdcmDirList.h"
-
+#include "gdcmUtil.h"
 #include "gdcmArgMgr.h"
 
 /**
   * Hope they don't change soon!
   */  
 
+void LoadPeakStrain(std::ifstream &from, std::string imageName, const char * patientname, std::string studyUID);
+void LoadStrain(std::ifstream &from, std::string imageName, const char * patientname, bool createMultiFrame, std::string studyUID);
+void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName,
+                    const char * patientname, int nbFrames, std::string studyUID, std::string serieUID);
 
-void LoadPeakStrain(std::ifstream &from, std::string imageName);
-void LoadStrain(std::ifstream &from, std::string imageName);
-void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName);
-
-int verbose;  
+bool verbose;
 
 int main(int argc, char *argv[])
 {
@@ -51,6 +51,8 @@ int main(int argc, char *argv[])
    "        Converts the '.txt' files into 16 bits Dicom Files,               ",
    " usage:                                                                   ",
    " Dense2007ToDicom strain=...strain.txt  peak_strain=...peak_strain.txt    ",
+   "                 [patientname = Patient's name]                           ",
+   "                 [m]ultiframe                                             ",
    "                 [verbose] [debug]                                        ",
    "                                                                          ",
    " verbose  : user wants to run the program in 'verbose mode'               ",
@@ -81,11 +83,15 @@ int main(int argc, char *argv[])
       
    const char *strain      = am->ArgMgrWantString("strain",usage);
    const char *peak_strain = am->ArgMgrWantString("peak_strain",usage);
+
+   const char *patientName = am->ArgMgrGetString("patientname");
    
+   bool createMultiFrame = (am->ArgMgrDefined("m") != 0);
+         
    if (am->ArgMgrDefined("debug"))
       GDCM_NAME_SPACE::Debug::DebugOn();
 
-   verbose  = am->ArgMgrDefined("verbose");      
+   verbose  =  ( 0 != am->ArgMgrDefined("verbose") );     
 
    // if unused Param we give up
    if ( am->ArgMgrPrintUnusedLabels() )
@@ -98,34 +104,35 @@ int main(int argc, char *argv[])
 
    // ----- Begin Processing -----
 
-
    std::ifstream fromPeakStrain( peak_strain );             
    if ( !fromPeakStrain )
    {
-      std::cout << "Can't open file" << peak_strain << std::endl;
+      std::cout << "Can't open file [" << peak_strain << "]" << std::endl;
       exit(0);
    }
 
    std::ifstream fromStrain( strain );      
    if ( !fromStrain )
    {
-      std::cout << "Can't open file" << strain << std::endl;
+      std::cout << "Can't open file [" << strain << "]" << std::endl;
       exit(0);
-   }  
+   }
+     
+   std::string strStudyUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
        
-   std::cout << "Success in open file" << peak_strain << std::endl;
-   LoadPeakStrain(fromPeakStrain, peak_strain);
+   std::cout << "Success in open file [" << peak_strain << "]" << std::endl;
+   LoadPeakStrain(fromPeakStrain, peak_strain, patientName,strStudyUID);
    fromPeakStrain.close();  
 
-   std::cout << "Success in open file" << strain << std::endl;
-   LoadStrain(fromStrain, strain);
+   std::cout << "Success in open file [" << strain << "]" << std::endl;
+   LoadStrain(fromStrain, strain, patientName, createMultiFrame, strStudyUID);
    fromStrain.close();      
    return 1;            
 }
 
 // =====================================================================================================================
 
-void LoadPeakStrain(std::ifstream &from, std::string textFileName)
+void LoadPeakStrain(std::ifstream &from, std::string textFileName, const char * patientname,std::string studyUID)
 {
 // in sax_base_slice0_peak_strain.txt :
 
@@ -162,7 +169,7 @@ followed by their Peak E22 strain, an array of NP elements,
     from >> str1;
     from >> str1;
     from >> NP;
-    
+
     std::cout << "NP : " << NP << std::endl; 
 
    //Origin of (readout, phase enc, slice sel) coordinates in 3D =  87.3243 3.19392 88.2381
@@ -177,27 +184,27 @@ followed by their Peak E22 strain, an array of NP elements,
      from >> str1;
      from >> str1;
      from >> str1;
-     
+
      float readout,  phase_enc, slice_sel;
      from >> readout;
      from >> phase_enc;
      from >> slice_sel;
      std::cout << " readout " << readout << " phase_enc " << phase_enc << " slice_sel " << slice_sel << std::endl;
-     
+
     // Readout direction in 3D =  -0.162314 -0.0771294 -0.983720
-    
+
     from >> str1;
     from >> str1;
     from >> str1;
     from >> str1;
     from >> str1;
-    
+
     float readoutX, readoutY, readoutZ;
     from >> readoutX;
     from >> readoutY;       
     from >> readoutZ;
     std::cout << " readoutX " << readoutX <<  " readoutY " << readoutY <<  " readoutZ " << readoutZ << std::endl;
-     
+
 // Phase Enc. direction in 3D =  -0.540606 -0.827052 0.154046
 
      from >> str1;
@@ -206,7 +213,7 @@ followed by their Peak E22 strain, an array of NP elements,
      from >> str1;
      from >> str1;
      from >> str1;
-     
+
     float phase_encX, phase_encY, phase_encZ;
     from >> phase_encX;
     from >> phase_encY;       
@@ -220,7 +227,7 @@ followed by their Peak E22 strain, an array of NP elements,
      from >> str1;
      from >> str1;
      from >> str1;
-     
+
     float slice_selX, slice_selY, slice_selZ;
     from >> slice_selX;
     from >> slice_selY;       
@@ -228,7 +235,6 @@ followed by their Peak E22 strain, an array of NP elements,
     std::cout << " slice_selX " << slice_selX <<  " slice_selY " << slice_selY <<  " slice_selZ " << slice_selZ << std::endl; 
 
 
-
 // Skip 5 lines :
 /*
 The following are the (readout, phase enc, slice sel) coordinates (mm) of the grid points for which strains are calculated,
@@ -257,15 +263,15 @@ std::cout << "------------start skipping 1 line---------------- " << std::endl;
    std::getline(from, str1);
    std::cout << "[" << str1 << "]" << std::endl;
 std::cout << "------------stop skipping ---------------- " << std::endl;
-  
+
    float *X = new float[NP];
    float *Y = new float[NP];   
    float *Z = new float[NP];
-      
+
    char c;
    int i;   
    for (i=0; i<NP; i++) {
-      
+
       from >> X[i];
       for (;;) {
         if (!from.get(c))
@@ -275,8 +281,8 @@ std::cout << "------------stop skipping ---------------- " << std::endl;
           break;
         }
      }
-  
-      from >> Y[i];    
+
+      from >> Y[i];  
       for (;;) {
         if (!from.get(c))
           break;
@@ -284,65 +290,74 @@ std::cout << "------------stop skipping ---------------- " << std::endl;
           from.putback(c);
           break;
         }
-     }        
+     }     
       from >> Z[i];
-                   
+
    } // end for i<NP
 
    std::cout << "--------------- Ecc_strain ------------------" << std::endl;
    float *ecc_strain = new float[NP];
    for (i=0; i<NP; i++) {
-       from >> ecc_strain[i]; 
-       if (verbose)
-       std::cout <<  ecc_strain[i] <<  std::endl;
+      from >> ecc_strain[i]; 
+      if (verbose)
+         std::cout <<  ecc_strain[i] <<  std::endl;
    }
+   delete []ecc_strain;
 
    std::cout << "--------------- Err_strain ------------------" << std::endl;
    float *err_strain = new float[NP];
    for (i=0; i<NP; i++) {
-       from >> err_strain[i]; 
-       if (verbose)
-       std::cout <<  err_strain[i] <<  std::endl;
+      from >> err_strain[i]; 
+      if (verbose)
+         std::cout <<  err_strain[i] <<  std::endl;
    }
-   
+   delete []err_strain;
+
    std::cout << "--------------- E11_strain ------------------" << std::endl;
    float *e11_strain = new float[NP];
    for (i=0; i<NP; i++) {
-       from >> e11_strain[i]; 
-       if (verbose)
-       std::cout <<  e11_strain[i] <<  std::endl;
+      from >> e11_strain[i]; 
+      if (verbose)
+         std::cout <<  e11_strain[i] <<  std::endl;
    }  
-   
+   delete []e11_strain;
+
    std::cout << "--------------- E22_strain ------------------" << std::endl;
    float *e22_strain = new float[NP];
    for (i=0; i<NP; i++) {
-       from >> e22_strain[i]; 
-       if (verbose)
-       std::cout <<  e22_strain[i] <<  std::endl;
+      from >> e22_strain[i]; 
+      if (verbose)
+         std::cout <<  e22_strain[i] <<  std::endl;
    }    
-   std::string dcmImageName;    
+   delete []e22_strain;
 
+   std::string dcmImageName;    
+   std::string serieUID;
+   
 //followed by their peak Ecc strain, an array of NP elements,
+   serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
    dcmImageName = textFileName + "_peak_Ecc_strain.dcm";
-   MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName);
+   MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
 
 //followed by their peak Err strain, an array of NP elements,
+   serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
    dcmImageName = textFileName + "_peak_Err_strain.dcm";
-   MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName);
-   
+   MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
+
 //followed by their peak E11 strain, an array of NP elements,
+   serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
    dcmImageName = textFileName + "_peak_E11_strain.dcm";
-   MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName);
-   
+   MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
+
 //followed by their Peak E22 strain, an array of NP elements,
+   serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
    dcmImageName = textFileName + "_peak_E22_strain.dcm";
-   MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName);         
+   MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);         
 }
 
 // =====================================================================================================================
 
-void LoadStrain(std::ifstream &from, std::string textFileName)
+void LoadStrain(std::ifstream &from, std::string textFileName, const char * patientname, bool createMultiFrame, std::string studyUID)
 {
 
 // in sax_base_slice0_strain.txt :
@@ -372,11 +387,11 @@ Note that RV Err, E11 and E22 strains are not calculated due to the small thickn
       return;
 
    std::string str1;
-   int NP;    // Number of Pints
+   int NP;    // Number of Points
    int NCF;   // Number of cine frames
    float TR;  // Temporal resolution
    float FFS; // First frame starts
-   
+
    // Number of cine frames = 18
     from >> str1;
     from >> str1;
@@ -408,7 +423,7 @@ Note that RV Err, E11 and E22 strains are not calculated due to the small thickn
     from >> str1;
     from >> str1;
     from >> NP;
-    
+
     std::cout << "NP : " << NP << std::endl; 
 
    //Origin of (readout, phase enc, slice sel) coordinates in 3D = 87.324341 3.193918 88.238113 
@@ -423,27 +438,27 @@ Note that RV Err, E11 and E22 strains are not calculated due to the small thickn
      from >> str1;
      from >> str1;
      from >> str1;
-     
+
      float readout,  phase_enc, slice_sel;
      from >> readout;
      from >> phase_enc;
      from >> slice_sel;
      std::cout << " readout " << readout << " phase_enc " << phase_enc << " slice_sel " << slice_sel << std::endl;
-     
+
     // Readout direction in 3D =  -0.162314 -0.0771294 -0.983720
-    
+
     from >> str1;
     from >> str1;
     from >> str1;
     from >> str1;
     from >> str1;
-    
+
     float readoutX, readoutY, readoutZ;
     from >> readoutX;
     from >> readoutY;       
     from >> readoutZ;
     std::cout << " readoutX " << readoutX <<  " readoutY " << readoutY <<  " readoutZ " << readoutZ << std::endl;
-     
+
 // Phase Enc. direction in 3D =  -0.540606 -0.827052 0.154046
 
      from >> str1;
@@ -452,7 +467,7 @@ Note that RV Err, E11 and E22 strains are not calculated due to the small thickn
      from >> str1;
      from >> str1;
      from >> str1;
-     
+
     float phase_encX, phase_encY, phase_encZ;
     from >> phase_encX;
     from >> phase_encY;       
@@ -536,64 +551,164 @@ std::cout << "------------stop skipping ---------------- " << std::endl;
       from >> Z[i];              
    }
 
+char frame[10];
+std::string dcmImageName;    
+std::string serieUID;
+
+std::cout << "=======================================================================================" << createMultiFrame << std::endl;
+if(!createMultiFrame) {     // One image per file here (single frame)
+
+serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
+float *ecc_strain = new float[NP];
+for (int nbr_of_frames=0; nbr_of_frames < NCF;  nbr_of_frames++)
+{
+sprintf(frame, "_%d", nbr_of_frames);
+
    std::cout << "--------------- Ecc_strain ------------------" << std::endl;
-   float *ecc_strain = new float[NP];
    for (i=0; i<NP; i++) {
        from >> ecc_strain[i];
        if (verbose)
        std::cout <<  ecc_strain[i] <<  std::endl;
    }
-
+//followed by their Ecc strain, an array of NP elements,
+   dcmImageName = textFileName + frame + "_Ecc_strain.dcm";
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);      
+}// end for   nbr_of_frames
+delete []ecc_strain;
+
+serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
+float *err_strain = new float[NP];
+for (int nbr_of_frames=0; nbr_of_frames < NCF;  nbr_of_frames++)
+{
+sprintf(frame, "_%d", nbr_of_frames);
    std::cout << "--------------- Err_strain ------------------" << std::endl;
-   float *err_strain = new float[NP];
    for (i=0; i<NP; i++) {
        from >> err_strain[i]; 
        if (verbose)
        std::cout <<  err_strain[i] <<  std::endl;
    }
-   
+//followed by their  Err strain, an array of NP elements,
+   dcmImageName = textFileName + frame + "_Err_strain.dcm";
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
+}// end for   nbr_of_frames
+delete []err_strain;
+serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
+float *e11_strain = new float[NP];
+for (int nbr_of_frames=0; nbr_of_frames < NCF;  nbr_of_frames++)
+{
+sprintf(frame, "_%d", nbr_of_frames);   
    std::cout << "--------------- E11_strain ------------------" << std::endl;
-   float *e11_strain = new float[NP];
    for (i=0; i<NP; i++) {
        from >> e11_strain[i]; 
        if (verbose)
        std::cout <<  e11_strain[i] <<  std::endl;
    }  
-   
+//followed by their E11 strain, an array of NP elements,
+   dcmImageName = textFileName + frame + "_E11_strain.dcm";
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);
+}// end for   nbr_of_frames   
+delete []e11_strain;
+
+serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
+float *e22_strain = new float[NP];
+for (int nbr_of_frames=0; nbr_of_frames < NCF;  nbr_of_frames++)
+{
+sprintf(frame, "_%d", nbr_of_frames); 
    std::cout << "--------------- E22_strain ------------------" << std::endl;
-   float *e22_strain = new float[NP];
    for (i=0; i<NP; i++) {
        from >> e22_strain[i]; 
        if (verbose)
        std::cout <<  e22_strain[i] <<  std::endl;
-   }    
+   }   
+//followed by their E22 strain, an array of NP elements,
+   dcmImageName = textFileName + frame + "_E22_strain.dcm";
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, 1, studyUID, serieUID);   
+} // end for   nbr_of_frames
+delete [] e22_strain;
+} // end of single frame
+
+
+else                      // generate Multiframe files
+{
 
-   std::string dcmImageName;    
 
+serieUID =  GDCM_NAME_SPACE::Util::CreateUniqueUID();
+float *ecc_strain = new float[NP*NCF];
+   std::cout << "--------------- Ecc_strain ------------------" << std::endl;
+   for (i=0; i<NP*NCF; i++) {
+       from >> ecc_strain[i];
+       if (verbose)
+       std::cout <<  ecc_strain[i] <<  std::endl;
+   }
 //followed by their Ecc strain, an array of NP elements,
    dcmImageName = textFileName + "_Ecc_strain.dcm";
-   MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName);
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(ecc_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);      
+delete []ecc_strain;
 
-//followed by their  Err strain, an array of NP elements,
+
+
+float *err_strain = new float[NP*NCF];
+   std::cout << "--------------- Err_strain ------------------" << std::endl;
+   for (i=0; i<NP*NCF; i++) {
+       from >> err_strain[i];
+       if (verbose)
+       std::cout <<  err_strain[i] <<  std::endl;
+   }
+//followed by their Ecc strain, an array of NP elements,
    dcmImageName = textFileName + "_Err_strain.dcm";
-   MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName);
-   
-//followed by their E11 strain, an array of NP elements,
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(err_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);      
+delete []err_strain;
+
+
+
+float *e11_strain = new float[NP*NCF];
+   std::cout << "--------------- E11_strain ------------------" << std::endl;
+   for (i=0; i<NP*NCF; i++) {
+       from >> e11_strain[i];
+       if (verbose)
+       std::cout <<  e11_strain[i] <<  std::endl;
+   }
+//followed by their Ecc strain, an array of NP elements,
    dcmImageName = textFileName + "_E11_strain.dcm";
-   MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName);
-   
-//followed by their E22 strain, an array of NP elements,
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(e11_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);      
+delete []e11_strain;
+
+
+
+float *e22_strain = new float[NP*NCF];
+   std::cout << "--------------- E22_strain ------------------" << std::endl;
+   for (i=0; i<NP*NCF; i++) {
+       from >> e22_strain[i];
+       if (verbose)
+       std::cout <<  e22_strain[i] <<  std::endl;
+   }
+//followed by their Ecc strain, an array of NP elements,
    dcmImageName = textFileName + "_E22_strain.dcm";
-   MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName);   
-      
+   std::cout << "Try to make image :[" << dcmImageName << "]" << std::endl;
+   MakeDicomImage(e22_strain, X, Y, Z, NP, dcmImageName, patientname, NCF, studyUID, serieUID);      
+delete []e22_strain;
+
+}    // end of Multiframe    
 }
 
 
 // =====================================================================================================================
     
 
-void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName)
+void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::string dcmImageName, const char * patientName, int nbFrames, std::string studyUID, std::string serieUID)
 {
+
+std::cout << "=============================================================================="
+          << "enter MakeDicomImage [" << dcmImageName << "] [" << patientName << "]" << std::endl;
    float minX = 99999., minY = 99999., minZ = 99999.;
    float maxX = 0., maxY = 0., maxZ = 0.;
    int i;
@@ -618,36 +733,33 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
    std::cout << "Max X,Y,Z " << maxX << " " << maxY << " " << maxZ <<  std::endl;
    std::cout << "Size X,Y,Z " << maxX-minX << " " << maxY-minY << " " << maxZ-minZ <<  std::endl;      
 
-//   uint16_t *img = new uint16_t[int(maxX+0.5)*int(maxY+0.5)];
-   uint16_t *img = new uint16_t[int(maxX*4.)*int(maxY*4.)];
-   
-   // Set whole image to 0 
-   for(int i3=0;i3<int(maxX*4.)*int(maxY*4.);i3++)
-//   for(int i3=0;i3<int(maxX+0.5)*int(maxY+0.5);i3++)
-      img[i3] = 0; 
+   int lgrFrame = int(maxX*4.)*int(maxY*4.);
+   uint16_t *img = new uint16_t[lgrFrame*nbFrames ];
 
-   for(int i2=0; i2<NP; i2++) {
-   
+   // Set whole image to 0 
+   for(int i3=0; i3<lgrFrame*nbFrames; i3++)
+      img[i3] = 0;
+       
+for(int i4=0; i4<nbFrames; i4++)
+   for(int i2=0; i2<NP; i2++) {   
       int ordX = int(X[i2]*4.-30);
       int ordY = int(maxY*4.) - int(Y[i2]*4.)+30;      
-//   img[ /*int(maxX) -*/ int(X[i2]+0.5-1)   +  (int(maxY+0.5) - int(Y[i2]+0.5))   * int(maxX+0.5) ] = int(tabVal[i2]*100);
-   
-//   img[ /*int(maxX) -*/ int(X[i2]*4.-30)   +  (int(maxY*4.) - int(Y[i2]*4.)+30)   * int(maxX*4.) ] = int(tabVal[i2]*100);
-   img[ /*int(maxX) -*/ ordX   +  ordY   * int(maxX*4.) ] = int(tabVal[i2]*100);
+      img[ lgrFrame*i4 + ordX   +  ordY   * int(maxX*4.) ] = int(tabVal[i2 + NP*i4]*100);
 
       // Try to round up, just to see.   
-       for(int iii=ordY-3; iii<ordY+4; iii++) for(int jjj=ordX-3; jjj<ordX+4; jjj++) 
-          img[  jjj  +  iii   * int(maxX*4.) ] = int(tabVal[i2]*100);         
-      std::cout << int(X[i2]*4.) << " " << int(Y[i2]*4.) << " = " << int(tabVal[i2]*100) << std::endl;      
-   }       
-  
+       for(int iii=ordY-3; iii<ordY+4; iii++) 
+          for(int jjj=ordX-3; jjj<ordX+4; jjj++) 
+             img[  lgrFrame*i4 + jjj  +  iii   * int(maxX*4.) ] = int(tabVal[i2 + NP*i4]*100);            
+   }
+
+ std::cout << "===========sortie recup points" << std::endl; 
  // GDCM_NAME_SPACE::Debug::DebugOn();
   
    std::ostringstream str;
-    
+
    GDCM_NAME_SPACE::File *file;
    file = GDCM_NAME_SPACE::File::New();       
-              
+      
   // Set the image size
    str.str(""); 
    str << (int)(maxX*4.);
@@ -655,7 +767,7 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
    str.str("");
    str << (int)(maxY*4.);
    file->InsertEntryString(str.str(),0x0028,0x0010,"US"); // Rows
-   
+
   // Set the pixel type
   //      16; //8, 16, 32
    file->InsertEntryString("16",0x0028,0x0100,"US"); // Bits Allocated
@@ -669,6 +781,30 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
   // Set the samples per pixel // 1:Grey level, 3:RGB
    file->InsertEntryString("1",0x0028,0x0002, "US"); // Samples per Pixel
 
+   if (nbFrames != 1)
+   {
+      str.str("");
+      str << nbFrames;
+      file->InsertEntryString(str.str(),0x0028,0x0008,"IS"); // Number of Frames  
+   }
+  
+   if (strlen(patientName) != 0)
+      file->InsertEntryString(patientName,0x0010,0x0010, "PN"); // Patient's Name
+
+   file->InsertEntryString(studyUID, 0x0020, 0x000d, "UI");
+   file->InsertEntryString(serieUID, 0x0020, 0x000e, "UI");
+     
+   int pos = 0;  // get the usefull part of the name
+/*  
+   for(i=0, pos=0; pos<dcmImageName.size()-4; pos++, i++) {
+     if( dcmImageName[i]=='.' &&dcmImageName[i+1]=='t' && dcmImageName[i+2]=='x' && dcmImageName[i+3]=='t'  
+       && dcmImageName[i+3]=='_') {
+       pos+=5;
+       break;
+     }
+   }
+*/  
+   file->InsertEntryString(&(dcmImageName.c_str()[pos]),0x0008,0x103e, "LO");  // Series Description   
 /*
   // Set Rescale Intercept
         str.str("");
@@ -685,7 +821,8 @@ void MakeDicomImage(float *tabVal, float *X, float *Y, float *Z, int NP, std::st
    fileH = GDCM_NAME_SPACE::FileHelper::New(file);
    // cast is just to avoid warnings (*no* conversion)
    //fileH->SetImageData((uint8_t *)img,int(maxX*maxY)*sizeof(uint16_t)); // troubles when maxX, mayY are *actually* float!
-   fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*sizeof(uint16_t));
+   
+   fileH->SetImageData((uint8_t *)img,int(maxX*4.)*int(maxY*4.)*nbFrames*sizeof(uint16_t));
    fileH->SetWriteModeToRaw(); 
    fileH->SetWriteTypeToDcmExplVR();