File: BrainModelVolumeSureFitSegmentation.h

package info (click to toggle)
caret 5.6.4~dfsg.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, wheezy
  • size: 31,904 kB
  • ctags: 28,901
  • sloc: cpp: 378,050; python: 6,718; ansic: 5,507; makefile: 333; sh: 46
file content (515 lines) | stat: -rw-r--r-- 16,451 bytes parent folder | download | duplicates (2)
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515

#ifndef __BRAIN_MODEL_VOLUME_SEGMENTATION_H__
#define __BRAIN_MODEL_VOLUME_SEGMENTATION_H__

/*LICENSE_START*/
/*
 *  Copyright 1995-2002 Washington University School of Medicine
 *
 *  http://brainmap.wustl.edu
 *
 *  This file is part of CARET.
 *
 *  CARET 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.
 *
 *  CARET is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with CARET; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 */
/*LICENSE_END*/

#include <QString>

#include "BrainModelAlgorithm.h"
#include "BrainModelSurface.h"
#include "SureFitVectorFile.h"
#include "VolumeFile.h"

class PaintFile;

/// class for performing segmentation operations
class BrainModelVolumeSureFitSegmentation : public BrainModelAlgorithm {
   public:
      /// error correction method
      enum ERROR_CORRECTION_METHOD {
         /// No Error Correction
         ERROR_CORRECTION_METHOD_NONE,
         /// Graph-Based Error Correction
         ERROR_CORRECTION_METHOD_GRAPH,
         /// SureFit Error Correction
         ERROR_CORRECTION_METHOD_SUREFIT,
         /// SureFit Error Correction followed by Graph Correction
         ERROR_CORRECTION_METHOD_SUREFIT_AND_GRAPH,
         /// Graph Error Correction followed by SureFit Error
         ERROR_CORRECTION_METHOD_GRAPH_AND_SUREFIT
      };
      
      /// Constructor
      BrainModelVolumeSureFitSegmentation(BrainSet* bs,
                                   const VolumeFile* anatomyVolumeIn,
                                   const VolumeFile* segmentationVolumeIn,
                                   const VolumeFile::FILE_READ_WRITE_TYPE typeOfVolumeFilesToWriteIn,
                                   const int acIJKIn[3],
                                   const int paddingIn[6],
                                   const float wmPeakIn,
                                   const float gmPeakIn,
                                   const float midThreshOverrideIn,
                                   const Structure::STRUCTURE_TYPE structureIn,
                                   const bool disconnectEyeFlagIn,
                                   const bool disconnectHindBrainFlagIn,
                                   const bool disconnectHindBrainHiThreshFlagIn,
                                   const bool cutCorpusCallosumFlagIn,
                                   const bool segmentAnatomyFlagIn,
                                   const bool fillVentriclesFlagIn,
                                   const ERROR_CORRECTION_METHOD errorCorrectionMethodIn,
                                   const bool generateRawAndFidualSurfacesFlagIn,
                                   const bool maximumPolygonsFlagIn,
                                   const bool generateTopologicallyCorrectFiducialSurfaceFlagIn,
                                   const bool generateInflatedSurfaceFlagIn,
                                   const bool generateVeryInflatedSurfaceFlagIn,
                                   const bool generateEllipsoidSurfaceFlagIn,
                                   const bool generateSphericalSurfaceFlagIn,
                                   const bool generateCompressedMedialWallSurfaceFlagIn,
                                   const bool generateHullSurfaceFlagIn,
                                   const bool generateDepthCurvatureGeographyFlagIn,
                                   const bool identifyRegisterFlattenLandmarksFlagIn,
                                   const bool autoSaveFilesFlagIn);
                                   
      /// Constructor used for identifying sulci only.  
      BrainModelVolumeSureFitSegmentation(
                                   BrainSet* bs,
                                   const Structure::STRUCTURE_TYPE structureIn,
                                   const VolumeFile::FILE_READ_WRITE_TYPE typeOfVolumeFilesToWriteIn,
                                   const bool generateHullSurfaceFlagIn);
      
