FSL User Guide - NEWIMAGE Quick Reference Guide

| # FSL User Guide - NEWIMAGE Quick Reference Guide |

## VOLUME

    template <class T>
    class volume : public lazymanager {
    public:
      // CONSTRUCTORS AND DESTRUCTORS (including copy, = and reinitialize)
      volume();
      volume(const volume<T>& source);
      volume(int xsize, int ysize, int zsize);
      volume(int xsize, int ysize, int zsize, T *d, bool d_owner);
      ~volume();
      const volume<T>& operator=(const volume<T>& source);
      int reinitialize(const volume<T>& source);
      int reinitialize(int xsize, int ysize, int zsize);
      int reinitialize(int xsize, int ysize, int zsize, T *d, bool d_owner);
      int copyproperties(const volume<T>& source);
      int copydata(const volume<T>& source);

      // BASIC PROPERTIES
      inline int xsize() const;
      inline int ysize() const;
      inline int zsize() const;
      inline float xdim() const;
      inline float ydim() const;
      inline float zdim() const;
      inline const int xsign(void) const;
      inline const int ysign(void) const;
      inline const int zsign(void) const;

      void setxdim(float x);
      void setydim(float y);
      void setzdim(float z);
      void setdims(float x, float y, float z);
      int nvoxels() const;

      // ROI FUNCTIONS
      inline const std::vector<int>& limits() const;
      inline int limits(int n) const;
      inline int minx() const;
      inline int maxx() const;
      inline int miny() const;
      inline int maxy() const;
      inline int minz() const;
      inline int maxz() const;
      inline const std::vector<int>& ROIlimits() const;
      inline int ROIlimits(int n) const;
      inline bool usingROI() const;
      void setROIlimits(int x0, int y0, int z0, int x1, int y1, int z1) const;
      void setROIlimits(const std::vector<int>& lims) const;
      void activateROI() const;
      void deactivateROI() const;
      int copyROIonly(const volume<T>& source);

      // SECONDARY PROPERTIES
      Matrix sampling_mat() const;
      const ColumnVector& getorigin() const;
      void setorigin(const ColumnVector& orig) const;
      void setorigin(float x, float y, float z) const;
      T min() const;
      T max() const;
      float sum() const;
      float sumsquares() const;
      float mean() const;
      float variance() const;
      float stddev() const;
    //      T robustmin() const;
    //      T robustmax() const;
      ColumnVector principleaxis(int n) const;
    //      T percentile(float pvalue) const;
    //      ColumnVector histogram(int nbins) const;
    //      ColumnVector histogram(int nbins, T minval, T maxval) const;

      T backgroundval() const;
      ColumnVector cog() const;

      // DATA ACCESS FUNCTIONS (iterators)
      typedef poslazyiterator<T> iterator;
      typedef posconstiterator<T> const_iterator;
      typedef rlazyiterator<T*,T> fast_iterator;
      typedef const T* fast_const_iterator;

      inline iterator begin();
      inline iterator end();
      inline const_iterator begin() const;
      inline const_iterator end() const;
      inline fast_iterator fbegin();
      inline fast_iterator fend();
      inline fast_const_iterator fbegin() const;
      inline fast_const_iterator fend() const;

      // BASIC DATA ACCESS FUNCTIONS
      inline bool in_bounds(int x, int y, int z) const;
      inline T& operator()(int x, int y, int z);
      inline const T& operator()(int x, int y, int z) const;

      inline T& value(int x, int y, int z);
      inline const T& value(int x, int y, int z) const;

      // SECONDARY FUNCTIONS
      void setextrapolation(extrapolation extrapmethod) const;
      extrapolation getextrapolationmethod() const;
      void setpadvalue(T padval) const;
      T getpadvalue() const;
      inline void getneighbours(int x, int y, int z,
    			      T &v000, T &v001, T &v010,
    			      T &v011, T &v100, T &v101,
    			      T &v110, T &v111) const;
      inline void getneighbours(int x, int y, int z,
    			      T &v000, T &v010,
    			      T &v100, T &v110) const;

      // ARITHMETIC FUNCTIONS
      T operator=(T val);
      const volume<T>& operator+=(T val);
      const volume<T>& operator-=(T val);
      const volume<T>& operator*=(T val);
      const volume<T>& operator/=(T val);
      const volume<T>& operator+=(const volume<T>& source);
      const volume<T>& operator-=(const volume<T>& source);
      const volume<T>& operator*=(const volume<T>& source);
      const volume<T>& operator/=(const volume<T>& source);

      volume<T> operator+(T num) const;
      volume<T> operator-(T num) const;
      volume<T> operator*(T num) const;
      volume<T> operator/(T num) const;
      volume<T> operator+(const volume<T>& vol2) const;
      volume<T> operator-(const volume<T>& vol2) const;
      volume<T> operator*(const volume<T>& vol2) const;
      volume<T> operator/(const volume<T>& vol2) const;

      template <class S>
      friend volume<S> operator+(S num, const volume<S>& vol);
      template <class S>
      friend volume<S> operator-(S num, const volume<S>& vol);
      template <class S>
      friend volume<S> operator*(S num, const volume<S>& vol);
      template <class S>
      friend volume<S> operator/(S num, const volume<S>& vol);

      // CONVERSION FUNCTIONS
      template <class S, class D> friend
      void copyconvert(const volume<S>& source, volume<D>& dest);

    };

    // HELPER FUNCTIONS

    template <class S, class D>
    void convertbuffer(const S* source, D* dest, int len);

    template <class S1, class S2>
    bool samesize(const volume<S1>& vol1, const volume<S2>& vol2);

