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
|
/*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 __VE_BRAIN_SURFACE_MULTIRESOLUTION_MORPHING_H__
#define __VE_BRAIN_SURFACE_MULTIRESOLUTION_MORPHING_H__
#include <QString>
#include <vector>
#include "BrainSetNodeAttribute.h"
#include "BrainModelSurface.h"
#include "BrainModelSurfaceMorphing.h"
#include "MultiResMorphFile.h"
#include "StatisticsUtilities.h"
#include "SurfaceShapeFile.h"
class BorderProjection;
class BrainModelSurface;
class CoordinateFile;
class TopologyFile;
/// class for measurements take while multiresolution morphing
class MorphingMeasurements {
public:
/// constructor
MorphingMeasurements(const QString& nameIn,
const StatisticsUtilities::DescriptiveStatistics& arealDistortionStatisticsIn,
const StatisticsUtilities::DescriptiveStatistics& linearDistortionStatisticsIn,
const int numberOfNodeCrossoversIn,
const int numberOfTileCrossoversIn,
const float elapsedTimeIn);
/// get the measurements
void get(QString& nameOut,
StatisticsUtilities::DescriptiveStatistics& arealDistortionStatisticsOut,
StatisticsUtilities::DescriptiveStatistics& linearDistortionStatisticsOut,
int& numberOfNodeCrossoversOut,
int& numberOfTileCrossoversOut,
float& elapsedTimeOut) const;
private:
/// name for this measurement
QString name;
/// areal distortion measurements
StatisticsUtilities::DescriptiveStatistics arealDistortionStatistics;
/// linear distortion measurements
StatisticsUtilities::DescriptiveStatistics linearDistortionStatistics;
/// number of node crossovers
int numberOfNodeCrossovers;
/// number of tile crossovers
int numberOfTileCrossovers;
/// time of cycle
float elapsedTime;
};
/// Class that performs multiresolution morphing on a brain surface
class BrainModelSurfaceMultiresolutionMorphing : public BrainModelAlgorithm {
public:
/// Constructor
BrainModelSurfaceMultiresolutionMorphing(BrainSet* brainSetIn,
BrainModelSurface* referenceSurfaceIn,
BrainModelSurface* morphingSurfaceIn,
const BrainModelSurfaceMorphing::MORPHING_SURFACE_TYPE morphingSurfaceTypeIn,
const BorderProjection* centralSulcusBorderProjectionIn = NULL);
/// Destructor
virtual ~BrainModelSurfaceMultiresolutionMorphing();
/// run the multiresolution morphing
virtual void execute() throw (BrainModelAlgorithmException);
/// copy the parameters to this morphing object
void copyParameters(const BrainModelSurfaceMultiresolutionMorphing& bmsm);
BrainModelSurfaceMorphing::MORPHING_SURFACE_TYPE
getMorphingSurfaceType() const { return morphingSurfaceType; }
/// get the surface measurements taken while morphing
void getMorphingMeasurements(std::vector<MorphingMeasurements>& mm) const
{ mm = measurements; }
/// get automatically save all created files
bool getAutoSaveAllFiles() const { return autoSaveFilesFlag; }
/// set automatically save all created files
void setAutoSaveAllFiles(const bool b) { autoSaveFilesFlag = b; }
/// get multi-res morph file that contains parameters for editing
MultiResMorphFile* getMultiResMorphParametersFile() {
return &this->multiResMorphFile;
}
/// get multi-res morph file that contains parameters for reading
const MultiResMorphFile* getMultiResMorphParametersFile() const {
return &this->multiResMorphFile;
}
protected:
enum {
SURFACE_FIDUCIAL_INDEX = 0,
SURFACE_MORPHED_INDEX = 1,
SURFACE_NOT_MORPHED_INDEX = 2
};
///
void constructTemplateSpheres(std::vector<BrainSet*>& brains)
throw (BrainModelAlgorithmException);
/// create the equilateral grid topology file
TopologyFile* createEquilateralGridTopology(BrainSet* brain, BrainModelSurface* surface);
void createSphereDownsampleMapping(std::vector<BrainSet*>& brains)
throw (BrainModelAlgorithmException);
/// downsample an equilateral grid surface
BrainSet* downsampleEquilateralGridSurface(BrainSet* brainIn);
/// measure surface distortions
void measureSurface(const int cycleNumber, const float elapsedTime);
/// create downsampled surface(s)
void multiresolutionDownsample(std::vector<BrainSet*>& brains);
/// perform the multi-resolution morphing
void multiresolutionMorph(std::vector<BrainSet*>& brains);
/// upsample fro a lower resolution to a higher resolution brain (spherical surface)
void sphericalUpsample(std::vector<BrainSet*>& brains,
const int targetBrainIndex)
throw (BrainModelAlgorithmException);
/// write the multi-resolution surfaces
void writeMultiresolutionSurfaces(std::vector<BrainSet*>& brains);
/// upsample from a lower resolution to higher resolution brain (float surface)
void flatUpsample(BrainSet* fromBrain,
BrainSet* toBrain,
BrainModelSurface* toSurface,
const bool backsampleFlag);
/// smooth to eliminate crossovers
void smoothOutCrossovers(BrainModelSurface* bms, const float sphereRadius);
/// setup file naming prefix and suffix
void setUpOutputFileNaming();
/// the reference surface
BrainModelSurface* referenceSurface;
/// the morphing surface
BrainModelSurface* morphingSurface;
/// type of surface being morphed
const BrainModelSurfaceMorphing::MORPHING_SURFACE_TYPE morphingSurfaceType;
/// central sulcus border projection for alignment
const BorderProjection* centralSulcusBorderProjection;
/// surface shape file used for distortion measurements
SurfaceShapeFile shapeMeasurementsFile;
/// intermediate files
std::vector<QString> intermediateFiles;
/// prefix of intermediate files names
QString intermediateFileNamePrefix[MultiResolutionMorphingCycle::MAXIMUM_NUMBER_OF_LEVELS];
/// prefix of intermediate coord files being morphed
QString intermediateCoordFileNamePrefix[MultiResolutionMorphingCycle::MAXIMUM_NUMBER_OF_LEVELS];
/// name of intermediate spec files
QString intermediateSpecFileNames[MultiResolutionMorphingCycle::MAXIMUM_NUMBER_OF_LEVELS];
/// name of original morphing surface coord file
QString origCoordFileName;
/// measurements take while morphing
std::vector<MorphingMeasurements> measurements;
/// output filename's prefix
QString outputFileNamePrefix;
/// output filename's suffix
QString outputFileNameSuffix;
/// the hemisphere being morphed
Structure::STRUCTURE_TYPE brainStruct;
/// surface type for crossover checks
BrainModelSurface::SURFACE_TYPES brainModelSurfaceType;
/// cycle currently being iterated
int currentCycle;
/// crossover smoothing strength
float crossoverSmoothStrength;
/// crossover smoothing cycles
int crossoverSmoothCycles;
/// crossover smoothing iterations per cycle
int crossoverSmoothIterations;
/// crossover smoothing edges every X iterations
int crossoverSmoothEdgeIterations;
/// crossover smoothing project to sphere every X iterations
int crossoverSmoothProjectToSphereIterations;
/// crossover smoothing neighbor depth
int crossoverSmoothNeighborDepth;
/// auto save all created files
bool autoSaveFilesFlag;
/// multi-res morph file contains parameters
MultiResMorphFile multiResMorphFile;
};
#endif // __VE_BRAIN_SURFACE_MULTIRESOLUTION_MORPHING_H__
|