      /// Destructor
      ~BrainModelVolumeSureFitSegmentation();
      
      /// get error correction methods and names
      static void getErrorCorrectionMethodsAndNames(std::vector<QString>& namesOut,
                                  std::vector<ERROR_CORRECTION_METHOD>& methodsOut);
                                  
      /// set the volume mask applied prior to inner and outer boundary determination
      void setVolumeMask(const VolumeFile* volumeMaskIn);
      
      /// set white maximum (values larger than this are excluded prior to inner and outer boundary determination
      void setWhiteMatterMaximum(const float whiteMatterMaximumIn);
      
      /// execute the algorithm
      void execute() throw (BrainModelAlgorithmException);
      
      /// execute the algorithm for only identifying sulci
      void executeIdentifySulci() throw (BrainModelAlgorithmException);
      
      /// generate the corpus callosum slice (assumes AC at center)
      /// estimate white matter peak if invalid
      static void generateCorpusCallosumSlice(VolumeFile& anatomyVolumeFileIn,
                                              VolumeFile& corpusCallosumVolumeFileOut,
                                              const Structure& structure,
                                              const float grayMatterPeakIn,
                                              const float whiteMatterPeakIn,
                                              const bool looseMask = false) throw (BrainModelAlgorithmException);
                                              
   protected:
      /// apply volume mask and white matter maximum
      void applyVolumeMaskAndWhiteMatterMaximum() throw (BrainModelAlgorithmException);
      
      /// disconnect the eye
      void disconnectEye() throw (BrainModelAlgorithmException);
      
      /// disconnect the hind brain
      void disconnectHindBrain() throw (BrainModelAlgorithmException);
      
      /// cut the corpus callossum
      void cutCorpusCallossum() throw (BrainModelAlgorithmException);
      
      /// generate the inner boundary
      void generateInnerBoundary() throw (BrainModelAlgorithmException);
      
      /// generate the outer boundary
      void generateOuterBoundary() throw (BrainModelAlgorithmException);
      
      /// generate the segmentation
      void generateSegmentation() throw (BrainModelAlgorithmException);
      
      /// generate the raw and fiducial surfaces
      void generateRawAndFiducialSurfaces(VolumeFile* vf) throw (BrainModelAlgorithmException);
      
      /// create a fiducial surface that is topologically correct
      void generateTopologicallyCorrectFiducialSurface();
      
      /// generate the inflated and ellipsoid surfaces
      void generateInflatedAndEllipsoidSurfaces() throw (BrainModelAlgorithmException);
      
      /// fill ventricles
      void fillVentricles() throw (BrainModelAlgorithmException);
      
      /// do graph-based automatic error correction
      VolumeFile* graphBasedErrorCorrection(VolumeFile* vf);
      
      /// do SureFit automatic error correction
      VolumeFile* sureFitAutomaticErrorCorrection(VolumeFile* vf);
      
      /// generate depth, curvature, and geography
      void generateDepthCurvatureGeography(const VolumeFile* vf);
      
      /// generate landmarks borders for flattening and registration
      void generateRegistrationFlatteningLandmarkBorders() throw (BrainModelAlgorithmException);
      
      /// generate default scenes
      void generateDefaultScenes() throw (BrainModelAlgorithmException);
      
      /// get parameters from the parameters file
      void getParameters() throw (BrainModelAlgorithmException);
      
      /// write the volume for debugging
      void writeDebugVolume(VolumeFile* vf, const QString& name) throw (BrainModelAlgorithmException);
      
      /// write the volume for debugging
      void writeDebugVolume(VolumeFile& vf, const QString& name) throw (BrainModelAlgorithmException);
      
      /// write the vector file for debugging
      void writeDebugVector(SureFitVectorFile& vf, const QString& name) throw (BrainModelAlgorithmException);
      
      /// Free a volume file.
      void freeVolumeInMemory(VolumeFile* &vf);

