]> Creatis software - clitk.git/commitdiff
Added more options to clitkImageUncertainty, default should be identical
authorSimon Rit <simon.rit@creatis.insa-lyon.fr>
Wed, 8 Oct 2014 11:54:24 +0000 (13:54 +0200)
committerSimon Rit <simon.rit@creatis.insa-lyon.fr>
Wed, 8 Oct 2014 11:54:24 +0000 (13:54 +0200)
tools/clitkImageUncertainty.cxx
tools/clitkImageUncertainty.ggo

index 63b1f12173a161647d64043f6fa986fe5d1248bc..a8e76de080c278e6d87cb095a1f2ee03160a808f 100644 (file)
@@ -53,9 +53,9 @@ int main(int argc, char * argv[]) {
 
   // Read images
   ImageType::Pointer input =
-       clitk::readImage<ImageType>(args_info.input_arg, args_info.verbose_flag);
+    clitk::readImage<ImageType>(args_info.input_arg, args_info.verbose_flag);
   ImageType::Pointer inputSquared =
-       clitk::readImage<ImageType>(args_info.inputSquared_arg, args_info.verbose_flag);
+    clitk::readImage<ImageType>(args_info.inputSquared_arg, args_info.verbose_flag);
 
   // Create Output
   ImageType::Pointer output = ImageType::New();
@@ -75,39 +75,36 @@ int main(int argc, char * argv[]) {
 
   int NumberOfEvents = args_info.NumberOfEvents_arg;
   while ( !pi.IsAtEnd() ) {
-       double squared = pii.Get();
-       double mean = pi.Get();
-       double uncert = sqrt((NumberOfEvents*squared - mean*mean) / ((NumberOfEvents-1)*(mean*mean)));
-       if (!IsNormal(uncert)) uncert = 1.;
-       po.Set(uncert);
-       ++pi;
-       ++pii;
-       ++po;
+    double squared = pii.Get();
+    double mean = pi.Get();
+    double uncert = sqrt((NumberOfEvents*squared - mean*mean) / (NumberOfEvents-1));
+    if(!args_info.absolute_flag)
+      uncert /= std::abs(mean);
+    if (!IsNormal(uncert)) uncert = args_info.default_arg;
+    po.Set(uncert);
+    ++pi;
+    ++pii;
+    ++po;
   }
-//       *po = sqrt( (NumberOfEvents*squared - mean*mean) /
-// ((NumberOfEvents-1)*(mean*mean)) );
-//       ++po;
-
-
 
   // Write output image
   // DD(clitk::GetExtension(args_info.output_arg));
   if (clitk::GetExtension(args_info.output_arg) != "txt") {
-       clitk::writeImage<ImageType>(output, args_info.output_arg, args_info.verbose_flag);
+    clitk::writeImage<ImageType>(output, args_info.output_arg, args_info.verbose_flag);
   }
   else {
-       std::ofstream os;
-       clitk::openFileForWriting(os, args_info.output_arg);
-       typedef itk::ImageRegionConstIterator<ImageType> IteratorType;
-       IteratorType pi(output, output->GetLargestPossibleRegion());
-       pi.GoToBegin();
-       os << "# Image size = " << output->GetLargestPossibleRegion().GetSize() << std::endl;
-       os << "# Image spacing = " << output->GetSpacing() << std::endl;
-       os << "# Number of events = " << NumberOfEvents << std::endl;
-       while (!pi.IsAtEnd()) {
-         os << pi.Get() << std::endl;
-         ++pi;
-       }
+    std::ofstream os;
+    clitk::openFileForWriting(os, args_info.output_arg);
+    typedef itk::ImageRegionConstIterator<ImageType> IteratorType;
+    IteratorType pi(output, output->GetLargestPossibleRegion());
+    pi.GoToBegin();
+    os << "# Image size = " << output->GetLargestPossibleRegion().GetSize() << std::endl;
+    os << "# Image spacing = " << output->GetSpacing() << std::endl;
+    os << "# Number of events = " << NumberOfEvents << std::endl;
+    while (!pi.IsAtEnd()) {
+      os << pi.Get() << std::endl;
+      ++pi;
+    }
   }
 }
 
index af5dfad275afe067dba4d4bafa4b5d1e7b12ea16..00b105a9318e865f7e042389df3920117c1c9317 100644 (file)
@@ -1,10 +1,12 @@
 # file clitkImageRescaleIntensity.ggo
 package "clitk"
-version "Rescale intensity in the image"
+version "Compute the uncertainty of simulation outputs using Chetty's history-by-history's method"
 
-option "config"                        -       "Config file"                                   string  no
-option "input"                 i       "Input image filename"                  string  yes
-option "inputSquared"  s       "Input squared image filename"  string  yes
-option "output"                        o       "Output image filename"                 string  yes
-option "NumberOfEvents" n   "Number of events"                         int     yes
-option "verbose"               v   "Verbose"                                           flag    off
+option "config"         - "Config file"                      string  no
+option "input"          i "Input image filename"             string  yes
+option "inputSquared"   s "Input squared image filename"     string  yes
+option "output"         o "Output image filename"            string  yes
+option "NumberOfEvents" n "Number of events"                 int     yes
+option "verbose"        v "Verbose"                          flag    off
+option "absolute"       a "Absolute instead of the relative" flag    off
+option "default"        d "Default when input is 0."         double  no   default="1."