File: BorderUncertaintyToArealEstimationConverter.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 (167 lines) | stat: -rw-r--r-- 5,600 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
/*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*/

#ifndef __BORDER_UNCERTAINTY_TO_AREAL_ESTIMATION_CONVERTER_H__
#define __BORDER_UNCERTAINTY_TO_AREAL_ESTIMATION_CONVERTER_H__

#include <set>

#include "BrainModelAlgorithm.h"

class ArealEstimationFile;
class BorderFile;
class BrainModelSurface;
class PaintFile;

/// Class that creates an areal estimation file from border uncertainty
class BorderUncertaintyToArealEstimationConverter : public BrainModelAlgorithm {
   public:
      enum MODE {
         MODE_ALL_NODES,
         MODE_NODES_WITH_PAINT
      };
      
      /// Constructor
      BorderUncertaintyToArealEstimationConverter(
                                       BrainSet* bs,
                                       BrainModelSurface* surfaceIn,
                                       ArealEstimationFile* arealEstimationFileIn,
                                       BorderFile* borderFileIn,
                                       PaintFile* paintFileIn,
                                       const MODE modeIn,
                                       const int arealEstimationFileColumnIn,
                                       const QString& arealEstimationFileColumnNameIn,
                                       const QString& longNameIn,
                                       const QString& commentIn,
                                       const int paintColumnIn,
                                       const QString paintMatchNameIn,
                                       const bool overrideBorderUncertaintyIn,
                                       const float overrideBorderUncertaintyValueIn);
      
      /// Destructor
      ~BorderUncertaintyToArealEstimationConverter();
      
      /// execute the algorithm
      void execute() throw (BrainModelAlgorithmException);
      
   private:
      /// class to help with finding the nearest borders
      class BorderDist {
         public:
            int borderNumber;
            int borderNearestLink;
            float distanceToBorder;
            
            BorderDist(const int borderNumberIn,
                     const int borderNearestLinkIn,
                     const float distanceToBorderIn) {
               borderNumber = borderNumberIn;
               borderNearestLink = borderNearestLinkIn;
               distanceToBorder = distanceToBorderIn;
            }
            bool operator<(const BorderDist& b) const {
               if (distanceToBorder < b.distanceToBorder) {
                  return true;
               }
               if (distanceToBorder > b.distanceToBorder) {
                  return false;
               }
               if (borderNumber < b.borderNumber) {
                  return true;
               }
               return false;
            }
      };
      
      /// Class for sorting 4 borders with normalized probabilities
      class ProbabilitySort {
         public:
            QString name;
            float probability;
            ProbabilitySort(const QString& n, const float p) {
               name = n;
               probability = p;
            }
            bool operator<(const ProbabilitySort& p) const {   
               if (probability > p.probability) {
                  return true;
               }
               if (probability < p.probability) {
                  return false;
               }
               if (name.compare(p.name) < 0) {
                  return true;
               }
               return false;
            }
      };
      
      float determineSignedDistance(const float* pos, const BorderDist& bd);
           
      void findClosestBorderLinks2D(const float* pos, std::set<BorderDist>& closestBorders);
      
                                                   
      /// the areal estimation file
      ArealEstimationFile* arealEstimationFile;
      
      /// column in the areal estimation file
      int arealEstimationFileColumn;
      
      /// name of areal estimation file column
      QString arealEstimationFileColumnName;
      
      /// the paint file
      PaintFile* paintFile;
      
      /// the paint column
      int paintColumn;
      
      /// the border file
      BorderFile* borderFile;
      
      /// paint name to match
      QString paintMatchName;
      
      /// long name for column
      QString longName;
      
      /// comment for column
      QString comment;
      
      /// the surface used 
      BrainModelSurface* surface;
      
      /// mode 
      MODE mode;
      
      /// override border file uncertainties
      bool overrideBorderUncertainty;
      
      /// border override uncertainty value
      float overrideBorderUncertaintyValue;
};

#endif // __BORDER_UNCERTAINTY_TO_AREAL_ESTIMATION_CONVERTER_H__