forked from Slicer/SlicerGitSVNArchive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vtkTeemEstimateDiffusionTensor.h
205 lines (161 loc) · 5.83 KB
/
vtkTeemEstimateDiffusionTensor.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*=auto=========================================================================
Portions (c) Copyright 2005 Brigham and Women's Hospital (BWH) All Rights Reserved.
See COPYRIGHT.txt
or http://www.slicer.org/copyright/copyright.txt for details.
Program: 3D Slicer
Module: $RCSfile: vtkTeemEstimateDiffusionTensor.h,v $
Date: $Date: 2007/04/09 08:10:16 $
Version: $Revision: 1.3.2.1 $
=========================================================================auto=*/
#ifndef __vtkTeemEstimateDiffusionTensor_h
#define __vtkTeemEstimateDiffusionTensor_h
#include "vtkTeemConfigure.h"
#include "vtkThreadedImageAlgorithm.h"
#include "vtkDoubleArray.h"
#include "vtkTransform.h"
#include <vtkVersion.h>
#include "teem/nrrd.h"
/* avoid name conflicts with symbols from python */
#undef ECHO
#undef B0
#include "teem/ten.h"
class VTK_Teem_EXPORT vtkTeemEstimateDiffusionTensor : public vtkThreadedImageAlgorithm
{
public:
static vtkTeemEstimateDiffusionTensor *New();
vtkTypeMacro(vtkTeemEstimateDiffusionTensor,vtkThreadedImageAlgorithm);
///
/// The number of gradients is the same as the number of input
/// diffusion ImageDatas this filter will require.
void SetNumberOfGradients(int num);
vtkGetMacro(NumberOfGradients,int);
///
/// Set the 3-vectors describing the gradient directions
void SetDiffusionGradient(int num, double gradient[3])
{
this->DiffusionGradients->SetTuple(num,gradient);
this->Modified();
}
void SetDiffusionGradient(int num, double g0, double g1, double g2)
{
this->DiffusionGradients->SetComponent(num,0,g0);
this->DiffusionGradients->SetComponent(num,1,g1);
this->DiffusionGradients->SetComponent(num,2,g2);
this->Modified();
}
void SetDiffusionGradients(vtkDoubleArray *grad);
vtkGetObjectMacro(DiffusionGradients,vtkDoubleArray);
///
/// Get the 3-vectors describing the gradient directions
void GetDiffusionGradient(int num,double grad[3]);
/// the following look messy but are copied from vtkSetGet.h,
/// just adding the num parameter we need.
void SetBValue(int num,double b)
{
this->BValues->SetValue(num,b);
this->CalculateMaxB();
this->Modified();
}
void SetBValues(vtkDoubleArray *bValues);
vtkGetObjectMacro(BValues,vtkDoubleArray);
/// Description
/// need to calculate max B (using GetRange) outside threaded execute
void CalculateMaxB();
vtkSetMacro(MaxB, double);
vtkGetMacro(MaxB, double);
#if (VTK_MAJOR_VERSION <= 5)
///
/// Get Baseline Image
vtkGetObjectMacro(Baseline,vtkImageData);
///
/// Get Average of all DWI images
vtkGetObjectMacro(AverageDWI,vtkImageData);
#else
///
/// Get Baseline Image
vtkImageData* GetBaseline();
///
/// Get Average of all DWI images
vtkImageData* GetAverageDWI();
#endif
enum
{
tenEstimateMethodUnknown, /* 0 */
tenEstimateMethodLLS, /* 1 */
tenEstimateMethodWLS, /* 2 */
tenEstimateMethodNLS, /* 3 */
tenEstimateMethodLast
};
//Description
vtkGetMacro(EstimationMethod,int);
vtkSetMacro(EstimationMethod,int);
void SetEstimationMethodToLLS() {
this->SetEstimationMethod(tenEstimateMethodLLS);
};
void SetEstimationMethodToNLS() {
this->SetEstimationMethod(tenEstimateMethodNLS);
};
void SetEstimationMethodToWLS() {
this->SetEstimationMethod(tenEstimateMethodWLS);
};
vtkGetMacro(MinimumSignalValue,double);
vtkSetMacro(MinimumSignalValue,double);
/// Description
/// Transformation of the tensors (for RAS coords, for example)
/// The gradient vectors are multiplied by this matrix
vtkSetObjectMacro(Transform, vtkTransform);
vtkGetObjectMacro(Transform, vtkTransform);
///
/// Internal class use only
void TransformDiffusionGradients();
void RescaleGradients();
int SetGradientsToContext ( tenEstimateContext *tec,Nrrd *ngrad, Nrrd *nbmat);
int SetTenContext( tenEstimateContext *tec,Nrrd *ngrad, Nrrd *nbmat);
///
/// Flag to shift eigenvalues upwards to that smallest one is non-negative
/// (negEvalShift in Teem's Ten)
vtkSetMacro(ShiftNegativeEigenvalues,int);
vtkGetMacro(ShiftNegativeEigenvalues,int);
protected:
vtkTeemEstimateDiffusionTensor();
~vtkTeemEstimateDiffusionTensor();
vtkTeemEstimateDiffusionTensor(const vtkTeemEstimateDiffusionTensor&);
void operator=(const vtkTeemEstimateDiffusionTensor&);
void PrintSelf(ostream& os, vtkIndent indent);
int NumberOfGradients;
vtkDoubleArray *BValues;
vtkDoubleArray *DiffusionGradients;
vtkDoubleArray *RescaledDiffusionGradients;
/// Maximum of the B values
double MaxB;
#if (VTK_MAJOR_VERSION <= 5)
vtkImageData *Baseline;
vtkImageData *AverageDWI;
#endif
/// for transforming tensors
vtkTransform *Transform;
/// Method
int EstimationMethod;
/// Minimum detectable value
double MinimumSignalValue;
/// Noise variance (useful for MLE)
double Sigma;
/// Matrices for LS fitting
int knownB0;
///
/// Flag to shift eigenvalues upwards to that smallest one is non-negative
/// (negEvalShift in Teem's Ten)
int ShiftNegativeEigenvalues;
///
int NumberOfWLSIterations;
virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
void ThreadedExecute(vtkImageData *inData, vtkImageData *outData,
int extent[6], int id);
/// We override this in order to allocate output tensors
/// before threading happens. This replaces the superclass
/// vtkImageAlgorithm's RequestData function.
virtual int RequestData(vtkInformation* request,
vtkInformationVector** inputVector,
vtkInformationVector* outputVector);
};
#endif