Slicer
4.10
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
|
This class encapsulates a segmentation that can contain multiple segments and multiple representations for each segment. More...
#include <Libs/vtkSegmentationCore/vtkSegmentation.h>
Public Types | |
enum | { MasterRepresentationModified = 62100, RepresentationModified, SegmentAdded, SegmentRemoved, SegmentModified, ContainedRepresentationNamesModified, SegmentsOrderModified } |
enum | { EXTENT_REFERENCE_GEOMETRY, EXTENT_UNION_OF_SEGMENTS, EXTENT_UNION_OF_SEGMENTS_PADDED, EXTENT_UNION_OF_EFFECTIVE_SEGMENTS, EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_PADDED } |
typedef std::map< std::string, vtkSmartPointer< vtkSegment > > | SegmentMap |
Container type for segments. Maps segment IDs to segment objects. More... | |
typedef vtkObject | Superclass |
Public Member Functions | |
std::string | AddEmptySegment (std::string segmentId="", std::string segmentName="", double color[3]=NULL) |
bool | AddSegment (vtkSegment *segment, std::string segmentId="", std::string insertBeforeSegmentId="") |
virtual void | ApplyLinearTransform (vtkAbstractTransform *transform) |
virtual void | ApplyNonLinearTransform (vtkAbstractTransform *transform) |
bool | CanAcceptRepresentation (std::string representationName) |
bool | CanAcceptSegment (vtkSegment *segment) |
bool | ContainsRepresentation (std::string representationName) |
virtual void | CopyConversionParameters (vtkSegmentation *aSegmentation) |
Copy conversion parameters from another segmentation. More... | |
bool | CopySegmentFromSegmentation (vtkSegmentation *fromSegmentation, std::string segmentId, bool removeFromSource=false) |
bool | CreateRepresentation (const std::string &targetRepresentationName, bool alwaysConvert=false) |
bool | CreateRepresentation (vtkSegmentationConverter::ConversionPathType path, vtkSegmentationConverterRule::ConversionParameterListType parameters) |
virtual void | DeepCopy (vtkSegmentation *aSegmentation) |
Deep copy one segmentation into another. More... | |
void | DeserializeConversionParameters (std::string conversionParametersString) |
void | DetermineCommonLabelmapExtent (int commonGeometryExtent[6], vtkOrientedImageData *commonGeometryImage, const std::vector< std::string > &segmentIDs=std::vector< std::string >(), bool computeEffectiveExtent=false, bool addPadding=false) |
void | DetermineCommonLabelmapExtent (int commonGeometryExtent[6], vtkOrientedImageData *commonGeometryImage, vtkStringArray *segmentIds, bool computeEffectiveExtent=false, bool addPadding=false) |
Determine common labelmap extent for whole segmentation, for python compatibility. More... | |
std::string | DetermineCommonLabelmapGeometry (int extentComputationMode=EXTENT_UNION_OF_SEGMENTS, const std::vector< std::string > &segmentIDs=std::vector< std::string >()) |
std::string | DetermineCommonLabelmapGeometry (int extentComputationMode, vtkStringArray *segmentIds) |
Determine common labelmap geometry for whole segmentation, for python compatibility. More... | |
std::string | GenerateUniqueSegmentID (std::string id) |
void | GetAvailableRepresentationNames (std::set< std::string > &representationNames) |
Get all representations supported by the converter. More... | |
virtual void | GetBounds (double bounds[6]) |
Get bounding box in global RAS in the form (xmin,xmax, ymin,ymax, zmin,zmax). More... | |
virtual const char * | GetClassName () |
void | GetContainedRepresentationNames (std::vector< std::string > &representationNames) |
std::string | GetConversionParameter (const std::string &name) |
void | GetConversionParametersForPath (vtkSegmentationConverterRule::ConversionParameterListType &conversionParameters, const vtkSegmentationConverter::ConversionPathType &path) |
Get names of all conversion parameters used by the selected conversion path. More... | |
virtual std::string | GetMasterRepresentationName () |
Get master representation name. More... | |
vtkSegment * | GetNthSegment (unsigned int index) const |
Request segment by index. More... | |
std::string | GetNthSegmentID (unsigned int index) const |
Get n-th segment ID. Return with "" if no segment is found by that index. More... | |
int | GetNumberOfSegments () const |
Request the total number of segments, primarily used for iterating over all segments. More... | |
void | GetPossibleConversions (const std::string &targetRepresentationName, vtkSegmentationConverter::ConversionPathAndCostListType &pathsCosts) |
Get all possible conversions between the master representation and a specified target representation. More... | |
vtkSegment * | GetSegment (std::string segmentId) |
std::string | GetSegmentIdBySegment (vtkSegment *segment) |
std::string | GetSegmentIdBySegmentName (std::string name) |
void | GetSegmentIDs (std::vector< std::string > &segmentIds) |
Get IDs for all contained segments. More... | |
void | GetSegmentIDs (vtkStringArray *segmentIds) |
Get IDs for all contained segments, for python compatibility. More... | |
int | GetSegmentIndex (const std::string &segmentId) |
vtkDataObject * | GetSegmentRepresentation (std::string segmentId, std::string representationName) |
Get representation from segment. More... | |
std::vector< vtkSegment * > | GetSegmentsByTag (std::string tag, std::string value="") |
void | InvalidateNonMasterRepresentations () |
Invalidate (remove) non-master representations in all the segments if this segmentation node. More... | |
virtual int | IsA (const char *type) |
bool | IsMasterRepresentationImageData () |
Determine if master representation is (oriented) image data type. More... | |
bool | IsMasterRepresentationPolyData () |
Determine if master representation is poly data type. More... | |
void | PrintSelf (ostream &os, vtkIndent indent) VTK_OVERRIDE |
virtual void | ReadXMLAttributes (const char **atts) |
Set attributes from name/value pairs. More... | |
void | RemoveAllSegments () |
Remove all segments. More... | |
void | RemoveRepresentation (const std::string &representationName) |
Removes a representation from all segments if present. More... | |
void | RemoveSegment (std::string segmentId) |
void | RemoveSegment (vtkSegment *segment) |
void | ReorderSegments (std::vector< std::string > segmentIdsToMove, std::string insertBeforeSegmentId="") |
std::string | SerializeAllConversionParameters () |
void | SetConversionParameter (const std::string &name, const std::string &value) |
Set a conversion parameter to all rules having this parameter. More... | |
bool | SetImageGeometryFromCommonLabelmapGeometry (vtkOrientedImageData *imageData, vtkStringArray *segmentIDs=NULL, int extentComputationMode=vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS) |
virtual void | SetMasterRepresentationName (const std::string &representationName) |
bool | SetSegmentIndex (const std::string &segmentId, unsigned int newIndex) |
virtual void | WriteXML (ostream &of, int indent) |
Write this object's information to a MRML file in XML format. More... | |
Static Public Member Functions | |
static int | IsTypeOf (const char *type) |
static vtkSegmentation * | New () |
static vtkSegmentation * | SafeDownCast (vtkObject *o) |
Protected Member Functions | |
bool | ConvertSegmentUsingPath (vtkSegment *segment, vtkSegmentationConverter::ConversionPathType path, bool overwriteExisting=false) |
bool | ConvertSingleSegment (std::string segmentId, std::string targetRepresentationName) |
Converts a single segment to a representation. More... | |
void | operator= (const vtkSegmentation &) |
void | RemoveSegment (SegmentMap::iterator segmentIt) |
bool | SetMasterRepresentationModifiedEnabled (bool enabled) |
bool | SetSegmentModifiedEnabled (bool enabled) |
vtkSegmentation () | |
~vtkSegmentation () | |
Static Protected Member Functions | |
static void | OnMasterRepresentationModified (vtkObject *caller, unsigned long eid, void *clientData, void *callData) |
static void | OnSegmentModified (vtkObject *caller, unsigned long eid, void *clientData, void *callData) |
Protected Attributes | |
vtkSegmentationConverter * | Converter |
Converter instance. More... | |
vtkCallbackCommand * | MasterRepresentationCallbackCommand |
Command handling master representation modified events. More... | |
bool | MasterRepresentationModifiedEnabled |
Modified events of master representations are observed. More... | |
std::string | MasterRepresentationName |
vtkCallbackCommand * | SegmentCallbackCommand |
Command handling segment modified events. More... | |
int | SegmentIdAutogeneratorIndex |
std::deque< std::string > | SegmentIds |
bool | SegmentModifiedEnabled |
Modified events of segments are observed. More... | |
SegmentMap | Segments |
Container of segments that belong to this segmentation. More... | |
Friends | |
class | qMRMLSegmentEditorWidgetPrivate |
class | vtkMRMLSegmentationNode |
class | vtkSlicerSegmentationsModuleLogic |
This class encapsulates a segmentation that can contain multiple segments and multiple representations for each segment.
The primary purpose of this class is to serve as a container to store the segments (in labelmap analogy the "labels"). Also provides generic functions on the segmentation level. Performs conversion to a specified representation, extracts geometry information etc.
Main points to remember:
Schematic illustration of the segmentation container:
+=============================================+ | Patient (vtkSegmentation) | +======================+======================+ | Brain (vtkSegment) | Tumor (vtkSegment) | +======================+======================+ Binary labelmap | vtkOrientedImageData | vtkOrientedImageData | +----------------------+----------------------+ Closed surface | vtkPolyData | vtkPolyData | +----------------------+----------------------+ Custom representation | vtkDataObject | vtkDataObject | +----------------------+----------------------+
Definition at line 89 of file vtkSegmentation.h.
typedef std::map<std::string, vtkSmartPointer<vtkSegment> > vtkSegmentation::SegmentMap |
Container type for segments. Maps segment IDs to segment objects.
Definition at line 126 of file vtkSegmentation.h.
typedef vtkObject vtkSegmentation::Superclass |
Definition at line 130 of file vtkSegmentation.h.
anonymous enum |
Definition at line 92 of file vtkSegmentation.h.
anonymous enum |
Definition at line 111 of file vtkSegmentation.h.
|
protected |
|
protected |
std::string vtkSegmentation::AddEmptySegment | ( | std::string | segmentId = "" , |
std::string | segmentName = "" , |
||
double | color[3] = NULL |
||
) |
Add empty segment containing empty instances of the contained representations
segmentId | ID of added segment. If empty then a default ID will be generated |
segmentName | name of added segment. If empty then the segmentId will be used as name. |
color | of added segment. If not specified then empty then vtkSegment::SEGMENT_COLOR_INVALID is used. |
bool vtkSegmentation::AddSegment | ( | vtkSegment * | segment, |
std::string | segmentId = "" , |
||
std::string | insertBeforeSegmentId = "" |
||
) |
Add a segment to this segmentation, do necessary conversions, and observe underlying data for changes. Necessary conversions:
segment | the segment to observe |
insertBeforeSegmentId | if specified then the segment is inserted before insertBeforeSegmentId |
|
virtual |
Apply a linear transform on the master representation of the segments. The others will be invalidated Harden transform if poly data, apply to directions if oriented image data.
|
virtual |
Apply a non-linear transform on the master representation of the segments. The others will be invalidated Harden transform both if oriented image data and poly data.
bool vtkSegmentation::CanAcceptRepresentation | ( | std::string | representationName | ) |
Determine if the segmentation is ready to accept a certain type of representation by copy/move or import. It can accept a representation if it is the master representation of this segment or it is possible to convert to master representation (or the segmentation is empty).
bool vtkSegmentation::CanAcceptSegment | ( | vtkSegment * | segment | ) |
Determine if the segmentation is ready to accept a certain segment. It can accept a segment if it contains a representation that is acceptable, or if it is empty.
bool vtkSegmentation::ContainsRepresentation | ( | std::string | representationName | ) |
Determine if segments contain a certain representation type Note: This assumes the first segment contains the same type of representations as all segments (this should be the case by design)
|
protected |
Convert given segment along a specified path
segment | Segment to convert |
path | Path to do the conversion along |
overwriteExisting | If true then do each conversion step regardless the target representation exists. If false then skip those conversion steps that would overwrite existing representation |
|
protected |
Converts a single segment to a representation.
|
virtual |
Copy conversion parameters from another segmentation.
bool vtkSegmentation::CopySegmentFromSegmentation | ( | vtkSegmentation * | fromSegmentation, |
std::string | segmentId, | ||
bool | removeFromSource = false |
||
) |
Copy segment from one segmentation to this one
fromSegmentation | Source segmentation |
segmentId | ID of segment to copy |
removeFromSource | If true, then delete segment from source segmentation after copying. Default value is false. |
bool vtkSegmentation::CreateRepresentation | ( | const std::string & | targetRepresentationName, |
bool | alwaysConvert = false |
||
) |
Create a representation in all segments, using the conversion path with the lowest cost. The stored conversion parameters are used (which are the defaults if not changed by the user). Conversion starts from the master representation. If a representation along the path already exists then no conversion is performed. Note: The conversion functions are not in vtkSegmentationConverter, because they need to know about the master representation which is segmentation- specific, and also to allow optimizations (steps before per-segment conversion).
targetRepresentationName | Name of the representation to create |
alwaysConvert | If true, then conversion takes place even if target representation exists. False by default. |
bool vtkSegmentation::CreateRepresentation | ( | vtkSegmentationConverter::ConversionPathType | path, |
vtkSegmentationConverterRule::ConversionParameterListType | parameters | ||
) |
Generate or update a representation in all segments, using the specified conversion path and parameters. Conversion starts from the master representation, and all representations along the path get overwritten.
|
virtual |
Deep copy one segmentation into another.
void vtkSegmentation::DeserializeConversionParameters | ( | std::string | conversionParametersString | ) |
Parse conversion parameters in string and set it to the segmentation converter Such a string can be constructed in a segmentation object using /sa SerializeAllConversionParameters
void vtkSegmentation::DetermineCommonLabelmapExtent | ( | int | commonGeometryExtent[6], |
vtkOrientedImageData * | commonGeometryImage, | ||
const std::vector< std::string > & | segmentIDs = std::vector< std::string >() , |
||
bool | computeEffectiveExtent = false , |
||
bool | addPadding = false |
||
) |
Determine common labelmap extent for whole segmentation.
commonGeometryExtent | Computed extent that contains all the specified segments. |
commonGeometryImage | Extent will be returned in this image geometry |
segmentIDs | List of IDs of segments to include in the merged labelmap. If empty or missing, then all segments are included |
computeEffectiveExtent | Specifies if the extent of a segment is the whole extent or the effective extent (where voxel values >0 found) |
void vtkSegmentation::DetermineCommonLabelmapExtent | ( | int | commonGeometryExtent[6], |
vtkOrientedImageData * | commonGeometryImage, | ||
vtkStringArray * | segmentIds, | ||
bool | computeEffectiveExtent = false , |
||
bool | addPadding = false |
||
) |
Determine common labelmap extent for whole segmentation, for python compatibility.
std::string vtkSegmentation::DetermineCommonLabelmapGeometry | ( | int | extentComputationMode = EXTENT_UNION_OF_SEGMENTS , |
const std::vector< std::string > & | segmentIDs = std::vector< std::string >() |
||
) |
Determine common labelmap geometry for whole segmentation. If the segmentation has reference image geometry conversion parameter, then oversample it to be at least as fine resolution as the highest resolution labelmap contained, otherwise just use the geometry of the highest resolution labelmap in the segments.
extentComputationMode | Determines how to compute extents (EXTENT_REFERENCE_GEOMETRY, EXTENT_UNION_OF_SEGMENTS, EXTENT_UNION_OF_SEGMENTS_PADDED, EXTENT_UNION_OF_EFFECTIVE_SEGMENTS, or EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_PADDED). |
segmentIDs | List of IDs of segments to include in the merged labelmap. If empty or missing, then all segments are included |
std::string vtkSegmentation::DetermineCommonLabelmapGeometry | ( | int | extentComputationMode, |
vtkStringArray * | segmentIds | ||
) |
Determine common labelmap geometry for whole segmentation, for python compatibility.
std::string vtkSegmentation::GenerateUniqueSegmentID | ( | std::string | id | ) |
Generate unique segment ID. If argument is empty then a new ID will be generated in the form "Segment_", where N is the number of segments. If argument is unique it is returned unchanged. If there is a segment with the given name, then it is postfixed by a number to make it unique.
|
inline |
Get all representations supported by the converter.
Definition at line 302 of file vtkSegmentation.h.
|
virtual |
Get bounding box in global RAS in the form (xmin,xmax, ymin,ymax, zmin,zmax).
|
virtual |
void vtkSegmentation::GetContainedRepresentationNames | ( | std::vector< std::string > & | representationNames | ) |
Get representation names present in this segmentation in an output string vector Note: This assumes the first segment contains the same type of representations as all segments (this should be the case by design)
|
inline |
Get a conversion parameter from first rule containing this parameter Note: all parameters with the same name should contain the same value
Definition at line 358 of file vtkSegmentation.h.
|
inline |
Get names of all conversion parameters used by the selected conversion path.
Definition at line 361 of file vtkSegmentation.h.
|
virtual |
Get master representation name.
vtkSegment* vtkSegmentation::GetNthSegment | ( | unsigned int | index | ) | const |
Request segment by index.
std::string vtkSegmentation::GetNthSegmentID | ( | unsigned int | index | ) | const |
Get n-th segment ID. Return with "" if no segment is found by that index.
int vtkSegmentation::GetNumberOfSegments | ( | ) | const |
Request the total number of segments, primarily used for iterating over all segments.
void vtkSegmentation::GetPossibleConversions | ( | const std::string & | targetRepresentationName, |
vtkSegmentationConverter::ConversionPathAndCostListType & | pathsCosts | ||
) |
Get all possible conversions between the master representation and a specified target representation.
vtkSegment* vtkSegmentation::GetSegment | ( | std::string | segmentId | ) |
Access a segment by ID
segmentId | Segment identifier in the container to access |
std::string vtkSegmentation::GetSegmentIdBySegment | ( | vtkSegment * | segment | ) |
Find segment ID by segment instance Returns empty string if segment is not found.
std::string vtkSegmentation::GetSegmentIdBySegmentName | ( | std::string | name | ) |
Find segment ID by segment name. Search is case-insensitive. If multiple segments have the same name, the first match is returned. Returns empty string if segment is not found.
void vtkSegmentation::GetSegmentIDs | ( | std::vector< std::string > & | segmentIds | ) |
Get IDs for all contained segments.
void vtkSegmentation::GetSegmentIDs | ( | vtkStringArray * | segmentIds | ) |
Get IDs for all contained segments, for python compatibility.
int vtkSegmentation::GetSegmentIndex | ( | const std::string & | segmentId | ) |
Get index of segment in the SegmentID list. Returns -1 if the segment ID is not in the SegmentID list.
vtkDataObject* vtkSegmentation::GetSegmentRepresentation | ( | std::string | segmentId, |
std::string | representationName | ||
) |
Get representation from segment.
std::vector<vtkSegment*> vtkSegmentation::GetSegmentsByTag | ( | std::string | tag, |
std::string | value = "" |
||
) |
Get segments that contain a certain tag
tag | Tag name to look for in segments |
value | Tag value to look for in segments. If omitted or empty then any value is accepted |
void vtkSegmentation::InvalidateNonMasterRepresentations | ( | ) |
Invalidate (remove) non-master representations in all the segments if this segmentation node.
|
virtual |
bool vtkSegmentation::IsMasterRepresentationImageData | ( | ) |
Determine if master representation is (oriented) image data type.
bool vtkSegmentation::IsMasterRepresentationPolyData | ( | ) |
Determine if master representation is poly data type.
|
static |
|
static |
|
staticprotected |
Callback function observing the master representation of each segment It fires a
|
staticprotected |
Callback function invoked when segment is modified. It calls Modified on the segmentation and rebuilds observations on the master representation of each segment
|
protected |
void vtkSegmentation::PrintSelf | ( | ostream & | os, |
vtkIndent | indent | ||
) |
|
virtual |
Set attributes from name/value pairs.
void vtkSegmentation::RemoveAllSegments | ( | ) |
Remove all segments.
void vtkSegmentation::RemoveRepresentation | ( | const std::string & | representationName | ) |
Removes a representation from all segments if present.
void vtkSegmentation::RemoveSegment | ( | std::string | segmentId | ) |
Remove a segment by ID
segmentId | Identifier of the segment to remove from the segmentation |
void vtkSegmentation::RemoveSegment | ( | vtkSegment * | segment | ) |
Remove a segment by value
segment | the segment to remove from the segmentation |
|
protected |
Remove segment by iterator. The two
void vtkSegmentation::ReorderSegments | ( | std::vector< std::string > | segmentIdsToMove, |
std::string | insertBeforeSegmentId = "" |
||
) |
Reorder segment IDs so that the list of segment IDs are moved from their current position and inserted after the specified segment. If insertBeforeSegmentId is empty then segments are moved to the end of the segment list.
|
static |
std::string vtkSegmentation::SerializeAllConversionParameters | ( | ) |
Serialize all conversion parameters. The resulting string can be parsed in a segmentation object using /sa DeserializeConversionParameters
|
inline |
Set a conversion parameter to all rules having this parameter.
Definition at line 354 of file vtkSegmentation.h.
bool vtkSegmentation::SetImageGeometryFromCommonLabelmapGeometry | ( | vtkOrientedImageData * | imageData, |
vtkStringArray * | segmentIDs = NULL , |
||
int | extentComputationMode = vtkSegmentation::EXTENT_UNION_OF_EFFECTIVE_SEGMENTS |
||
) |
Updates image geometry (origin, spacing, axis directions, extents) based on labelmaps stored in the segmentation. Does not allocate memory (to allow just retrieving geometry information without using memory).
|
protected |
Temporarily enable/disable master representation modified event.
|
virtual |
Set master representation name. Need to make sure before setting the name that the newly set master representation exists in the segmentation! Use
bool vtkSegmentation::SetSegmentIndex | ( | const std::string & | segmentId, |
unsigned int | newIndex | ||
) |
Changes segment order. Segment order may be used for display and generating merged labelmaps.
|
protected |
Temporarily enable/disable segment modified event.
|
virtual |
Write this object's information to a MRML file in XML format.
|
friend |
Definition at line 459 of file vtkSegmentation.h.
|
friend |
Definition at line 457 of file vtkSegmentation.h.
|
friend |
Definition at line 458 of file vtkSegmentation.h.
|
protected |
Converter instance.
Definition at line 434 of file vtkSegmentation.h.
|
protected |
Command handling master representation modified events.
Definition at line 440 of file vtkSegmentation.h.
|
protected |
Modified events of master representations are observed.
Definition at line 443 of file vtkSegmentation.h.
|
protected |
Master representation type name.
Definition at line 431 of file vtkSegmentation.h.
|
protected |
Command handling segment modified events.
Definition at line 437 of file vtkSegmentation.h.
|
protected |
This number is incremented and used for generating the next segment ID.
Definition at line 450 of file vtkSegmentation.h.
|
protected |
This contains the segment IDs in display order. (we could retrieve segment IDs from SegmentMap too, but that always contains segments in alphabetical order)
Definition at line 455 of file vtkSegmentation.h.
|
protected |
Modified events of segments are observed.
Definition at line 446 of file vtkSegmentation.h.
|
protected |
Container of segments that belong to this segmentation.
Definition at line 425 of file vtkSegmentation.h.