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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/* glmrand.h
Mark Woolrich, FMRIB Image Analysis Group
Copyright (C) 1999-2000 University of Oxford */
/* Part of FSL - FMRIB's Software Library
WWW: http://www.fmrib.ox.ac.uk/fsl
Email: fsl@fmrib.ox.ac.uk
Developed at FMRIB (Oxford Centre for Functional Magnetic Resonance
Imaging of the Brain), Department of Clinical Neurology, Oxford
University, Oxford, UK
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
in
order that the University as a charitable foundation protects its
assets for the benefit of its educational and research purposes, the
University makes clear that no condition is made or to be implied,
nor
is any warranty given or to be implied, as to the accuracy of FSL,
or
that it will be suitable for any particular purpose or for use under
any specific conditions. Furthermore, the University disclaims all
responsibility for the use which is made of FSL. 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA */
#include <iostream>
#include <fstream>
#define WANT_STREAM
#define WANT_MATH
#include "newmatap.h"
#include "newmatio.h"
#include "Volume.h"
#include "VolumeSeries.h"
#if !defined(__glmRand_h)
#define __glmRand_h
#ifndef NO_NAMESPACE
using namespace NEWMAT;
using namespace TACO;
namespace SIGPROC{
#endif
#define BATCHSIZE 50
class GlmRand
{
public:
GlmRand(const int pnumrand, const int pnumts, Matrix& pcontrasts, const int contrastnum) :
yorig(NULL),
x(NULL),
contrasts(&pcontrasts),
numTS(pnumts),
numrand(pnumrand),
randts(pnumrand*pnumts),
datats(pnumts),
datazs(pnumts),
datatscount(1),
batch_size(BATCHSIZE) {SetContrast(contrastnum);}
void addData(ColumnVector& p_y, Matrix& p_x);
void SetContrast(const int p_num) {c = contrasts->Row(p_num).t();}
const Volume& ComputeZStats();
private:
GlmRand(const GlmRand&);
GlmRand& operator=(const GlmRand& p_glmRand);
void randomise();
void ComputeResids();
void ComputeVar();
void Computecb();
void ComputeTStats();
// y = bx + r
// Original time series:
ColumnVector yorig;
VolumeSeries y;
Matrix* x;
// Contrast
Matrix* contrasts;
ColumnVector c;
int numTS;
int sizeTS;
int numrand;
VolumeSeries r;
Matrix pinv_x;
Volume cb;
Volume var;
Volume randts;
Volume datats;
Volume datazs;
Matrix RMat;
int datatscount;
// batch stuff
int batch_size;
};
#endif
#ifndef NO_NAMESPACE
}
#endif