      /// Free a vector file.
      void freeVectorInMemory(SureFitVectorFile* &vf);

      /// free all volumes and vector files in memory.
      void freeAllFilesInMemory();

      /// assign paint for padded CUT.FACE nodes
      void assignPaddedCutFaceNodePainting(const CoordinateFile* cf,
                                           const VolumeFile* segmentVol,
                                           PaintFile* pf,
                                           const int columnToAssign);
                                           
      /// the fiducial surface
      BrainModelSurface* fiducialSurface;
      
      /// the input volume
      VolumeFile* anatomyVolume;
      
      /// resulting segmentation volume
      VolumeFile* segmentationVolume;
      
      /// resulting segmentation with ventricles filled
      VolumeFile* segmentationVentriclesFilledVolume;
      
      /// white matter threshold no eye volume
      VolumeFile* whiteMatterThreshNoEyeVolume;
      
      /// white matter threshold no eye flood volume
      VolumeFile* whiteMatterThreshNoEyeFloodVolume;
      
      /// cerebral white matter no brain stem filled
      VolumeFile* cerebralWmNoBstemFill;
      
      /// the inner mask volume
      VolumeFile* innerMask1Volume;
      
      /// intensity gradient volume
      VolumeFile* gradIntensityVolume;
      
      /// eye fat sculpt volume
      VolumeFile* eyeFatSculptVolume;
      
      /// gray matter level volume
      VolumeFile* gmILevelVolume;
      
      /// outer mask
      VolumeFile* outerMaskVolume;
      
      /// hindbrain flood volume
      VolumeFile* hindbrainFloodVolume;
      
      /// volume
      VolumeFile* wmThreshFloodVolume;
      
      /// volume
      VolumeFile* inTotalVolume;
      
      /// wm volume
      VolumeFile* inTotalThinWMVolume;
      
      /// out total volume
      VolumeFile* outTotalVolume;
      
      /// wm near ventricle volume
      VolumeFile* thinWMOrNearVentricleHCMask;
      
      /// gradient blur
      VolumeFile* ventGradLevelBlurVolume;
      
      /// inner boundary blur
      VolumeFile* inTotalBlur1Volume;
      
      /// outer boundary blur
      VolumeFile* outTotalBlur1Volume;
      
      /// cerebral wm erode volume
      VolumeFile* cerebralWMErodeVolume;
      
      /// pia vector
      SureFitVectorFile* gradPiaLevelVec;
      
      /// the gradient thin white matter vector
      SureFitVectorFile* gradThinWMlevelVecFile;
      
      /// the intensity gradient file
      SureFitVectorFile* gradIntensityVecFile;
      
      /// total thin WM gradient file
      SureFitVectorFile* gradInTotalThinWMVecFile;
      
      /// gray/white gradient
      SureFitVectorFile* gradGWlevelVecFile;
      
      /// gradient pial vector
      SureFitVectorFile* outGradPialLevelGMGradOutITMagVecFile;
      
      /// optional mask used for removal of non-cortical material
      VolumeFile* volumeMask;
      
      /// optional value for excluding voxels larger than this value
      float whiteMatterMaximum;
      
      /// disconnect eye flag
      bool disconnectEyeFlag;
      
      /// disconnect the hind brain flag
      bool disconnectHindBrainFlag;
      
      /// disconnect hind brain using high thresholding flag
      bool disconnectHindBrainHiThreshFlag;
      
      /// cut the corpus callossum flag
      bool cutCorpusCallosumFlag;
      
      /// generate the inner boundary flag
      bool generateInnerBoundaryFlag;
      
      /// generate the outer boundary flag
      bool generateOuterBoundaryFlag;
      
      /// generate the segmentation flag
      bool generateSegmentationFlag;
      
      /// generate the surface flag
      bool generateRawAndFidualSurfacesFlag;
      
      /// generate a topologically correct fiducial surface
      bool generateTopologicallyCorrectFiducialSurfaceFlag;
      
