~ubuntu-branches/ubuntu/raring/voxbo/raring

« back to all changes in this revision

Viewing changes to stand_alone/calcgs.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Hanke
  • Date: 2010-06-06 11:33:11 UTC
  • Revision ID: james.westby@ubuntu.com-20100606113311-v3c13imdkkd5n7ae
Tags: upstream-1.8.5~svn1172
ImportĀ upstreamĀ versionĀ 1.8.5~svn1172

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
// calcgs.cpp
 
3
// Copyright (c) 1998-2010 by The VoxBo Development Team
 
4
 
 
5
// This file is part of VoxBo
 
6
// 
 
7
// VoxBo is free software: you can redistribute it and/or modify it
 
8
// under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation, either version 3 of the License, or
 
10
// (at your option) any later version.
 
11
// 
 
12
// VoxBo is distributed in the hope that it will be useful, but
 
13
// WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
15
// General Public License for more details.
 
16
// 
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with VoxBo.  If not, see <http://www.gnu.org/licenses/>.
 
19
// 
 
20
// For general information on VoxBo, including the latest complete
 
21
// source code and binary distributions, manual, and associated files,
 
22
// see the VoxBo home page at: http://www.voxbo.org/
 
23
// 
 
24
// original version written by Kosh Banerjee
 
25
 
 
26
/*********************************************************************
 
27
* calcgs.cpp                                                         *
 
28
* VoxBo CalcGS utility.                                              *
 
29
* K. Banerjee  03/06/2001                                            *
 
30
*                                                                    *
 
31
* This program computes the Global Spectrum of the input 4D data     *
 
32
* file.                                                              *
 
33
*                                                                    *
 
34
* INPUTS:                                                            *
 
35
* -------                                                            *
 
36
* 4D data file name. Required.                                       *
 
37
* Flag to specify if the GS should have unit variance or not.        *
 
38
* Optional.                                                          *
 
39
*                                                                    *
 
40
* OUTPUTS:                                                           *
 
41
* --------                                                           *
 
42
* The Global spectrum is written to a file called *_GS.ref where     *
 
43
* "*" represents the input 4D data file name without the ".tes"      *
 
44
* extension.                                                         *
 
45
*********************************************************************/
 
46
 
 
47
void usage(const unsigned short exitValue, char *progName);
 
48
 
 
49
#include <iostream>
 
50
#include <string>
 
51
#include "calc_gs_ps.h"
 
52
 
 
53
int main(int argc, char *argv[], char *[]) {
 
54
  SEGV_HANDLER
 
55
 
 
56
/*********************************************************************
 
57
* VARIABLES:   TYPE:           DESCRIPTION:                          *
 
58
* ----------   -----           ------------                          *
 
59
* unitVar      bool            TRUE if the user wants the GS to have *
 
60
*                              unit variance.                        *
 
61
* printHelp    bool            Will be set to TRUE is the user omits *
 
62
*                              required options or wants usage       *
 
63
*                              information printed out.              *
 
64
* printVersion bool            Will be set to TRUE is the user wants *
 
65
*                              the global VoxBo version printed.     *
 
66
*********************************************************************/
 
67
  bool unitVar = false;
 
68
  string tesFile;
 
69
  if (argc == 1)
 
70
    usage(1, argv[0]);
 
71
 
 
72
/*********************************************************************
 
73
* Now processing the command line options.                           *
 
74
*                                                                    *
 
75
* -h ==> Display usage information.                                  *
 
76
* -i ==> Specifies the input 4D data file.                           *
 
77
* -u ==> The unit variance flag.                                     *
 
78
* -v ==> Print global VoxBo version.                                 *
 
79
*********************************************************************/
 
80
  arghandler a;
 
81
  a.setArgs("-h", "--help", 0);
 
82
  a.setArgs("-i", "--inputfile", 1);
 
83
  a.setArgs("-u", "--unitvariance", 1);
 
84
  a.setArgs("-v", "--version", 0);
 
85
  a.parseArgs(argc, argv);
 
86
  string errstring = a.badArg();
 
87
  if (errstring.size()) {
 
88
     errstring = "[E] unknown flag: " + errstring;
 
89
     printErrorMsg(VB_ERROR, errstring.c_str());
 
90
     exit(-1);
 
91
  }
 
92
  if (a.flagPresent("-h"))
 
93
     usage(0, argv[0]);
 
94
  tesFile = a.getFlaggedArgs("-i")[0];
 
95
  unitVar = atoi(a.getFlaggedArgs("-u")[0].c_str());
 
96
  if (a.flagPresent("-v"))
 
97
    printf("\nVoxBo v%s\n",vbversion.c_str());
 
98
  if (tesFile.size() == 0) {
 
99
    cerr << "ERROR: Must specify the input 4D data file name." << endl;
 
100
    usage(1, argv[0]);
 
101
  } 
 
102
  CalcGs myGs(tesFile);
 
103
  if (unitVar)
 
104
    myGs.normalizeVariance();
 
105
  myGs.printGsData();
 
106
  return 0;
 
107
 
108
 
 
109
/*********************************************************************
 
110
* This function calls genusage() to write out the usage information. *
 
111
*                                                                    *
 
112
* INPUTS:                                                            *
 
113
* -------                                                            *
 
114
* exitValue: The desired exit value.                                 *
 
115
* progName: String holding the program name.                         *
 
116
*                                                                    *
 
117
* OUTPUTS:                                                           *
 
118
* --------                                                           *
 
119
* None.                                                              *
 
120
*********************************************************************/
 
121
void usage(const unsigned short, char *)
 
122
{
 
123
  printf("\nVoxBo calcgs (v%s)\n",vbversion.c_str());
 
124
  printf("summary: ");
 
125
  printf(" Calc GS routine for VoxBo.\n");
 
126
  printf("usage:\n");
 
127
  printf(" calcgs -h -i[4D data file name] -u -v\n");
 
128
  printf("flags:\n");
 
129
  printf(" -h                        Print usage information. Optional.\n");
 
130
  printf(" -i <4D data file>         Specify the input 4D data file. Required.\n");
 
131
  printf(" -u                        Unit variance flag for GS. Optional.\n");
 
132
  printf(" -v                        Global VoxBo version number. Optional.\n\n");
 
133
  exit(-1);
 
134