Bsoft  2.1.0
Bernard's software package
dimgstats.cpp
Go to the documentation of this file.
1 
9 #include "Bstring.h"
10 #include "rwimg.h"
11 #include "img_combine.h"
12 #include "math_util.h"
13 #include "utilities.h"
14 #include "options.h"
15 #include "timer.h"
16 #include "Vector3.h"
17 
18 // Declaration of global variables
19 extern int verbose; // Level of output to the screen
20 
21 // Function prototypes
22 int img_fom_sqrt(Bimage* p);
23 Bimage* img_students_t_test(int n, Bimage* p, vector<double>& weight);
24 Bimage* img_students_t_test_equal(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight);
25 Bimage* img_students_t_test_unequal(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight);
26 Bimage* img_f_test(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight);
27 
28 // Usage assistence
29 const char* use[] = {
30 " ",
31 "Usage: dimgstats [options] input.images",
32 "---------------------------------------",
33 "Calculates statistical measures within a set of images or between sets of images.",
34 "Corresponding pixels are compared--i.e. pixel m in image 1 is compared to pixel m",
35 "in image 2.",
36 " ",
37 "Definitions: ",
38 " Variance var = Sum[ (rho - avg_rho)(rho - avg_rho) ] / (n - 1)",
39 " numerator portion Vn = Sum[ (rho - avg_rho)(rho - avg_rho) ]",
40 " Standard deviation std = sqrt( var )",
41 " Student's t-test (t) SD = sqrt[(Vn1 + Vn2)(1/m + 1/n) / (m + n - 2) ]",
42 " approx. equal var t = ( avg1 - avg2 ) / SD",
43 " unequal var t = ( avg1 - avg2 ) / sqrt[ var1/m + var2/n ]",
44 " F-test F = var1 / var2",
45 "avg = average (mean), m = number of data points in set 1, n = number in set 2,",
46 "rho = value of a given pixel at a given (x,y,z) coordinate",
47 "SD = standard error of the difference of the means, sqrt = square root",
48 "Sum = summation of.",
49 " ",
50 "See Milligan and Flicker (1987) J. Cell Biol. 105:29-39 for a reference",
51 "to the use of the Student's t-test in 3D electron microscopy.",
52 " ",
53 "Any number of input images may be given and may include the wild card \"*\".",
54 "(However, VMS does not support Unix style usage of wild cards)",
55 "All images are converted to floating point.",
56 " ",
57 "Actions:",
58 "-Ttest equal Do a Student's t-test to compare two sets (equal/unequal).",
59 "-Ftest Do a F-test to compare two sets.",
60 "-average Compute an average image for each set.",
61 "-stdev Compute a standard deviation image for each set.",
62 "-variance Compute a variance image for each set.",
63 "-significance Compute significance-level (probability) image.",
64 "-rescale -0.1,5.2 Rescale input images to average, standard deviation.",
65 " ",
66 "Parameters:",
67 "-datatype u Force writing of a new data type",
68 "-sampling 1.5,1.5,1.5 Sampling (A/pixel; a single value can be given).",
69 "-sets 10,12 Number of input files in each set (default = single set).",
70 "-verbose 7 Verbosity of output",
71 "-weights 0.1,0.3,0.9 Weights for input files (default 1 for every file)",
72 " ",
73 "Output:",
74 "-output name.img base name for output image(s), suffix added based on action",
75 " ",
76 NULL
77 };
78 
79 
80 
81 int main(int argc, char **argv)
82 {
83  // Initialize variables
84  Bstring filebase; // Output file base name
85  Bstring* file_list = NULL; // List of file names for first and second sets
86  Bstring* file_list2 = NULL; // List of file names for second set
87  Bstring outfile; // Name of output file
88  Bstring weight_string; // input weights
89 
90  int avgflag(0); // Flag to output average image
91  int avgvar(0); // Flag indicating that average and variance need to be calculated
92  int fflag(0); // Flag for F-test
93  int nfiles; // Number of files entered
94  int set1(0), set2(0); // Number of images in sets 1 and 2, for Student's t-test image
95  int setweight(0); // Weight flag, default weights are 1
96  int signif(0); // Flag to calculate significance-level image
97  int stdev(0); // Flag to calculate and output standard deviation
98  int sttflag[2] = {0,0}; // Flags for Student's t-test equal or unequal variance
99  int variance(0); // Flag to output variance
100 
101  double nuavg(0), nustd(0); // Average and standard deviation for rescaling
102  vector<double> weight, weight2; // Weights for each image file (default = 1)
103 
104  DataType nudatatype(Unknown_Type); // Conversion to new data type
105  Bimage *p1 = NULL, *p2 = NULL; // Average images for sets 1 and 2
106  long i; // Index
107  Vector3<double> sam; // Units for the three axes (A/pixel)
108 
109 
110  // Command-line options
111  int optind;
112  Boption* option = get_option_list(use, argc, argv, optind);
113  Boption* curropt;
114  for ( curropt = option; curropt; curropt = curropt->next ) {
115  if ( curropt->tag == "Ttest" ) {
116  avgvar = 1;
117  if ( curropt->value[0] == 'e' ) sttflag[0] = 1;
118  if ( curropt->value[0] == 'u' ) sttflag[1] = 1;
119  }
120  if ( curropt->tag == "Ftest" ) {
121  fflag = 1; avgvar = 1;
122  }
123  if ( curropt->tag == "average" ) {
124  avgflag = 1; avgvar = 1;
125  }
126  if ( curropt->tag == "stdev" ) {
127  stdev = 1; avgvar = 1;
128  }
129  if ( curropt->tag == "variance" ) {
130  variance = 1; avgvar = 1;
131  }
132  if ( curropt->tag == "significance" )
133  signif = 1;
134  if ( curropt->tag == "rescale" )
135  if ( curropt->values(nuavg, nustd) < 2 )
136  cerr << "-rescale: Both average and standard deviation must be specified" << endl;
137  if ( curropt->tag == "datatype" )
138  nudatatype = curropt->datatype();
139  if ( curropt->tag == "sampling" )
140  sam = curropt->scale();
141  if ( curropt->tag == "sets" ) {
142  if ( curropt->values(set1, set2) < 2 )
143  cerr << "-sets: Two integers must be specified" << endl;
144  else if ( set1<=0 || set2<=0 )
145  cerr << "-sets: Each set must have at least one member." << endl;
146  }
147  if ( curropt->tag == "weights" ) {
148  weight_string = curropt->value;
149  if ( weight_string.length() < 1 )
150  cerr << "-weights: Weights for all files must be specified" << endl;
151  else
152  setweight = 1;
153  }
154  if ( curropt->tag == "output" )
155  filebase = curropt->filename();
156  }
157  option_kill(option);
158 
159  double ti = timer_start();
160 
161  if ( optind >= argc ) {
162  cerr << "No input files!" << endl;
163  bexit(-1);
164  }
165  if ( (sttflag[0] || sttflag[1] || fflag) && (set1 == 0) ) {
166  cerr << "You must designate two image sets (option \"-sets\") for the t-test or F-test!" << endl;
167  bexit(-1);
168  }
169 
170 
171  // Set up image file names
172  nfiles = 0;
173  while ( optind < argc ) {
174  if ( !set1 || ( set1 && nfiles < set1 ) )
175  string_add(&file_list, argv[optind++]);
176  else
177  string_add(&file_list2, argv[optind++]);
178  nfiles++;
179  }
180 
181  if ( set1 < 1 && set2 < 1 ) // If set option unused, assume only one set
182  set1 = nfiles;
183  else // If two sets, check that number of files and numbers for sets are in agreement
184  if ( (set1+set2) != nfiles ) {
185  cerr << "The number of files (" << nfiles << ") does not agree with the numbers designated for sets 1 ("
186  << set1 << ") and 2 (" << set2 << ")." << endl;
187  bexit(-1);
188  }
189 
190  // Set weights for each input file, default is 1.0
191  i = 0;
192  if ( setweight ) {
193  weight = weight_string.split_into_doubles(",");
194  if ( weight.size() < nfiles ) {
195  cerr << "Error: The number of weights must be equal to the number of input files" << endl;
196  bexit(-1);
197  }
198  } else {
199  for ( i=0; i<nfiles; i++ ) weight.push_back(1.0);
200  }
201 
202  if ( set2 )
203  for ( i=set1; i<nfiles; i++ ) weight2.push_back(weight[i]);
204 
205  // Compute average and variance images
206  if ( avgvar ) {
207  p1 = img_add_weighed(file_list, weight, nuavg, nustd, 3);
208  if ( set2 )
209  p2 = img_add_weighed(file_list2, weight2, nuavg, nustd, 3);
210 
211  if ( filebase.length() ) { // write image(s) to file
212  if ( sam.volume() > 0 ) {
213  p1->sampling(sam);
214  p2->sampling(sam);
215  }
216  p1->change_type(nudatatype);
217  if ( p2 ) p2->change_type(nudatatype);
218  if ( avgflag ) {
219  if ( set2 )
220  outfile = filebase.pre_rev('.') + "_avg1." + filebase.post_rev('.');
221  else
222  outfile = filebase.pre_rev('.') + "_avg." + filebase.post_rev('.');
223  write_img(outfile, p1, 0);
224  if ( p2 ) {
225  outfile = filebase.pre_rev('.') + "_avg2." + filebase.post_rev('.');
226  write_img(outfile, p2, 0);
227  }
228  }
229  if ( variance ) {
230  if ( set2 )
231  outfile = filebase.pre_rev('.') + "_var1." + filebase.post_rev('.');
232  else
233  outfile = filebase.pre_rev('.') + "_var." + filebase.post_rev('.');
234  write_img(outfile, p1->next, 0);
235  if ( p2 ) {
236  outfile = filebase.pre_rev('.') + "_var2." + filebase.post_rev('.');
237  write_img(outfile, p2->next, 0);
238  }
239  }
240  }
241  }
242 
243  string_kill(file_list);
244 
245  // F-test image
246  if ( fflag ) {
247 
248  Bimage* pf = img_f_test(set1, set2, p1, p2, weight);
249 
250  if ( filebase.length() ) {
251  outfile = filebase.pre_rev('.') + "_ftest." + filebase.post_rev('.');
252  if ( sam.volume() > 0 ) pf->sampling(sam);
253  pf->change_type(nudatatype);
254  write_img(outfile, pf, 0);
255  if ( signif ) {
256  outfile = filebase.pre_rev('.') + "_ftest_sig." + filebase.post_rev('.');
257  write_img(outfile, pf->next, 0);
258  }
259  }
260 
261  delete pf;
262  }
263 
264  // Student's t-test image, equal or unequal variance
265  Bimage* pt = NULL;
266  for ( i=0; i<2; i++ ) if ( sttflag[i] ) {
267  if ( i == 0 ) // equal variance
268  pt = img_students_t_test_equal(set1, set2, p1, p2, weight);
269  else if ( i == 1 ) // unequal variance
270  pt = img_students_t_test_unequal(set1, set2, p1, p2, weight);
271  if ( filebase.length() ) {
272  if ( i == 0 ) outfile = filebase.pre_rev('.') + "_stte." + filebase.post_rev('.');
273  if ( i == 1 ) outfile = filebase.pre_rev('.') + "_sttu." + filebase.post_rev('.');
274  if ( sam.volume() > 0 ) pt->sampling(sam);
275  pt->change_type(nudatatype);
276  write_img(outfile, pt, 0);
277  if ( signif ) {
278  if ( i == 0 ) outfile = filebase.pre_rev('.') + "_stte_sig." + filebase.post_rev('.');
279  if ( i == 1 ) outfile = filebase.pre_rev('.') + "_sttu_sig." + filebase.post_rev('.');
280  write_img(outfile, pt->next, 0);
281  }
282  }
283  delete pt;
284  }
285 
286  // Compute standard deviation image from variance
287  if ( stdev ) {
288  img_fom_sqrt(p1);
289  if ( p2 ) img_fom_sqrt(p2);
290  if ( filebase.length() ) {
291  if ( set2 )
292  outfile = filebase.pre_rev('.') + "_std1." + filebase.post_rev('.');
293  else
294  outfile = filebase.pre_rev('.') + "_std." + filebase.post_rev('.');
295  write_img(outfile, p1->next, 0);
296  if ( p2 ) {
297  outfile = filebase.pre_rev('.') + "_std2." + filebase.post_rev('.');
298  write_img(outfile, p2->next, 0);
299  }
300  }
301  }
302 
303  delete p1;
304  delete p2;
305 
306  if ( verbose & VERB_TIME )
307  timer_report(ti);
308 
309  bexit(0);
310 }
311 
312 /************************************************************************
313 @brief Calculates the square root of the FOM portion of an image.
314 @param *p image.
315 @return Bimage* square root of the FOM of the input image.
316 
317  The new data is calculated as:
318  new_datum = sqrt(datum)
319  FOM min. must be 0 or greater.
320 
321 **/
323 {
324  if ( !p->next ) {
325  cerr << "Error: No FOM block found in " << p->file_name() << endl;
326  return -1;
327  }
328 
329  long i, datasize = (long) p->size().volume()*p->images();
330  float* fom = (float *) p->next->data_pointer();
331 
332  for ( i=0; i<datasize; i++ ) {
333  if ( fom[i] < 0 ) {
334  cerr << "Cannot take the square root of the FOM of this image because a value is less than zero." << endl;
335  return -1;
336  }
337  else
338  fom[i] = sqrt(fom[i]);
339  }
340 
341  return 0;
342 }
343 
365 Bimage* img_students_t_test(int n, Bimage* p, vector<double>& weight)
366 {
367  Bimage* pt = new Bimage(Float, TSimple, p->size(), 1);
368  pt->origin(p->image->origin());
369  pt->sampling(p->sampling(0));
370 
371  float* var = (float *) p->next->data_pointer();
372 
373  pt->next = new Bimage(Float, TSimple, pt->size(), 1);
374  float* siglev = (float *) pt->next->data_pointer();
375 
376  long i, datasize = p->data_size();
377  double ws(0), d;
378 
379  for ( i=0; i<n; i++ ) ws += weight[i];
380 
381  double dof = ws*(1 - 1.0L/n);
382  double hdof = 0.5*dof;
383  double avg_var = 0;
384 
385  for ( i=0; i<datasize; i++ ) avg_var += var[i];
386  avg_var /= datasize;
387 
388  if ( verbose ) {
389  cout << "Student's t test:" << endl;
390  cout << "Number: " << n << endl;
391  cout << "Average variance: " << avg_var << endl;
392  cout << "Degrees of freedom: " << dof << endl << endl;
393  }
394 
395  avg_var *= avg_var;
396 
397  for ( i=0; i<datasize; i++ ) {
398  d = var[i]/n;
399  if ( d < avg_var ) d = avg_var;
400  d = sqrt(d);
401  pt->set(i, (*p)[i]/d);
402  siglev[i] = betai(hdof, 0.5, dof/(dof + (*pt)[i]*(*pt)[i]));
403  }
404 
405  return pt;
406 }
407 
433 Bimage* img_students_t_test_equal(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight)
434 {
435  // Set arrays and image parameters
436  Bimage* pt = new Bimage(Float, TSimple, p1->size(), 1);
437  pt->origin(p1->image->origin());
438  pt->sampling(p1->sampling(0));
439  pt->next = new Bimage(Float, TSimple, pt->size(), 1);
440 
441  long i, j, datasize = p1->sizeX()*p1->sizeY()*p1->sizeZ()*p1->images();
442 
443  float* var1 = (float *) p1->next->data_pointer(); // pointers to variance data
444  float* var2 = (float *) p2->next->data_pointer();
445  float* sig = (float *) pt->next->data_pointer();
446 
447  // Compute Student's t-test
448  if ( verbose ) {
449  cout << endl << "Student's t-test, assuming same variance in sets 1 and 2" << endl;
450  cout << "Set 1 contains " << set1 << " images" << endl;
451  cout << "Set 2 contains " << set2 << " images" << endl;
452  }
453 
454  double ws1, ws2;
455  for ( i=0, j=0, ws1=0; i<set1; i++, j++ ) ws1 += weight[j];
456  for ( i=0, ws2=0; i<set2; i++, j++ ) ws2 += weight[j];
457 
458  double inv_weight_sum = (1.0L / ws1) + (1.0L / ws2);
459 
460  double dof1 = ws1*(1.0L - 1.0L/set1); // degrees of freedom
461  double dof2 = ws2*(1.0L - 1.0L/set2);
462  double dof = dof1 + dof2;
463  double hdof = 0.5*dof;
464  double SD;
465  double Vn1, Vn2;
466 
467  long zero_count1 = 0, zero_count2 = 0; // Counts numbers of zero values in t-test
468  for ( i=0; i<datasize; i++ ) {
469  Vn1 = var1[i] * dof1; // Compute numerator of variance from the variance
470  Vn2 = var2[i] * dof2;
471  SD = sqrt( ( (Vn1 + Vn2) / dof ) * inv_weight_sum ); // Standard error of the difference of the means
472  if ( SD > 0 ) { // test for zero in denominator
473  pt->set(i, ( (*p1)[i] - (*p2)[i] ) / SD); // t-test value
474  if ( (*pt)[i] == 0 ) zero_count2++;
475  sig[i] = betai(hdof, 0.5L, dof/(dof + (*pt)[i]*(*pt)[i]) ); // significance level
476  } else {
477  pt->set(i, 0);
478  sig[i] = 1;
479  zero_count1++;
480  }
481  }
482 
483  if ( verbose & VERB_FULL ) {
484  cout << zero_count1 << " pixels had a zero value for the standard error of the differences of the means, and t was set to zero." << endl;
485  cout << zero_count2 << " pixels had standard deviation > 0 and t = 0." << endl;
486  cout << datasize << " = total pixels in image" << endl;
487  }
488 
489  return pt;
490 }
491 
492 
493 
515 Bimage* img_students_t_test_unequal(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight)
516 {
517  // Set arrays and image parameters
518  Bimage* pt = new Bimage(Float, TSimple, p1->sizeX(), p1->sizeY(), p1->sizeZ(), 1);
519  pt->origin(p1->image->origin());
520  pt->sampling(p1->sampling(0));
521  pt->next = new Bimage(Float, TSimple, pt->size(), 1);
522 
523  long i, j, datasize = p1->sizeX()*p1->sizeY()*p1->sizeZ()*p1->images();
524 
525  float* var1 = (float *) p1->next->data_pointer(); // pointers to variance data
526  float* var2 = (float *) p2->next->data_pointer();
527  float* sig = (float *) pt->next->data_pointer(); // initialize figure-of-merit subimage structure, for significance level
528 
529  // Compute Student's t-test
530  if ( verbose ) {
531  cout << endl << "Student's t-test, assuming unequal variance in sets 1 and 2" << endl;
532  cout << "Set 1 contains " << set1 << " images" << endl;
533  cout << "Set 2 contains " << set2 << " images" << endl;
534  }
535 
536  double ws1, ws2;
537  for ( i=0, j=0, ws1=0; i<set1; i++, j++ ) ws1 += weight[j];
538  for ( i=0, ws2=0; i<set2; i++, j++ ) ws2 += weight[j];
539 
540  double dof1 = ws1*(1.0L - 1.0L/set1); // degrees of freedom
541  double dof2 = ws2*(1.0L - 1.0L/set2);
542  double dof;
543  double Vn1, Vn2;
544 
545  long zero_count1 = 0, zero_count2 = 0; // Counts numbers of zero values in t-test
546  for ( i=0; i<datasize; i++ ) {
547  if ( var1[i] > 0 || var2[i] > 0 ) { // test for zero in denominator
548  Vn1 = var1[i]/ws1;
549  Vn2 = var2[i]/ws2;
550  pt->set(i, ( (*p1)[i] - (*p2)[i] ) / sqrt(Vn1 + Vn2));
551  if ( (*pt)[i] == 0 ) zero_count2++;
552  dof = (Vn1 + Vn2)*(Vn1 + Vn2) / (Vn1*Vn1/dof1 + Vn2*Vn2/dof2);
553  sig[i] = betai(0.5L*dof, 0.5L, dof/(dof + (*pt)[i]*(*pt)[i]) ); // significance level
554  } else {
555  pt->set(i, 0);
556  sig[i] = 1;
557  zero_count1++;
558  }
559  }
560 
561  if ( verbose & VERB_FULL ) {
562  cout << zero_count1 << " pixels had zero variance and t was set to zero." << endl;
563  cout << zero_count2 << " pixels had variance not equal to 0 and t = 0." << endl;
564  cout << datasize << " = total pixels in image" << endl;
565  }
566 
567  return pt;
568 }
569 
589 Bimage* img_f_test(int set1, int set2, Bimage* p1, Bimage* p2, vector<double>& weight)
590 {
591  // Set image parameters and arrays
592  Bimage* pf = new Bimage(Float, TSimple, p1->size(), 1);
593  pf->origin(p1->image->origin());
594  pf->sampling(p1->sampling(0));
595  pf->next = new Bimage(Float, TSimple, pf->size(), 1);
596 
597  long i, j, datasize = p1->sizeX()*p1->sizeY()*p1->sizeZ()*p1->images();
598 
599  float* var1 = (float *) p1->next->data_pointer(); // pointers to variance data
600  float* var2 = (float *) p2->next->data_pointer();
601  float* sig = (float *) pf->next->data_pointer();
602 
603  // Compute F-test
604  if ( verbose ) {
605  cout << endl << "F-test" << endl;
606  cout << "Set 1 contains " << set1 << " images" << endl;
607  cout << "Set 2 contains " << set2 << " images" << endl;
608  }
609 
610  double ws1, ws2;
611  for ( i=0, j=0, ws1=0; i<set1; i++, j++ ) ws1 += weight[j];
612  for ( i=0, ws2=0; i<set2; i++, j++ ) ws2 += weight[j];
613 
614  double dof1 = ws1*(1.0L - 1.0L/set1);
615  double dof2 = ws2*(1.0L - 1.0L/set2);
616  double df1, df2; // degrees of freedom, sets 1 and 2
617 
618  for ( i=0; i<datasize; i++ ) {
619  if ( var1[i] < SMALLFLOAT || var2[i] < SMALLFLOAT ) {
620  pf->set(i, 0);
621  sig[i] = 1;
622  j++;
623  } else {
624  if ( var1[i] > var2[i] ) { // make f the ratio of the larger variance to the smaller one
625  pf->set(i, var1[i] / var2[i]);
626  df1 = dof1;
627  df2 = dof2;
628  } else {
629  pf->set(i, var2[i] / var1[i]);
630  df1 = dof2;
631  df2 = dof1;
632  }
633  sig[i] = 2*betai(0.5L*df2, 0.5L*df1, df2/(df2 + df1*(*pf)[i]) ); // significance level
634  if ( sig[i] > 1 ) sig[i] = 2 - sig[i];
635  }
636  }
637  if ( verbose & VERB_FULL ) {
638  cout << j << " pixels in set 1 or set 2 had zero variance, and the F-values were set to zero." << endl;
639  cout << datasize << " = total pixels in image" << endl;
640  }
641 
642  return pf;
643 }
644 
645 
Boption
A class for a command line input option.
Definition: options.h:26
Bimage::sizeZ
void sizeZ(long nz)
Definition: Bimage.h:392
img_students_t_test
Bimage * img_students_t_test(int n, Bimage *p, vector< double > &weight)
Applies the Student's t-test to one set of images.
Definition: dimgstats.cpp:365
Boption::scale
Vector3< double > scale()
Definition: options.h:190
string_kill
int string_kill(Bstring *list)
Kills a string linked list.
Definition: Bstring.cpp:768
Bimage::set
void set(long j, double v)
Sets a single value at the given index.
Definition: Bimage.cpp:1118
Bstring
Definition: Bstring.h:29
Bimage::next
Bimage * next
Definition: Bimage.h:179
Bstring::post_rev
Bstring post_rev(char c)
Definition: Bstring.cpp:436
Boption::datatype
DataType datatype()
Definition: options.h:93
Boption::next
Boption * next
Definition: options.h:28
Vector3< double >
Bimage::sizeX
void sizeX(long nx)
Definition: Bimage.h:390
bexit
int bexit(int value)
Exit function for cleanup and debugging.
Definition: utilities.cpp:280
get_option_list
Boption * get_option_list(const char *use[], int argc, char *argv[], int &optind)
Parses command line arguments based on a template.
Definition: options.cpp:40
Bimage::size
Vector3< long > size() const
Definition: Bimage.h:386
img_fom_sqrt
int img_fom_sqrt(Bimage *p)
Definition: dimgstats.cpp:322
options.h
Header file for option handlers.
Bimage::image
Bsub_image * image
Definition: Bimage.h:202
Bimage::images
long images()
Definition: Bimage.h:504
Boption::tag
Bstring tag
Definition: options.h:29
Boption::values
long values(T1 &v1, T2 &v2)
Definition: options.h:115
Bsub_image::origin
void origin(double x, double y, double z)
Definition: Bimage.h:136
TSimple
@ TSimple
Definition: Bimage.h:59
write_img
int write_img(const char *filename, Bimage *p, int compression)
General driver function to write multiple image formats.
Definition: rwimg.cpp:281
img_f_test
Bimage * img_f_test(int set1, int set2, Bimage *p1, Bimage *p2, vector< double > &weight)
Applies the F-test to two sets of images.
Definition: dimgstats.cpp:589
Bimage::sizeY
void sizeY(long ny)
Definition: Bimage.h:391
SMALLFLOAT
#define SMALLFLOAT
Definition: utilities.h:46
img_add_weighed
Bimage * img_add_weighed(Bstring *file_list, vector< double > weight, double newavg=0, double newstd=0, int flags=0)
Adds multiple images together with given weights.
Definition: img_combine.cpp:291
Boption::value
Bstring value
Definition: options.h:30
Bstring::pre_rev
Bstring pre_rev(char c)
Definition: Bstring.cpp:421
Bimage::data_size
long data_size()
Definition: Bimage.h:270
main
int main(int argc, char **argv)
Definition: dimgstats.cpp:81
Bimage
General image parameter class.
Definition: Bimage.h:177
timer.h
Utilities for timing functions.
Unknown_Type
@ Unknown_Type
Definition: utilities.h:151
Vector3.h
Class for 3-value vectors.
Bstring::split_into_doubles
vector< double > split_into_doubles(const Bstring &delim)
Definition: Bstring.cpp:673
Bstring.h
Header file for the string class.
VERB_TIME
#define VERB_TIME
Definition: utilities.h:114
Bimage::file_name
void file_name(string s)
Definition: Bimage.h:245
timer_start
double timer_start()
Starts timer and prints the time.
Definition: timer.cpp:61
utilities.h
Header file for general utilities.
Bstring::length
long length() const
Definition: Bstring.cpp:263
timer_report
double timer_report(double lasttime)
Reports the time elapsed since a given time.
Definition: timer.cpp:76
Bimage::origin
void origin(double ox, double oy, double oz)
Definition: Bimage.h:570
Bimage::change_type
void change_type(char letter)
Get the data type indicated by a single letter code.
Definition: Bimage.cpp:1765
Vector3::volume
double volume()
Definition: Vector3.h:237
rwimg.h
Header file for 2D and 3D image I/O.
Bstring::next
Bstring * next
Definition: Bstring.h:31
img_students_t_test_unequal
Bimage * img_students_t_test_unequal(int set1, int set2, Bimage *p1, Bimage *p2, vector< double > &weight)
Applies the Student's t-test to two sets of images, assumes the two distributions have unequal varian...
Definition: dimgstats.cpp:515
math_util.h
Header file for general utilities.
Boption::filename
Bstring filename()
Definition: options.h:85
img_students_t_test_equal
Bimage * img_students_t_test_equal(int set1, int set2, Bimage *p1, Bimage *p2, vector< double > &weight)
Applies the Student's t-test to two sets of images, assumes the two distributions have approximately ...
Definition: dimgstats.cpp:433
option_kill
int option_kill(Boption *option)
Deallocates a linked list of option structures.
Definition: options.cpp:111
VERB_FULL
#define VERB_FULL
Definition: utilities.h:113
Bimage::data_pointer
unsigned char * data_pointer()
Definition: Bimage.h:284
verbose
int verbose
img_combine.h
Header file for combining two images in various ways.
Bimage::sampling
void sampling(long nn, Vector3< double > u)
Definition: Bimage.h:514
betai
double betai(double a, double b, double x)
Calculates the incomplete beta function Ix(a,b).
Definition: math_util.cpp:320
DataType
DataType
Base data type specifier.
Definition: utilities.h:150
Float
@ Float
Definition: utilities.h:161
use
const char * use[]
Definition: dimgstats.cpp:29
string_add
Bstring * string_add(Bstring **list, const char *string)
Adds a string to a linked list.
Definition: Bstring.cpp:713