-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMCMC.h
175 lines (144 loc) · 4.4 KB
/
MCMC.h
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef CUDIMOT_MCMC_H_INCLUDED
#define CUDIMOT_MCMC_H_INCLUDED
/**
*
* \class MCMC
*
* \brief A class for fitting a model to some dataset on a GPU using MCMC algorithm
*
* \author Moises Hernandez-Fernandez - FMRIB Image Analysis Group
*
* \date March 2017
*
*
* Copyright (C) 2005 University of Oxford
*/
#include <vector>
#include <curand_kernel.h>
#include <curand.h>
#include <curand_kernel.h>
#include "gridOptions.h"
#include "cudimot.h"
#include "checkcudacalls.h"
#include "cudimotoptions.h"
using std::vector;
namespace Cudimot{
template <typename T>
class MCMC{
private:
/**
* The number of voxels to fit in a part
*/
int nvoxFit_part;
/**
* Total number of jumps in MCMC to be discarded at the beginning (default is 5000)
*/
int nburnin;
/**
* Number of jumps in MCMC after burnin period (default is 1250)
*/
int njumps;
/**
* Number of samples to record per parameter and voxel
*/
int nsamples;
/**
* Number of jumps between sample recording
*/
int sampleevery;
/**
* Number of jumps between updates of the proposal standard deviations
*/
int updateproposalevery;
/**
* if false, do not update the proposal standard deviations durinf the recording step of MCMC.
*/
bool updateproposal;
/**
* If activated, use Rician noise modelling
*/
bool RicianNoise;
/**
* State of several random number generators on the GPU
*/
curandState* randStates;
/**
* Standard Deviation of Proposal Distributions on the GPU
*/
T* propSD;
/**
* Standard Deviation of Proposal Distributions for Tau parameter (rician noise) on the GPU
*/
T* tau_propSD;
/**
* Type of each parameter bounds
*/
int* bound_types_host;
/**
* Minimum bound of each parameter
*/
float* bounds_min_host;
/**
* Maximum bound of each parameter
*/
float* bounds_max_host;
/**
* Type of each parameter prior
*/
int* prior_types_host;
/**
* First argument of each parameter prior
*/
float* priors_a_host;
/**
* Second argument of each parameter prior
*/
float* priors_b_host;
/**
* 0: Parameter non fixed, 1: Parameter fixed
*/
int* fixed_host;
/**
* Activate debugging messages for a voxel. It prints the value of some variables at certain steps of Levenberg_Marquardt (Parameters, PredictedSignal, Derivatives, Gradient, Proposed Parameters)
*/
bool DEBUG;
/**
* Number of the voxel (starts at 0) to debug if debugging is activated
*/
int debugVOX;
public:
/**
* Constructor
* @param nvoxFitpart Number of voxel of the data to fit
* @param bound_types Vector with the type of each bound type
* @param bounds_min Vector with the lower bound of each parameter
* @param bounds_max Vector with the upper bound of each parameter
* @param prior_types Vector with the type of each parameter type
* @param prior_a Vector with the first argument of each prior
* @param prior_b Vector with the second argument of each prior
* @param fixed Vector with information to know if parameters are fixed
*/
MCMC(int nvoxFitpart,
vector<int> bound_types, vector<T> bounds_min, vector<T> bounds_max,
vector<int> prior_types, vector<T> priors_a, vector<T> prior_b,
vector<int> fixed);
/**
* Run MCMC algorithm on the GPU
* @param nvox Number of voxels in the dataset
* @param nmeas Number of measurements in the dataset
* @param CFP_size Size (x M measurements) of the common fixed parameters of the model
* @param FixP_size Size (x N voxels) of the fixed parameters of the model
* @param meas Measurements of all the voxels of the dataset (on GPU)
* @param params Value of the parameters to estimate of the model for all the voxels of the dataset (on GPU)
* @param CFP Common (to all the voxels) fixed parameters of the model (on GPU). CFP_size*nmeas
* @param FixP Fixed parameters of the model (on GPU). FixP_size*nvoxels
* @param samples Samples of the parameters estimation will be stored here (on the GPU)
*/
void run( int nvox, int nmeas,
int CFP_size, int FixP_size,
T* meas, T* params,
T* CFP, T* FixP,
T* samples, T* tau);
};
}
#endif