## VOLUME4D

    template <class T>
    class volume4D : public lazymanager {
    public:
      // CONSTRUCTORS AND DESTRUCTORS (including copy, = and reinitialize)
      volume4D();
      volume4D(const volume4D<T>& source);
      volume4D(int xsize, int ysize, int zsize, int tsize, T *d=0);
      ~volume4D();
      const volume4D<T>& operator=(const volume4D<T>& source);
      int reinitialize(const volume4D<T>& source);
      int reinitialize(int xsize, int ysize, int zsize, int tsize, T *d=0);
      int copyproperties(const volume4D<T>& source);
      int copyvolumes(const volume4D<T>& source);

      inline T& operator()(int x, int y, int z, int t);
      inline const T& operator()(int x, int y, int z, int t) const;
      inline volume<T>& operator[](int t);
      inline const volume<T>& operator[](int t) const;

      void addvolume(const volume<T>& source);
      void insertvolume(const volume<T>& source, int t);
      void deletevolume(int t);

      ColumnVector voxelts(int x, int y, int z) const;
      void setvoxelts(const ColumnVector& ts, int x, int y, int z);

      Matrix matrix(const volume<T>& mask) const;
      Matrix matrix() const;
      void setmatrix(const Matrix& newmatrix, const volume<T>& mask,
    		   const T pad=0);
      void setmatrix(const Matrix& newmatrix);

      // ROIset, blah blah
      inline int xsize() const;
      inline int ysize() const;
      inline int zsize() const;
      inline int tsize() const;
      inline float xdim() const;
      inline float ydim() const;
      inline float zdim() const;
      inline float tdim() const;
      inline float TR() const;
      inline const int xsign(void) const;
      inline const int ysign(void) const;
      inline const int zsign(void) const;

      void setxdim(float x);
      void setydim(float y);
      void setzdim(float z);
      void settdim(float tr);
      void setTR(float tr);
      void setdims(float x, float y, float z, float tr);
      int nvoxels() const;
      int ntimepoints() const;

      T min() const;
      T max() const;

      // ARITHMETIC FUNCTIONS
      T operator=(T val);

      // CONVERSION FUNCTIONS
    //      template <class S, class D> friend
    //      void copyconvert(const volume4D<S>& source, volume4D<D>& dest);
    };

#### Mark Jenkinson
Copyright © 2000, University of Oxford