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
|
#ifndef __BRAIN_MODEL_SURFACE_ROI_NODE_SELECTION_H__
#define __BRAIN_MODEL_SURFACE_ROI_NODE_SELECTION_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 <vector>
#include <QString>
#include "FileException.h"
class Border;
class BorderProjection;
class BrainModelBorderSet;
class BrainModelSurface;
class BrainSet;
class LatLonFile;
class MetricFile;
class NodeRegionOfInterestFile;
class PaintFile;
class SurfaceShapeFile;
class TopologyHelper;
/// class for selecting nodes in a region of interest
class BrainModelSurfaceROINodeSelection {
public:
/// logical selection (and, or, etc)
enum SELECTION_LOGIC {
/// normal selection (all existing selections are reset)
SELECTION_LOGIC_NORMAL,
/// logically AND (intersection) new and existing selections
SELECTION_LOGIC_AND,
/// logically OR (union) new and existing selections
SELECTION_LOGIC_OR,
/// new selections are AND'ed with opposite of existing selections
SELECTION_LOGIC_AND_NOT
};
// constructor
BrainModelSurfaceROINodeSelection(BrainSet* brainSetIn);
// copy constructor
BrainModelSurfaceROINodeSelection(const BrainModelSurfaceROINodeSelection& roi);
// Assignment operator.
BrainModelSurfaceROINodeSelection& operator=(const BrainModelSurfaceROINodeSelection& roi);
// destructor
~BrainModelSurfaceROINodeSelection();
// see if any nodes are selected
bool anyNodesSelected() const;
// get the selection status of a node
bool getNodeSelected(const int nodeNumber) const;
// set the selection status of a node
void setNodeSelected(const int nodeNumber,
const bool nodeSelectedFlag);
// get the number of nodes selected
int getNumberOfNodesSelected() const;
// get the number of nodes (count of all nodes regardless of selection status)
int getNumberOfNodes() const { return nodeSelectedFlags.size(); }
// get node in ROI flags
void getNodesInROI(std::vector<bool>& nodesAreInROI) const;
// set the ROI selection into file
void setRegionOfInterestIntoFile(NodeRegionOfInterestFile& nroi) const;
// get the ROI selection from file
void getRegionOfInterestFromFile(const NodeRegionOfInterestFile& nroi) throw (FileException);
// get the tiles that have at least one node in the ROI
void getTilesInRegionOfInterest(const BrainModelSurface* bms,
std::vector<int>& tilesInROI) const;
// get the nodes selection types and names
static void getNodeSelectionTypesAndNames(std::vector<SELECTION_LOGIC>& typesOut,
std::vector<QString>& namesOut);
// get display selected nodes
bool getDisplaySelectedNodes() const { return displaySelectedNodes; }
// set display selected nodes
void setDisplaySelectedNodes(const bool b) { displaySelectedNodes = b; }
// deselect all nodes
void deselectAllNodes();
// invert selected nodes
QString invertSelectedNodes(const BrainModelSurface* selectionSurface);
// get the extent of the selection
void getExtentOfSelectedNodes(const BrainModelSurface* bms,
float extentOut[6]) const;
// get the center of gravity of the selection
void getCenterOfGravityOfSelectedNodes(const BrainModelSurface* bms,
float cogOut[3]) const;
// get the nodes that have min/max x/y/z values
void getNodesWithMinMaxXYZValues(const BrainModelSurface* bms,
int& xMostMedial,
int& xMostLateral,
int& minXNode,
int& maxXNode,
int& minYNode,
int& maxYNode,
int& minZNode,
int& maxZNode,
int& absMinXNode,
int& absMaxXNode,
int& absMinYNode,
int& absMaxYNode,
int& absMinZNode,
int& absMaxZNode) const;
// get node with most lateral X Coordinate
int getNodeWithMostLateralXCoordinate(const BrainModelSurface* surface) const;
// get node with most medial X Coordinate
int getNodeWithMostMedialXCoordinate(const BrainModelSurface* surface) const;
// get node with minimum X Coordinate
int getNodeWithMinimumXCoordinate(const BrainModelSurface* surface) const;
// get node with maximum X Coordinate
int getNodeWithMaximumXCoordinate(const BrainModelSurface* surface) const;
// get node with minimum Y Coordinate
int getNodeWithMinimumYCoordinate(const BrainModelSurface* surface) const;
// get node with maximum Y Coordinate
int getNodeWithMaximumYCoordinate(const BrainModelSurface* surface) const;
// get node with minimum Z Coordinate
int getNodeWithMinimumZCoordinate(const BrainModelSurface* surface) const;
// get node with maximum Z Coordinate
int getNodeWithMaximumZCoordinate(const BrainModelSurface* surface) const;
// boundary only (keeps nodes in ROI that have at least one neighbor NOT in ROI)
void boundaryOnly(const BrainModelSurface* bms);
// dilate the selected nodes
void dilate(const BrainModelSurface* selectionSurface,
int numberOfIterations);
// dilate around the node (adds node's neighbors to ROI)
void dilateAroundNode(const BrainModelSurface* selectionSurface,
const int nodeNumber);
// dilate but only add nodes with selected paint
void dilatePaintConstrained(const BrainModelSurface* selectionSurface,
const PaintFile* paintFile,
const int paintColumnNumber,
const QString& paintName,
const int numberOfIterations);
// discard islands keeps the largest contiguous piece (returns number of islands removed)
int discardIslands(const BrainModelSurface* selectionSurface);
// discard islands with islands that have fewer than specified number of nodes
int discardIslands(const BrainModelSurface* selectionSurface,
const int minimumNumberOfNodesInIslandsKept);
// find islands (number of disjoint groups of nodes).
int findIslands(const BrainModelSurface* selectionSurface,
std::vector<int>& islandRootNode,
std::vector<int>& islandNumNodes,
std::vector<int>& nodeRootNeighbor);
// find islands and place each in an ROI
std::vector<BrainModelSurfaceROINodeSelection*> findIslands(const BrainModelSurface* selectionSurface);
// erode the selected nodes
void erode(const BrainModelSurface* selectionSurface,
int numberOfIterations);
// erode the selected nodes but maintain a connection between two nodes
void erodeButMaintainNodeConnection(const BrainModelSurface* selectionSurface,
int numberOfIterations,
const int node1,
const int node2);
// erode the selected nodes but maintain a connection between two nodes
void erodeButMaintainNodeConnection(const BrainModelSurface* selectionSurface,
const std::vector<int>& doNotErodeNodeFlags,
int numberOfIterations,
const int node1,
const int node2);
// expand the ROI so that these nodes are within the ROI and connected
void expandSoNodesAreWithinAndConnected(const BrainModelSurface* selectionSurface,
const int node1,
const int node2);
// find node int ROI nearest the XYZ
int getNearestNodeInROI(const BrainModelSurface* selectionSurface,
const float x, const float y, const float z) const;
// find node int ROI nearest the XYZ
int getNearestNodeInROI(const BrainModelSurface* selectionSurface,
const float xyz[3]) const;
// get the surface area of the ROI
float getSurfaceAreaOfROI(const BrainModelSurface* surface) const;
// limit the extent of the ROI
void limitExtent(const BrainModelSurface* selectionSurface,
const float extent[6]);
// exclude nodes in a region
void excludeNodesInRegion(const BrainModelSurface* selectionSurface,
const float regionExtent[6]);
// logically and this roi with another roi (returns error message)
QString logicallyAND(const BrainModelSurfaceROINodeSelection* otherROI);
// logically or this roi with another roi (returns error message)
QString logicallyOR(const BrainModelSurfaceROINodeSelection* otherROI);
// select all nodes (returns error message)
QString selectAllNodes(const BrainModelSurface* selectionSurface);
// select nodes that are edges
QString selectNodesThatAreEdges(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface);
// select nodes within geodesic distance
QString selectNodesWithinGeodesicDistance(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const int nodeNumber,
const float geodesicDistance);
// select nodes with paint (returns error message)
QString selectNodesWithPaint(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const PaintFile* pf,
const int paintFileColumnNumber,
const QString& paintName);
// select nodes within border (returns error message)
QString selectNodesWithinBorder(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const BrainModelSurface* flatSurface,
const BrainModelBorderSet* bmbs,
const QString& borderName);
// select nodes within border (returns error message)
QString selectNodesWithinBorderOnSphere(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* sphericalSurface,
const BorderProjection* borderProjection);
// select nodes within border (returns error message)
QString selectNodesWithinBorder(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const Border* border,
const bool surface3DFlag,
const float zMinimum = 0.0);
// select nodes within lat/long range (returns error message)
QString selectNodesWithLatLong(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const LatLonFile* latLonFile,
const int latLonFileColumnNumber,
const float minimumLatitude,
const float maximumLatitude,
const float minimumLongitude,
const float maximumLongitude);
// select nodes within metric range (returns error message)
QString selectNodesWithMetric(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const MetricFile* metricFile,
const int metricFileColumnNumber,
const float minimumMetricValue,
const float maximumMetricValue);
// select nodes within metric range and connected to specified node (returns error message)
QString selectConnectedNodesWithMetric(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const MetricFile* metricFile,
const int metricFileColumnNumber,
const float minimumMetricValue,
const float maximumMetricValue,
const int connectedToNodeNumber);
// select nodes within surface shape range (returns error message)
QString selectNodesWithSurfaceShape(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const SurfaceShapeFile* surfaceShapeFile,
const int surfaceShapeFileColumnNumber,
const float minimumShapeValue,
const float maximumShapeValue);
// select nodes within surface shape range and connected to specified node (returns error message)
QString selectConnectedNodesWithSurfaceShape(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
const SurfaceShapeFile* surfaceShapeFile,
const int surfaceShapeFileColumnNumber,
const float minimumShapeValue,
const float maximumShapeValue,
const int connectedToNodeNumber);
// select nodes that are crossovers (returns error message)
QString selectNodesThatAreCrossovers(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface);
// update (usually called if number of nodes changes)
void update();
// get the selection description
QString getSelectionDescription() const { return selectionDescription; }
protected:
// see if two nodes are connected in the ROI
bool areNodesConnected(const BrainModelSurface* bms,
const std::vector<int>& connectionFlags,
const int node1,
const int node2);
// get the topolgy helper for selection surface (returns NULL if unavailable)
const TopologyHelper* getSelectionSurfaceTopologyHelper(const BrainModelSurface* selectionSurface,
QString& errorMessageOut) const;
// process the new node selections (returns error message)
QString processNewNodeSelections(const SELECTION_LOGIC selectionLogic,
const BrainModelSurface* selectionSurface,
std::vector<int>& newNodeSelections,
const QString& description);
// add to the selection description
void addToSelectionDescription(const QString& selectionLogicText,
const QString& descriptionIn);
// copy helper used by copy constructor and assignment operator
void copyHelper(const BrainModelSurfaceROINodeSelection& roi);
/// the brain set
BrainSet* brainSet;
/// the node selection flags (ints should be faster than bools since bools packed into bits)
std::vector<int> nodeSelectedFlags;
/// display selected nodes
bool displaySelectedNodes;
/// selection description
QString selectionDescription;
// IF NEW MEMBERS ARE ADDED BE SURE TO UPDATE "coypHelper()"
};
#endif // __BRAIN_MODEL_SURFACE_ROI_NODE_SELECTION_H__
|