]> Creatis software - STMS.git/blobdiff - Lib/PrePostProcessing/itkSTMS_TemporalSetToImageSequence.txx
Adding CSV file generation
[STMS.git] / Lib / PrePostProcessing / itkSTMS_TemporalSetToImageSequence.txx
index 698e3ae4ec33359625560ecfcb4f1c8db75aec16..f5a00e9c08706091ca710fac3b5cf62e6a3c8c0d 100755 (executable)
@@ -127,7 +127,7 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
             "_Class_X-"+std::to_string((unsigned int)stmsParameters->spScales[0])+
             "_Y-"+std::to_string((unsigned int)stmsParameters->spScales[1])+
             "_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+
-            "_R-"+std::to_string(stmsParameters->rScale)+"_"+
+            "_R-"+std::to_string(stmsParameters->rScale)+
             expDescription->outputImageExtension;
 
     ClassWriterPointer classWriter
@@ -135,8 +135,8 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
     classWriter->SetFileName( classPath );
 
     // Filetered image sequence and class image saving
-    for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i ){
-
+    for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
+    {
         char buffer[6];
         int n;
 
@@ -194,6 +194,36 @@ itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
     }
 }
 
+
+template < class ImageType, class ClassImageType>
+void
+itkSTMS_TemporalSetToImageSequence< ImageType, ClassImageType >
+::GenerateCSVFile()
+{
+    std::string CSVFilename = expDescription->experimentPath+expDescription->outputFolder+
+            expDescription->outputCommonRoot+
+            "_X-"+std::to_string((unsigned int)stmsParameters->spScales[0])+
+            "_Y-"+std::to_string((unsigned int)stmsParameters->spScales[1])+
+            "_Z-"+std::to_string((unsigned int)stmsParameters->spScales[2])+
+            "_R-"+std::to_string(stmsParameters->rScale)+".csv";
+
+    std::cout << "Writing CSV File (classID, nb of pixels, values of time serie), : " << CSVFilename << std::endl;
+    std::ofstream ofs;
+    ofs.open (CSVFilename.c_str(), std::ofstream::out | std::ofstream::trunc);
+
+    for(unsigned int j=0 ; j<rangeSet->size() ; ++j)
+    {
+        ofs << j+1 <<", " << std::count (classSet->begin(), classSet->end(), j+1);
+        for( unsigned int i=1 ; i<=stmsParameters->numTimePoints - stmsParameters->startTimePoint + 1; ++i )
+           ofs << ", " << rangeSet->at(j)[i-1]*stmsParameters->rScale ;
+        ofs << std::endl;
+    }
+
+    ofs.close();
+
+}
+
+
 } // end of namespace itkSTMS
 
 #endif