/*

Description: Class containing the background images
             
Author:      Raimundo Sierra
             www.rsierra.com

Copyright:   Copyright (c) 2000 Raimundo Sierra. All rights reserved.
LICENSE:     This program is free software; you can redistribute it and/or modify
             it under the terms of the GNU General Public License as published by
             the Free Software Foundation; either version 2 of the License, or
             (at your option) any later version.

             This program is distributed in the hope that it will be useful,
             but WITHOUT ANY WARRANTY; without even the implied warranty of
             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
             GNU General Public License for more details.

             You should have received a copy of the GNU General Public License
             along with this program; if not, write to the Free Software
             Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

Institution: Surgical Planning Laboratory
             Department of Radiology
             Brigham and Women's Hospital
             Harvard Medical School
             MA 02115
             USA

Date:        11.2000 - 3.2001

Modifications:
<Date>   <Init>    <Version>    <Description>

*/
#ifndef _background
#define _background 1
#include <iostream.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include "basefield.h"

class background: public basefield{
 private:
  unsigned short* _AAI;
  unsigned short* _ADC;
  unsigned short* _DWI;
  unsigned short* _RAI;
  unsigned short* _T2W;

  background(const background &back);      // do not want a copy constructor to 
                                           // avoid creating unwanted copies  
 public:
  // constructors
  background(const char path[], const int dimx=256, const int dimy=256, const int dimz=1 );
  background(const int dimx=256, const int dimy=256, const int dimz=1 );

  // destructor
  ~background();

  void read_back(const char path[], const int slice_no = 0);
  void load(const char path[]);             // load background from disc
                                            // save background to disc
  void save(const char path[], int offset[3]=NULL, int windowsize[3]=NULL);

  unsigned short getAAI(const int fpos);             // get value of element fpos
  unsigned short getADC(const int fpos);
  unsigned short getDWI(const int fpos);
  unsigned short getRAI(const int fpos);
  unsigned short getT2W(const int fpos);

  unsigned short * getAAI();                         // get pointer to background array 
  unsigned short * getADC();
  unsigned short * getDWI();
  unsigned short * getRAI();
  unsigned short * getT2W();

  void setAAI(const unsigned short* AAI);           // set the background
  void setADC(const unsigned short* ADC);
  void setDWI(const unsigned short* DWI);
  void setRAI(const unsigned short* RAI);
  void setT2W(const unsigned short* T2W);

  void mask(const float thresh, const int selection, const int slice);
  void masksingle(const float thresh, const int selection, const int slice);
  void remask(float * segmentation);

  void setZero(const int fpos);                       // set element at fpos to zero in all backgrounds
  bool isZero(const int fpos, const int selection=-1);// true if all backgrounds zero in position fpos

  void reParameter(const int slice=-1);               // set element to element - minimum value of this background + 1;

  void saveAsMRI(const char *path, const int selection);

};

#endif
