/*  glimGls.h

    Mark Woolrich, FMRIB Image Analysis Group

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

/*  CCOPYRIGHT  */

#if !defined(__glimgls_h)
#define __glimgls_h

#include <iostream>
#include <fstream>
#define WANT_STREAM
#define WANT_MATH

#include "newmatap.h"
#include "newmatio.h"
#include "miscmaths/volume.h"
#include "miscmaths/miscmaths.h"
#include "miscmaths/volumeseries.h"

using namespace NEWMAT;
using namespace MISCMATHS;

namespace FILM {

#define BATCHSIZE 50

  class GlimGls
    {
    public:
      GlimGls(const int pnumTS, const int psizeTS, const int pnumParams);
     
      void setData(const ColumnVector& p_y, const Matrix& p_x, const int ind);       
      void Save(const VolumeInfo& volinfo, const ColumnVector& prethreshpos);
      ColumnVector& getResiduals() { return r; }
      void CleanUp();

    private:

      void SetCorrection(const Matrix& corr, const int ind);

      GlimGls(const GlimGls&);
      GlimGls& operator=(const GlimGls& p_glimgls);
   
      int numTS;
      int sizeTS;
      int numParams;

      // Data to be saved:
      VolumeSeries corrections;
      Matrix b;
      Volume sigmaSquareds;
      float dof;
      ColumnVector r;

      DiagonalMatrix I;
    };

}

#endif