      /// generate inflated surface
      bool generateInflatedSurfaceFlag;
      
      /// generate very inflated surface
      bool generateVeryInflatedSurfaceFlag;
      
      /// generate ellipsoid surfaces
      bool generateEllipsoidSurfaceFlag;
      
      /// generate spherical surface
      bool generateSphericalSurfaceFlag;
      
      /// generate compressed medial wall surface
      bool generateCompressedMedialWallSurfaceFlag;
      
      /// generate hull surface
      bool generateHullSurfaceFlag;
      
      /// fill ventricles flag
      bool fillVentriclesFlag;
      
      /// error correction method
      ERROR_CORRECTION_METHOD errorCorrectionMethod;
      
      /// generate depth, curvature, geography flag
      bool generateDepthCurvatureGeographyFlag;
      
      /// generate landmarks for registration and flattening
      bool identifyRegisterFlattenLandmarksFlag;
      
      /// auto-save files flag
      bool autoSaveFilesFlag;
      
      /// generate maximum polygons
      bool maximumPolygonsFlag;
      
      /// x dimensions of volume being segmented
      int xDim;
      
      /// y dimensions of volume being segmented
      int yDim;
      
      /// z dimensions of volume being segmented
      int zDim;
      
      /// Anterior Commissure voxel indices
      int acIJK[3];
      
      /// x/y/z minimums
      //int xyzMin[3];
      
      /// white matter peak
      float wmPeak;
      
      /// white matter threshold
      float wmThresh;
      
      ///
      float csfThresh;
      
      /// cgm peak
      float cgmPeak;
      
      /// 
      float cgmLow;
      
      /// 
      float cgmHigh;
      
      /// 
      float cgmSignum;
      
      /// 
      float inITPeak;
      
      /// 
      float inITLow;
      
      /// 
      float inITHigh;
      
      /// 
      float inITSignum;
      
      ///
      float outITPeak;
      
      /// 
      float outITLow;
      
      /// 
      float outITHigh;
      
      ///
      float outITSignum;
      
      /// padding voxel indices
      //int paddingIJK[6];
      
      /// structure
      Structure::STRUCTURE_TYPE structure;
      
      /// extract mask flag
      bool extractMaskFlag;
      
      /// 0=left, 1=right
      int Hem;
      
      /// ???
      int Hem1;
      
      /// ???
      int Hem2;
      
      /// ???
      int HemDbl;
      
      /// ??? 
      int Hem3;
      
      /// ??? 
      int xAClow;
      
      /// ??? 
      int xAChigh;
      
      /// ???
      int xAC_1;
      
      /// ???
      int xAC_1_low;
      
      /// ???
      int xAC_1_high;
      
      /// ???
      int xAC_10;
      
      /// ??? 
      int xAC_15;
      
      /// ???
      int xAC_20;
      
      /// ???
      int xAC_20_low;
      
      /// ???
      int xAC_20_high;
      
      /// ??? 
      int xAC_40;
      
      /// ??? 
      int xAC_15_40_low;
      
      /// ??? 
      int xAC_15_40_high;
      
      /// ??? 
      int xAC_50;
      
      /// ??? 
      int xMedLimit_50_low;
      
      /// ??? 
      int xMedLimit_50_high;
      
      /// ???
      int xMedLimit_20_low;
      
      /// ???
      int xMedLimit_20_high;
      
      /// ???
      int xMedLimit_low;
      
      /// ???
      int xMedLimit_high;
      
      /// Xmin from params file
      //int xMin;
      
      /// Ymin from params file
      //int yMin;
      
      /// Zmin from params file
      //int zMin;      
      
      /// segmentation debug files sub directory
      QString segmentationDebugFilesSubDirectory;
      
      /// partial hemisphere padding
      int partialHemispherePadding[6];
      
      /// type of volume files to write
      VolumeFile::FILE_READ_WRITE_TYPE typeOfVolumeFilesToWrite;
};

#endif // __BRAIN_MODEL_VOLUME_SEGMENTATION_H__