Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* volumeseries.h
Mark Woolrich - FMRIB Image Analysis Group
Copyright (C) 2002 University of Oxford */
/* CCOPYRIGHT */
#include <iostream>
#include <fstream>
#define WANT_STREAM
#define WANT_MATH
#include "newmatap.h"
#include "newmatio.h"
#include "volumeinfo.h"
#include <string>
using namespace NEWMAT;
namespace MISCMATHS {
#if !defined(__volumeseries_h)
#define __volumeseries_h
// Rows are volumes
// Columns are (time) series
// num Rows is size of (time) series
// num Cols is size of volumes
class VolumeSeries : public Matrix
{
public:
VolumeSeries() : Matrix() {}
VolumeSeries(const VolumeInfo& pvolinfo, const ColumnVector& in) :
Matrix(),
volinfo(pvolinfo),
preThresholdPositions(in)
{}
VolumeSeries(int pnumVols, int pnumSeries) :
Matrix(pnumVols, pnumSeries),
means(pnumSeries){}
VolumeSeries(int pnumVols, int pnumSeries, const VolumeInfo& pvolinfo, const ColumnVector& in) :
Matrix(pnumVols, pnumSeries),
volinfo(pvolinfo),
preThresholdPositions(in),
means(pnumSeries){}
VolumeSeries& operator=(const VolumeSeries& vol) {
Matrix::operator=(vol);
preThresholdPositions = vol.preThresholdPositions;
volinfo = vol.volinfo;
means = vol.means;
return *this;
}
VolumeSeries& operator=(const Matrix& mat) {
Matrix::operator=(mat);
return *this;
}
VolumeSeries& operator=(float pin) {
Matrix::operator=(pin);
return *this;
}
VolumeSeries(const VolumeSeries& vol){operator=(vol);}
VolumeSeries(const Matrix& pmat) : Matrix(pmat) {}
void thresholdSeries(float thresh, bool removeMean);
void thresholdSeries();
void unthresholdSeries();
void unthresholdSeries(const VolumeInfo& pvolinfo,const ColumnVector& in);
void removeSeriesMeans();
const ColumnVector& getPreThresholdPositions() const { return preThresholdPositions; }
void setPreThresholdPositions(const ColumnVector& in) { preThresholdPositions = in; }
int getNumVolumes() const { return Nrows(); }
int getNumSeries() const { return Ncols(); }
int nvoxels() const { return Ncols(); }
int tsize() const { return Nrows(); }
const ReturnMatrix getSeries(int i) const { ColumnVector tmp = Column(i);tmp.Release();return tmp; }
ReturnMatrix getSeries(int i) { ColumnVector tmp = Column(i);tmp.Release();return tmp; }
void setSeries(const ColumnVector& in, int i) { Column(i) = in; }
const ReturnMatrix getVolume(int i) const { RowVector tmp = Row(i);tmp.Release();return tmp; }
ReturnMatrix getVolume(int i) { RowVector tmp = Row(i);tmp.Release();return tmp; }
void setVolume(const ColumnVector& in, int i) { Row(i) = in.AsRow(); }
void setVolume(const RowVector& in, int i) { Row(i) = in; }
void read(const std::string& fname);
void writeAsInt(const std::string& fname);
void writeAsFloat(const std::string& fname);
void writeThresholdedSeriesAsFloat(const VolumeInfo& pvolinfo,const ColumnVector& in,const std::string& fname);
void replaceMeans();
const VolumeInfo& getInfo() const { return volinfo; }
void setInfo(const VolumeInfo& pvolinfo) { volinfo = pvolinfo; }
int getUnthresholdNumSeries() const { return volinfo.x*volinfo.y*volinfo.z; }
protected:
VolumeInfo volinfo;
ColumnVector preThresholdPositions;
ColumnVector means;
};
#endif
}