Skip to content
Snippets Groups Projects
paradigm.cc 1.31 KiB
Newer Older
Stephen Smith's avatar
Stephen Smith committed
/*  paradigm.cc

    Mark Woolrich, FMRIB Image Analysis Group

    Copyright (C) 1999-2000 University of Oxford  */

/*  CCOPYRIGHT  */

#include "paradigm.h"
#include "Log.h"
#include "sigproc.h"
#include "miscmaths.h"

using namespace UTILS;

namespace UTILS {

  void Paradigm::load(const string& p_paradfname, const string& p_contrastfname, bool p_blockdesign, int p_sizets)
    {
      if(p_paradfname != "")
	SIGPROC::In(p_paradfname, designMatrix);

      if(p_contrastfname != "")
	 SIGPROC::In(p_contrastfname, contrasts);       
       
      // Check time series match up with design
      if(p_paradfname != "" && designMatrix.Nrows() != p_sizets)
	{
	  cerr << "Num scans = "<< p_sizets << ", design matrix rows = " << designMatrix.Nrows() << endl;
	  throw Exception("size of design matrix does not match number of scans\n");
	}
      
      // Check contrast matches design matrix
      if(p_paradfname != "" &&  p_contrastfname != "" && designMatrix.Ncols() != contrasts.Ncols())
	 { 
	  cerr << "Num contrast cols  = " << contrasts.Ncols() << ", design matrix cols = " 
	    << designMatrix.Ncols() << endl;
	  throw Exception("size of design matrix does not match contrast\n");
	 }

      if(p_blockdesign)
	{
	  // Need to adjust amplitude from (-1,1) to (0,1)
	  designMatrix = (designMatrix + 1)/2;
	}
    }

}