Skip to content
Snippets Groups Projects
Select Git revision
  • a17b92cb266d2fd24ff85363ce4dee87fe148788
  • master default protected
  • enh/surfprc
  • ukbiobankv1.5
  • newnew
  • cvsHEAD protected
  • fsl-5_branch
  • osx-109-branch
  • oldOptionsFilm
  • originalSurfaceFilm
  • universal_branch
  • fsl-3_3-branch
  • fsl-3_2
  • release-branch
  • 2111.1
  • 2111.0
  • 2007.0
  • 2004.0
  • cvsFINAL protected
  • FSL6-0-0
  • newStable
  • FinalFive
  • fsl-5_0_11
  • stable
  • fsl-5_0_10
  • fsl-5_0_9
  • fsl-5_0_8
  • fsl-5_0_7
  • fsl-5_0_5
  • fsl-5_0_6
  • root-osx-109-branch
  • newnew_branchpoint
  • fsl-5_0_0
  • fsl-5_0_1
34 results

paradigm.h

Blame
  • ttologp.cc 2.87 KiB
    /*  ttologp.cc
    
        Mark Woolrich, FMRIB Image Analysis Group
    
        Copyright (C) 1999-2000 University of Oxford  */
    
    /*  CCOPYRIGHT  */
    
    #include <iostream>
    #include <fstream>
    #define WANT_STREAM
    #define WANT_MATH
    
    #include "newmatap.h"
    #include "newmatio.h"
    
    #include "miscmaths/t2z.h"
    #include "miscmaths/volume.h"
    #include <string>
    #include "miscmaths/miscmaths.h"
    
    using namespace NEWMAT;
    using namespace MISCMATHS;
    
    // the real defaults are provided in the function parse_command_line
    
    class globaloptions {
    public:
      string varsfname;
      string cbsfname;
      int dof;
    
      string logpfname;
    public:
      globaloptions();
      ~globaloptions() {};
    };
    
    globaloptions globalopts;
    
    
    globaloptions::globaloptions()
    {
      // set up defaults
      logpfname = "logps";
    }
    
    void print_usage(int argc, char *argv[])
    {
      cout << "Usage: " << argv[0] << " [options] <varsfile> <cbsfile> <dof> \n"
           << "  Available options are:\n"
           << "        -logpout <outputvol>            (default is "
                                            << globalopts.logpfname << ")\n"
           << "        -help\n\n";
    }
    
    void parse_command_line(int argc, char* argv[])
    {
      if(argc<2){
        print_usage(argc,argv);
        exit(1);
      }
    
      int inp = 1;
      int n=1;
      string arg;
      char first;
    
      while (n<argc) {
        arg=argv[n];
        if (arg.size()<1) { n++; continue; }
        first = arg[0];
        if (first!='-') {
          if(inp == 1)
    	globalopts.varsfname = arg;
          else if(inp == 2)
    	globalopts.cbsfname = arg;
          else if(inp == 3)
    	globalopts.dof = atoi(argv[n]);
          else
    	{
    	  cerr << "Mismatched argument " << arg << endl;
    	  break;
    	}
          n++;
          inp++;
          continue;
        }
        
        // put options without arguments here
        if ( arg == "-help" ) {
          print_usage(argc,argv);
          exit(0);
         }
    
        if (n+1>=argc) 
          { 
    	cerr << "Lacking argument to option " << arg << endl;
    	break; 
          }
    
        // put options with 1 argument here
        if ( arg == "-logpout") {
          globalopts.logpfname = argv[n+1];
          n+=2;
        } else { 
          cerr << "Unrecognised option " << arg << endl;
          n++;
        } 
      }  // while (n<argc)
    
      if (globalopts.varsfname.size()<1) {
        cerr << "Vars filename not found\n\n";
        print_usage(argc,argv);
        exit(2);
      }
    }
    
    int main(int argc,char *argv[])
    { 
      try{
        cerr << log(10) << endl;
        parse_command_line(argc, argv);
        
        Volume vars, cbs;
        vars.read(globalopts.varsfname.c_str());
        cbs.read(globalopts.cbsfname.c_str());
    
        int numTS = vars.Nrows();
        cerr << numTS << endl;
    
        Volume ps(numTS);
        T2z::ComputePs(vars, cbs, globalopts.dof, ps);
        
        VolumeInfo volinfo = vars.getInfo();
        volinfo.intent_code = NIFTI_INTENT_LOGPVAL;
        ps.setInfo(volinfo);
        ps.writeAsFloat(globalopts.logpfname.c_str());
      }
      catch(Exception p_excp) 
        {
          cerr << p_excp.what() << endl;
          throw;
        }
      catch(...) 
        {
          cerr << "Image error" << endl;
          throw;
        } 
    }