Slicer 5.8
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
Loading...
Searching...
No Matches
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Friends
vtkSegmentation Class Reference

This class encapsulates a segmentation that can contain multiple segments and multiple representations for each segment. More...

#include <Libs/vtkSegmentationCore/vtkSegmentation.h>

Inheritance diagram for vtkSegmentation:
Inheritance graph
[legend]
Collaboration diagram for vtkSegmentation:
Collaboration graph
[legend]

Public Types

enum  {
  SourceRepresentationModified = 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 , EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_AND_REFERENCE_GEOMETRY
}
 
typedef std::map< std::string, vtkSmartPointer< vtkSegment > > SegmentMap
 Container type for segments. Maps segment IDs to segment objects.
 
typedef vtkObject Superclass
 

Public Member Functions

std::string AddEmptySegment (std::string segmentId="", std::string segmentName="", double color[3]=nullptr)
 
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)
 
void ClearSegment (std::string segmentId)
 
void CollapseBinaryLabelmaps (bool forceToSingleLayer=false)
 
bool ContainsRepresentation (std::string representationName)
 
virtual void CopyConversionParameters (vtkSegmentation *aSegmentation)
 Copy conversion parameters from another segmentation.
 
bool CopySegmentFromSegmentation (vtkSegmentation *fromSegmentation, std::string segmentId, bool removeFromSource=false)
 
bool CreateRepresentation (const std::string &targetRepresentationName, bool alwaysConvert=false)
 
bool CreateRepresentation (vtkSegmentationConversionPath *path, vtkSegmentationConversionParameters *parameters)
 
virtual void DeepCopy (vtkSegmentation *aSegmentation)
 Deep copy one segmentation into another.
 
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.
 
std::string DetermineCommonLabelmapGeometry (int extentComputationMode, vtkStringArray *segmentIds)
 Determine common labelmap geometry for whole segmentation, for python compatibility.
 
std::string DetermineCommonLabelmapGeometry (int extentComputationMode=EXTENT_UNION_OF_SEGMENTS, const std::vector< std::string > &segmentIDs=std::vector< std::string >())
 
bool GenerateMergedLabelmap (vtkOrientedImageData *mergedImageData, int extentComputationMode, vtkOrientedImageData *mergedLabelmapGeometry=nullptr, const std::vector< std::string > &segmentIDs=std::vector< std::string >(), vtkIntArray *labelValues=nullptr)
 Merged labelmap functions.
 
std::string GenerateUniqueSegmentID (std::string id="")
 
void GetAvailableRepresentationNames (std::set< std::string > &representationNames)
 Get all representations supported by the converter.
 
virtual void GetBounds (double bounds[6])
 Get bounding box in global RAS in the form (xmin,xmax, ymin,ymax, zmin,zmax).
 
virtual const char * GetClassName ()
 
void GetContainedRepresentationNames (std::vector< std::string > &representationNames)
 
std::string GetConversionParameter (const std::string &name)
 
void GetConversionParametersForPath (vtkSegmentationConversionParameters *conversionParameters, vtkSegmentationConversionPath *path)
 Get names of all conversion parameters used by the selected conversion path.
 
vtkDataObject * GetLayerDataObject (int layer, std::string representationName="")
 
int GetLayerIndex (std::string segmentId, std::string representationName="")
 
void GetLayerObjects (vtkCollection *layerObjects, std::string representationName="")
 
virtual std::string GetMasterRepresentationName ()
 
vtkSegmentGetNthSegment (unsigned int index) const
 Request segment by index.
 
std::string GetNthSegmentID (unsigned int index) const
 Get n-th segment ID. Return with "" if no segment is found by that index.
 
int GetNumberOfLayers (std::string representationName="")
 Shared representation layer functions.
 
int GetNumberOfSegments () const
 Request the total number of segments, primarily used for iterating over all segments.
 
void GetPossibleConversions (const std::string &targetRepresentationName, vtkSegmentationConversionPaths *paths)
 Get all possible conversions between the source representation and a specified target representation.
 
vtkSegmentGetSegment (std::string segmentId)
 
std::string GetSegmentIdBySegment (vtkSegment *segment)
 
std::string GetSegmentIdBySegmentName (std::string name)
 
std::vector< std::string > GetSegmentIDs ()
 Get IDs for all contained segments, for python compatibility.
 
void GetSegmentIDs (std::vector< std::string > &segmentIds)
 Get IDs for all contained segments.
 
void GetSegmentIDs (vtkStringArray *segmentIds)
 Get IDs for all contained segments, for python compatibility.
 
std::vector< std::string > GetSegmentIDsForDataObject (vtkDataObject *dataObject, std::string representationName="")
 
std::vector< std::string > GetSegmentIDsForLayer (int layer, std::string representationName="")
 
void GetSegmentIDsSharingBinaryLabelmapRepresentation (std::string originalSegmentId, std::vector< std::string > &sharedSegmentIds, bool includeOriginalSegmentId=true)
 
void GetSegmentIDsSharingRepresentation (std::string originalSegmentId, std::string representationName, std::vector< std::string > &sharedSegmentIds, bool includeOriginalSegmentId=true)
 
int GetSegmentIndex (const std::string &segmentId)
 
vtkDataObject * GetSegmentRepresentation (std::string segmentId, std::string representationName)
 Get representation from segment.
 
std::vector< vtkSegment * > GetSegmentsByTag (std::string tag, std::string value="")
 
virtual std::string GetSourceRepresentationName ()
 Get source representation name.
 
int GetUniqueLabelValueForSharedLabelmap (std::string segmentId)
 
int GetUniqueLabelValueForSharedLabelmap (vtkOrientedImageData *labelmap)
 
virtual bool GetUUIDSegmentIDs ()
 
void InvalidateNonMasterRepresentations ()
 
void InvalidateNonSourceRepresentations ()
 Invalidate (remove) non-source representations in all the segments if this segmentation node.
 
virtual int IsA (const char *type)
 
bool IsMasterRepresentationImageData ()
 
bool IsMasterRepresentationPolyData ()
 
bool IsSharedBinaryLabelmap (std::string segmentID)
 Shared labelmap utility functions.
 
bool IsSourceRepresentationImageData ()
 Determine if source representation is (oriented) image data type.
 
bool IsSourceRepresentationPolyData ()
 Determine if source representation is poly data type.
 
void MergeSegmentLabelmaps (std::vector< std::string > mergeSegmentIds)
 
void PrintSelf (ostream &os, vtkIndent indent) override
 
virtual void ReadXMLAttributes (const char **atts)
 Set attributes from name/value pairs.
 
void RemoveAllSegments ()
 Remove all segments.
 
void RemoveRepresentation (const std::string &representationName)
 Removes a representation from all segments if present.
 
void RemoveSegment (std::string segmentId)
 
void RemoveSegment (vtkSegment *segment)
 
void ReorderSegments (std::vector< std::string > segmentIdsToMove, std::string insertBeforeSegmentId="")
 
void SeparateSegmentLabelmap (std::string segmentId)
 Moves an existing segment from a shared labelmap into a separate labelmap containing only the specified segment.
 
std::string SerializeAllConversionParameters ()
 
void SetConversionParameter (const std::string &name, const std::string &value)
 Set a conversion parameter to all rules having this parameter.
 
bool SetImageGeometryFromCommonLabelmapGeometry (vtkOrientedImageData *imageData, vtkStringArray *segmentIDs=nullptr, 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 SetSourceRepresentationName (const std::string &representationName)
 
virtual void SetUUIDSegmentIDs (bool)
 
virtual void UUIDSegmentIDsOff ()
 
virtual void UUIDSegmentIDsOn ()
 
virtual void WriteXML (ostream &of, int indent)
 Write this object's information to a MRML file in XML format.
 

Static Public Member Functions

static void CopySegment (vtkSegment *destination, vtkSegment *source, vtkSegment *baseline, std::map< vtkDataObject *, vtkDataObject * > &cachedRepresentations)
 
static vtkMinimalStandardRandomSequence * GetSegmentIDRandomSequenceInstance ()
 
static int IsTypeOf (const char *type)
 
static vtkSegmentationNew ()
 
static vtkSegmentationSafeDownCast (vtkObject *o)
 

Protected Member Functions

bool ConvertSegmentsUsingPath (std::vector< std::string > segmentIDs, vtkSegmentationConversionPath *path, bool overwriteExisting=false)
 
bool ConvertSegmentUsingPath (vtkSegment *segment, vtkSegmentationConversionPath *path, bool overwriteExisting=false)
 
bool ConvertSingleSegment (std::string segmentId, std::string targetRepresentationName)
 Converts a single segment to a representation.
 
std::string GenerateUniqueSegmentName (std::string base)
 
void RemoveSegment (SegmentMap::iterator segmentIt)
 
bool SetSegmentModifiedEnabled (bool enabled)
 
bool SetSourceRepresentationModifiedEnabled (bool enabled)
 
void UpdateSourceRepresentationObservers ()
 
 vtkSegmentation ()
 
 ~vtkSegmentation () override
 

Static Protected Member Functions

static void classFinalize ()
 
static void classInitialize ()
 Singleton management functions.
 
static std::string GenerateRandomSegmentID (int suffixLength, std::string validCharacters="")
 
static std::string GenerateUUIDDerivedUID ()
 
static void OnSegmentModified (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 
static void OnSourceRepresentationModified (vtkObject *caller, unsigned long eid, void *clientData, void *callData)
 

Protected Attributes

vtkSegmentationConverterConverter
 Converter instance.
 
vtkCallbackCommand * SegmentCallbackCommand
 Command handling segment modified events.
 
int SegmentIdAutogeneratorIndex
 
std::deque< std::string > SegmentIds
 
bool SegmentModifiedEnabled
 Modified events of segments are observed.
 
SegmentMap Segments
 Container of segments that belong to this segmentation.
 
std::set< vtkSmartPointer< vtkDataObject > > SourceRepresentationCache
 
vtkCallbackCommand * SourceRepresentationCallbackCommand
 Command handling source representation modified events.
 
bool SourceRepresentationModifiedEnabled
 Modified events of source representations are observed.
 
std::string SourceRepresentationName
 
bool UUIDSegmentIDs
 

Friends

class qMRMLSegmentEditorWidgetPrivate
 
class vtkMRMLSegmentationNode
 
class vtkSegmentationModifier
 
class vtkSegmentationRandomSequenceInitialize
 Singleton class managing vtkMinimalStandardRandomSequence used for randomizing segment IDs.
 
class vtkSlicerSegmentationsModuleLogic
 

Detailed Description

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 95 of file vtkSegmentation.h.

Member Typedef Documentation

◆ SegmentMap

typedef std::map<std::string, vtkSmartPointer<vtkSegment> > vtkSegmentation::SegmentMap

Container type for segments. Maps segment IDs to segment objects.

Definition at line 134 of file vtkSegmentation.h.

◆ Superclass

typedef vtkObject vtkSegmentation::Superclass

Definition at line 138 of file vtkSegmentation.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
SourceRepresentationModified 

Invoked when content of the source representation in a segment is changed.

RepresentationModified 

Invoked when content of any representation (including the source representation) in a segment is changed.

SegmentAdded 

Invoked if new segment is added.

SegmentRemoved 

Invoked if a segment is removed.

SegmentModified 

Invoked if a segment is modified (name changed, tags changed, etc). Note: the event is not invoked when content of a representation in a segment is changed.

ContainedRepresentationNamesModified 

Invoked if a representation is created or removed in the segments (e.g., created by conversion from master).

SegmentsOrderModified 

Invoked if segment IDs order is changed. Not called when a segment is added or removed.

Definition at line 98 of file vtkSegmentation.h.

◆ anonymous enum

anonymous enum
Enumerator
EXTENT_REFERENCE_GEOMETRY 

Extent of common geometry is used as extent.

EXTENT_UNION_OF_SEGMENTS 

Extent is computed as union of extent of all segments.

EXTENT_UNION_OF_SEGMENTS_PADDED 

Extent is computed as union of extent of all segments, with a single-voxel padding added on each side.

EXTENT_UNION_OF_EFFECTIVE_SEGMENTS 

Extent is computed as union of effective extent of all segments.

EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_PADDED 

Extent is computed as union of effective extent of all segments, with a single-voxel padding added on each side.

EXTENT_UNION_OF_EFFECTIVE_SEGMENTS_AND_REFERENCE_GEOMETRY 

Extent is computed as the reference geometry, expanded to contain the union of all segments.

Definition at line 117 of file vtkSegmentation.h.

Constructor & Destructor Documentation

◆ vtkSegmentation()

vtkSegmentation::vtkSegmentation ( )
protected

◆ ~vtkSegmentation()

vtkSegmentation::~vtkSegmentation ( )
overrideprotected

Member Function Documentation

◆ AddEmptySegment()

std::string vtkSegmentation::AddEmptySegment ( std::string segmentId = "",
std::string segmentName = "",
double color[3] = nullptr )

Add empty segment containing empty instances of the contained representations

Parameters
segmentIdID of added segment. If empty then a default ID will be generated
See also
GenerateUniqueSegmentId
Parameters
segmentNamename of added segment. If empty then the segmentId will be used as name.
colorof added segment. If not specified then empty then vtkSegment::SEGMENT_COLOR_INVALID is used.
Returns
ID of the added segment. Empty on failure

◆ AddSegment()

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:

  1. If the segment can be added (
    See also
    CanAcceptSegment), and it does not contain the source representation, then the source representation is converted using the cheapest available path.
  2. Make sure that the segment contains the same types of representations that are present in the existing segments of the segmentation (because we expect all segments in a segmentation to contain the same types of representations).
    Parameters
    segmentthe segment to observe
    insertBeforeSegmentIdif specified then the segment is inserted before insertBeforeSegmentId
    Returns
    Success flag

◆ ApplyLinearTransform()

virtual void vtkSegmentation::ApplyLinearTransform ( vtkAbstractTransform * transform)
virtual

Apply a linear transform on the source representation of the segments. The others will be invalidated Harden transform if poly data, apply to directions if oriented image data.

◆ ApplyNonLinearTransform()

virtual void vtkSegmentation::ApplyNonLinearTransform ( vtkAbstractTransform * transform)
virtual

Apply a non-linear transform on the source representation of the segments. The others will be invalidated Harden transform both if oriented image data and poly data.

◆ CanAcceptRepresentation()

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 source representation of this segment or it is possible to convert to source representation (or the segmentation is empty).

◆ CanAcceptSegment()

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.

◆ classFinalize()

static void vtkSegmentation::classFinalize ( )
staticprotected

◆ classInitialize()

static void vtkSegmentation::classInitialize ( )
staticprotected

Singleton management functions.

◆ ClearSegment()

void vtkSegmentation::ClearSegment ( std::string segmentId)

Clears the segment representation. If the segment is in a shared labelmap, it will be erased from the labelmap. Otherwise, the vtkDataObject will be initialized.

◆ CollapseBinaryLabelmaps()

void vtkSegmentation::CollapseBinaryLabelmaps ( bool forceToSingleLayer = false)

Reduce the binary labelmap representation to as few layers as possible.

Parameters
forceToSingleLayerIf false, then the layers will not be overwritten by each other, if true then the layers can overwrite each other, but the result is guaranteed to have one layer

◆ ContainsRepresentation()

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)

◆ ConvertSegmentsUsingPath()

bool vtkSegmentation::ConvertSegmentsUsingPath ( std::vector< std::string > segmentIDs,
vtkSegmentationConversionPath * path,
bool overwriteExisting = false )
protected

◆ ConvertSegmentUsingPath()

bool vtkSegmentation::ConvertSegmentUsingPath ( vtkSegment * segment,
vtkSegmentationConversionPath * path,
bool overwriteExisting = false )
protected

Convert given segment along a specified path

Parameters
segmentSegment to convert
pathPath to do the conversion along
overwriteExistingIf true then do each conversion step regardless the target representation exists. If false then skip those conversion steps that would overwrite existing representation
Returns
Success flag

◆ ConvertSingleSegment()

bool vtkSegmentation::ConvertSingleSegment ( std::string segmentId,
std::string targetRepresentationName )
protected

Converts a single segment to a representation.

◆ CopyConversionParameters()

virtual void vtkSegmentation::CopyConversionParameters ( vtkSegmentation * aSegmentation)
virtual

Copy conversion parameters from another segmentation.

◆ CopySegment()

static void vtkSegmentation::CopySegment ( vtkSegment * destination,
vtkSegment * source,
vtkSegment * baseline,
std::map< vtkDataObject *, vtkDataObject * > & cachedRepresentations )
static

Deep copies source segment to destination segment. If the same representation is found in baseline with up-to-date timestamp then the representation is reused from baseline.

◆ CopySegmentFromSegmentation()

bool vtkSegmentation::CopySegmentFromSegmentation ( vtkSegmentation * fromSegmentation,
std::string segmentId,
bool removeFromSource = false )

Copy segment from one segmentation to this one

Parameters
fromSegmentationSource segmentation
segmentIdID of segment to copy
removeFromSourceIf true, then delete segment from source segmentation after copying. Default value is false.
Returns
Success flag

◆ CreateRepresentation() [1/2]

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 source 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 source representation which is segmentation- specific, and also to allow optimizations (steps before per-segment conversion).

Parameters
targetRepresentationNameName of the representation to create
alwaysConvertIf true, then conversion takes place even if target representation exists. False by default.
Returns
true on success

◆ CreateRepresentation() [2/2]

bool vtkSegmentation::CreateRepresentation ( vtkSegmentationConversionPath * path,
vtkSegmentationConversionParameters * parameters )

Generate or update a representation in all segments, using the specified conversion path and parameters. Conversion starts from the source representation, and all representations along the path get overwritten.

Returns
true on success

◆ DeepCopy()

virtual void vtkSegmentation::DeepCopy ( vtkSegmentation * aSegmentation)
virtual

Deep copy one segmentation into another.

◆ DeserializeConversionParameters()

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

◆ DetermineCommonLabelmapExtent() [1/2]

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.

Parameters
commonGeometryExtentComputed extent that contains all the specified segments.
commonGeometryImageExtent will be returned in this image geometry
segmentIDsList of IDs of segments to include in the merged labelmap. If empty or missing, then all segments are included
computeEffectiveExtentSpecifies if the extent of a segment is the whole extent or the effective extent (where voxel values >0 found)

◆ DetermineCommonLabelmapExtent() [2/2]

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.

◆ DetermineCommonLabelmapGeometry() [1/2]

std::string vtkSegmentation::DetermineCommonLabelmapGeometry ( int extentComputationMode,
vtkStringArray * segmentIds )

Determine common labelmap geometry for whole segmentation, for python compatibility.

◆ DetermineCommonLabelmapGeometry() [2/2]

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.

Parameters
extentComputationModeDetermines 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).
segmentIDsList of IDs of segments to include in the merged labelmap. If empty or missing, then all segments are included
Returns
Geometry string that can be deserialized using
See also
vtkSegmentationConverter::SerializeImageGeometry

◆ GenerateMergedLabelmap()

bool vtkSegmentation::GenerateMergedLabelmap ( vtkOrientedImageData * mergedImageData,
int extentComputationMode,
vtkOrientedImageData * mergedLabelmapGeometry = nullptr,
const std::vector< std::string > & segmentIDs = std::vector< std::string >(),
vtkIntArray * labelValues = nullptr )

Merged labelmap functions.

Create a merged labelmap from the segment IDs If no segment IDs are specified, then all segments will be merged

Parameters
mergedImageDataOutput image data for the merged labelmap image data. Voxels of background volume will be of signed short type. Label value of n-th segment in segmentIDs list will be (n + 1), or will be specified in labelValues. Label value of background = 0.
extentComputationModeInput that 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).
mergedLabelmapGeometryDetermines geometry of merged labelmap if not nullptr, automatically determined otherwise
segmentIDsList of IDs of segments to include in the merged labelmap. If empty or missing, then all segments are included
labelValuesInput list of label values that will be used in the merged labelmap. If not specified, then the label values in the segmentation will be used. The size of the array should match the number of segment IDs used in the merged labelmap.

◆ GenerateRandomSegmentID()

static std::string vtkSegmentation::GenerateRandomSegmentID ( int suffixLength,
std::string validCharacters = "" )
staticprotected

Generate a random segment ID. The form is "S_" + random alphanumeric characters.

Parameters
suffixLengthLength of the generated ID

◆ GenerateUniqueSegmentID()

std::string vtkSegmentation::GenerateUniqueSegmentID ( std::string id = "")

Generate unique segment ID. If argument is empty then a new unique ID will be generated. The unique generated ID is generated as a UUID derived UID (See https://dicom.nema.org/medical/dicom/current/output/chtml/part05/sect_b.2.html). If argument is unique it is returned unchanged. If there is a segment with the given ID, then it is postfixed by a number to make it unique.

Parameters
idOptional segment ID to use as base for generating a unique ID
Returns
Unique segment ID

◆ GenerateUniqueSegmentName()

std::string vtkSegmentation::GenerateUniqueSegmentName ( std::string base)
protected

Generate unique segment name. If argument is empty then a new name will be generated in the form "Segment_N", 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.

Parameters
baseNameOptional segment name to use as base for generating a unique name
Returns
Unique segment name

◆ GenerateUUIDDerivedUID()

static std::string vtkSegmentation::GenerateUUIDDerivedUID ( )
staticprotected

Generate a UUID derived UID. The form is "2.25." + a UUID converted to an integer form.

◆ GetAvailableRepresentationNames()

void vtkSegmentation::GetAvailableRepresentationNames ( std::set< std::string > & representationNames)
inline

Get all representations supported by the converter.

Definition at line 329 of file vtkSegmentation.h.

◆ GetBounds()

virtual void vtkSegmentation::GetBounds ( double bounds[6])
virtual

Get bounding box in global RAS in the form (xmin,xmax, ymin,ymax, zmin,zmax).

◆ GetClassName()

virtual const char * vtkSegmentation::GetClassName ( )
virtual

◆ GetContainedRepresentationNames()

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)

◆ GetConversionParameter()

std::string vtkSegmentation::GetConversionParameter ( const std::string & name)
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 485 of file vtkSegmentation.h.

◆ GetConversionParametersForPath()

void vtkSegmentation::GetConversionParametersForPath ( vtkSegmentationConversionParameters * conversionParameters,
vtkSegmentationConversionPath * path )
inline

Get names of all conversion parameters used by the selected conversion path.

Definition at line 488 of file vtkSegmentation.h.

◆ GetLayerDataObject()

vtkDataObject * vtkSegmentation::GetLayerDataObject ( int layer,
std::string representationName = "" )

Get the data object for a particular layer index If representationName is not specified, it will be set to the source representation name

◆ GetLayerIndex()

int vtkSegmentation::GetLayerIndex ( std::string segmentId,
std::string representationName = "" )

Get the layer index for a particular segment If representationName is not specified, it will be set to the source representation name

◆ GetLayerObjects()

void vtkSegmentation::GetLayerObjects ( vtkCollection * layerObjects,
std::string representationName = "" )

Get a collection of all of the data objects in the segmentation If representationName is not specified, it will be set to the source representation name

◆ GetMasterRepresentationName()

virtual std::string vtkSegmentation::GetMasterRepresentationName ( )
inlinevirtual
Deprecated
Use SetSourceRepresentationName instead.

Definition at line 516 of file vtkSegmentation.h.

◆ GetNthSegment()

vtkSegment * vtkSegmentation::GetNthSegment ( unsigned int index) const

Request segment by index.

◆ GetNthSegmentID()

std::string vtkSegmentation::GetNthSegmentID ( unsigned int index) const

Get n-th segment ID. Return with "" if no segment is found by that index.

◆ GetNumberOfLayers()

int vtkSegmentation::GetNumberOfLayers ( std::string representationName = "")

Shared representation layer functions.

Get the number of unique vtkDataObject that are used for a particular representation type If representationName is not specified, it will be set to the source representation name

◆ GetNumberOfSegments()

int vtkSegmentation::GetNumberOfSegments ( ) const

Request the total number of segments, primarily used for iterating over all segments.

◆ GetPossibleConversions()

void vtkSegmentation::GetPossibleConversions ( const std::string & targetRepresentationName,
vtkSegmentationConversionPaths * paths )

Get all possible conversions between the source representation and a specified target representation.

◆ GetSegment()

vtkSegment * vtkSegmentation::GetSegment ( std::string segmentId)

Access a segment by ID

Parameters
segmentIdSegment identifier in the container to access

◆ GetSegmentIdBySegment()

std::string vtkSegmentation::GetSegmentIdBySegment ( vtkSegment * segment)

Find segment ID by segment instance Returns empty string if segment is not found.

◆ GetSegmentIdBySegmentName()

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.

◆ GetSegmentIDRandomSequenceInstance()

static vtkMinimalStandardRandomSequence * vtkSegmentation::GetSegmentIDRandomSequenceInstance ( )
static

◆ GetSegmentIDs() [1/3]

std::vector< std::string > vtkSegmentation::GetSegmentIDs ( )

Get IDs for all contained segments, for python compatibility.

◆ GetSegmentIDs() [2/3]

void vtkSegmentation::GetSegmentIDs ( std::vector< std::string > & segmentIds)

Get IDs for all contained segments.

◆ GetSegmentIDs() [3/3]

void vtkSegmentation::GetSegmentIDs ( vtkStringArray * segmentIds)

Get IDs for all contained segments, for python compatibility.

◆ GetSegmentIDsForDataObject()

std::vector< std::string > vtkSegmentation::GetSegmentIDsForDataObject ( vtkDataObject * dataObject,
std::string representationName = "" )

Get the segmentIDs that use a specific data object If representationName is not specified, it will be set to the source representation name

◆ GetSegmentIDsForLayer()

std::vector< std::string > vtkSegmentation::GetSegmentIDsForLayer ( int layer,
std::string representationName = "" )

Get the segmentIDs contained in the specified layer If representationName is not specified, it will be set to the source representation name

◆ GetSegmentIDsSharingBinaryLabelmapRepresentation()

void vtkSegmentation::GetSegmentIDsSharingBinaryLabelmapRepresentation ( std::string originalSegmentId,
std::vector< std::string > & sharedSegmentIds,
bool includeOriginalSegmentId = true )

Gets the segment IDs that are shared with the specified segment binary labelmap

Parameters
originalSegmentIdID of the specified segment
sharedSegmentIdsOutput segment IDs
includeOriginalSegmentIdIf true, the original segment ID is included in the output

◆ GetSegmentIDsSharingRepresentation()

void vtkSegmentation::GetSegmentIDsSharingRepresentation ( std::string originalSegmentId,
std::string representationName,
std::vector< std::string > & sharedSegmentIds,
bool includeOriginalSegmentId = true )

Gets the segment IDs that are shared with the specified segment

Parameters
originalSegmentIdID of the specified segment
representationNameRepresentation to check for shared segment IDs
sharedSegmentIdsOutput segment IDs
includeOriginalSegmentIdIf true, the original segment ID is included in the output

◆ GetSegmentIndex()

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.

See also
GetSegmentIDs

◆ GetSegmentRepresentation()

vtkDataObject * vtkSegmentation::GetSegmentRepresentation ( std::string segmentId,
std::string representationName )

Get representation from segment.

◆ GetSegmentsByTag()

std::vector< vtkSegment * > vtkSegmentation::GetSegmentsByTag ( std::string tag,
std::string value = "" )

Get segments that contain a certain tag

Parameters
tagTag name to look for in segments
valueTag value to look for in segments. If omitted or empty then any value is accepted
Returns
Vector of segments containing the requested tag

◆ GetSourceRepresentationName()

virtual std::string vtkSegmentation::GetSourceRepresentationName ( )
virtual

Get source representation name.

◆ GetUniqueLabelValueForSharedLabelmap() [1/2]

int vtkSegmentation::GetUniqueLabelValueForSharedLabelmap ( std::string segmentId)

Gets a unique shared labelmap value for the specified segment Compares all of the other segments that are shared with the specified segmentId to determine the a unique labelmap value

◆ GetUniqueLabelValueForSharedLabelmap() [2/2]

int vtkSegmentation::GetUniqueLabelValueForSharedLabelmap ( vtkOrientedImageData * labelmap)

Gets a unique shared labelmap value for the specified labelmap Returns labelmap->GetScalarRange()[1] + 1

◆ GetUUIDSegmentIDs()

virtual bool vtkSegmentation::GetUUIDSegmentIDs ( )
virtual

◆ InvalidateNonMasterRepresentations()

void vtkSegmentation::InvalidateNonMasterRepresentations ( )
inline
Deprecated
Use InvalidateNonSourceRepresentations instead.

Definition at line 335 of file vtkSegmentation.h.

◆ InvalidateNonSourceRepresentations()

void vtkSegmentation::InvalidateNonSourceRepresentations ( )

Invalidate (remove) non-source representations in all the segments if this segmentation node.

◆ IsA()

virtual int vtkSegmentation::IsA ( const char * type)
virtual

◆ IsMasterRepresentationImageData()

bool vtkSegmentation::IsMasterRepresentationImageData ( )
inline
Deprecated
Use IsSourceRepresentationImageData instead.

Definition at line 322 of file vtkSegmentation.h.

◆ IsMasterRepresentationPolyData()

bool vtkSegmentation::IsMasterRepresentationPolyData ( )
inline
Deprecated
Use IsSourceRepresentationPolyData instead.

Definition at line 312 of file vtkSegmentation.h.

◆ IsSharedBinaryLabelmap()

bool vtkSegmentation::IsSharedBinaryLabelmap ( std::string segmentID)

Shared labelmap utility functions.

Returns true if the binary labelmap representation is shared

◆ IsSourceRepresentationImageData()

bool vtkSegmentation::IsSourceRepresentationImageData ( )

Determine if source representation is (oriented) image data type.

◆ IsSourceRepresentationPolyData()

bool vtkSegmentation::IsSourceRepresentationPolyData ( )

Determine if source representation is poly data type.

◆ IsTypeOf()

static int vtkSegmentation::IsTypeOf ( const char * type)
static

◆ MergeSegmentLabelmaps()

void vtkSegmentation::MergeSegmentLabelmaps ( std::vector< std::string > mergeSegmentIds)

Merges the specified segments into the same shared labelmap This method can cause segments to overwrite each other during during merge. Segments with a higher index will overwrite segments with a lower index. If no segment IDs are specified, then all segments will be shared

◆ New()

static vtkSegmentation * vtkSegmentation::New ( )
static

◆ OnSegmentModified()

static void vtkSegmentation::OnSegmentModified ( vtkObject * caller,
unsigned long eid,
void * clientData,
void * callData )
staticprotected

Callback function invoked when segment is modified. It calls Modified on the segmentation and rebuilds observations on the source representation of each segment

◆ OnSourceRepresentationModified()

static void vtkSegmentation::OnSourceRepresentationModified ( vtkObject * caller,
unsigned long eid,
void * clientData,
void * callData )
staticprotected

Callback function observing the source representation of each segment It fires a

See also
SourceRepresentationModifiedEvent if source representation is changed in ANY segment

◆ PrintSelf()

void vtkSegmentation::PrintSelf ( ostream & os,
vtkIndent indent )
override

◆ ReadXMLAttributes()

virtual void vtkSegmentation::ReadXMLAttributes ( const char ** atts)
virtual

Set attributes from name/value pairs.

◆ RemoveAllSegments()

void vtkSegmentation::RemoveAllSegments ( )

Remove all segments.

◆ RemoveRepresentation()

void vtkSegmentation::RemoveRepresentation ( const std::string & representationName)

Removes a representation from all segments if present.

◆ RemoveSegment() [1/3]

void vtkSegmentation::RemoveSegment ( SegmentMap::iterator segmentIt)
protected

Remove segment by iterator. The two

See also
RemoveSegment methods call this function after finding the iterator based on their different input arguments.

◆ RemoveSegment() [2/3]

void vtkSegmentation::RemoveSegment ( std::string segmentId)

Remove a segment by ID

Parameters
segmentIdIdentifier of the segment to remove from the segmentation

◆ RemoveSegment() [3/3]

void vtkSegmentation::RemoveSegment ( vtkSegment * segment)

Remove a segment by value

Parameters
segmentthe segment to remove from the segmentation

◆ ReorderSegments()

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.

See also
SetSegmentIndex

◆ SafeDownCast()

static vtkSegmentation * vtkSegmentation::SafeDownCast ( vtkObject * o)
static

◆ SeparateSegmentLabelmap()

void vtkSegmentation::SeparateSegmentLabelmap ( std::string segmentId)

Moves an existing segment from a shared labelmap into a separate labelmap containing only the specified segment.

◆ SerializeAllConversionParameters()

std::string vtkSegmentation::SerializeAllConversionParameters ( )

Serialize all conversion parameters. The resulting string can be parsed in a segmentation object using /sa DeserializeConversionParameters

◆ SetConversionParameter()

void vtkSegmentation::SetConversionParameter ( const std::string & name,
const std::string & value )
inline

Set a conversion parameter to all rules having this parameter.

Definition at line 481 of file vtkSegmentation.h.

◆ SetImageGeometryFromCommonLabelmapGeometry()

bool vtkSegmentation::SetImageGeometryFromCommonLabelmapGeometry ( vtkOrientedImageData * imageData,
vtkStringArray * segmentIDs = nullptr,
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).

◆ SetMasterRepresentationName()

virtual void vtkSegmentation::SetMasterRepresentationName ( const std::string & representationName)
inlinevirtual
Deprecated
Use SetSourceRepresentationName instead.

Definition at line 509 of file vtkSegmentation.h.

◆ SetSegmentIndex()

bool vtkSegmentation::SetSegmentIndex ( const std::string & segmentId,
unsigned int newIndex )

Changes segment order. Segment order may be used for display and generating merged labelmaps.

Returns
True if segment index has changed successfully (or the index has already been set).
See also
ReorderSegments

◆ SetSegmentModifiedEnabled()

bool vtkSegmentation::SetSegmentModifiedEnabled ( bool enabled)
protected

Temporarily enable/disable segment modified event.

Returns
Old value of SegmentModifiedEnabled. In general, the old value should be restored after modified is temporarily disabled to ensure proper state when calling SetSegmentModifiedEnabled in nested functions.

◆ SetSourceRepresentationModifiedEnabled()

bool vtkSegmentation::SetSourceRepresentationModifiedEnabled ( bool enabled)
protected

Temporarily enable/disable source representation modified event.

Returns
Old value of SourceRepresentationModifiedEnabled. In general, the old value should be restored after modified is temporarily disabled to ensure proper state when calling SetSourceRepresentationModifiedEnabled in nested functions.

◆ SetSourceRepresentationName()

virtual void vtkSegmentation::SetSourceRepresentationName ( const std::string & representationName)
virtual

Set source representation name. Need to make sure before setting the name that the newly set source representation exists in the segmentation! Use

See also
CreateRepresentation for that.

◆ SetUUIDSegmentIDs()

virtual void vtkSegmentation::SetUUIDSegmentIDs ( bool )
virtual

◆ UpdateSourceRepresentationObservers()

void vtkSegmentation::UpdateSourceRepresentationObservers ( )
protected

Check to ensure that all source representations are being observed, and observers on source representations that are no longer in the segmentation are removed

◆ UUIDSegmentIDsOff()

virtual void vtkSegmentation::UUIDSegmentIDsOff ( )
virtual

◆ UUIDSegmentIDsOn()

virtual void vtkSegmentation::UUIDSegmentIDsOn ( )
virtual

◆ WriteXML()

virtual void vtkSegmentation::WriteXML ( ostream & of,
int indent )
virtual

Write this object's information to a MRML file in XML format.

Friends And Related Symbol Documentation

◆ qMRMLSegmentEditorWidgetPrivate

friend class qMRMLSegmentEditorWidgetPrivate
friend

Definition at line 644 of file vtkSegmentation.h.

◆ vtkMRMLSegmentationNode

friend class vtkMRMLSegmentationNode
friend

Definition at line 641 of file vtkSegmentation.h.

◆ vtkSegmentationModifier

friend class vtkSegmentationModifier
friend

Definition at line 643 of file vtkSegmentation.h.

◆ vtkSegmentationRandomSequenceInitialize

friend class vtkSegmentationRandomSequenceInitialize
friend

Singleton class managing vtkMinimalStandardRandomSequence used for randomizing segment IDs.

Definition at line 635 of file vtkSegmentation.h.

◆ vtkSlicerSegmentationsModuleLogic

friend class vtkSlicerSegmentationsModuleLogic
friend

Definition at line 642 of file vtkSegmentation.h.

Member Data Documentation

◆ Converter

vtkSegmentationConverter* vtkSegmentation::Converter
protected

Converter instance.

Definition at line 607 of file vtkSegmentation.h.

◆ SegmentCallbackCommand

vtkCallbackCommand* vtkSegmentation::SegmentCallbackCommand
protected

Command handling segment modified events.

Definition at line 610 of file vtkSegmentation.h.

◆ SegmentIdAutogeneratorIndex

int vtkSegmentation::SegmentIdAutogeneratorIndex
protected

This number is incremented and used for generating the next segment ID.

Definition at line 623 of file vtkSegmentation.h.

◆ SegmentIds

std::deque< std::string > vtkSegmentation::SegmentIds
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 628 of file vtkSegmentation.h.

◆ SegmentModifiedEnabled

bool vtkSegmentation::SegmentModifiedEnabled
protected

Modified events of segments are observed.

Definition at line 619 of file vtkSegmentation.h.

◆ Segments

SegmentMap vtkSegmentation::Segments
protected

Container of segments that belong to this segmentation.

Definition at line 598 of file vtkSegmentation.h.

◆ SourceRepresentationCache

std::set<vtkSmartPointer<vtkDataObject> > vtkSegmentation::SourceRepresentationCache
protected

Definition at line 630 of file vtkSegmentation.h.

◆ SourceRepresentationCallbackCommand

vtkCallbackCommand* vtkSegmentation::SourceRepresentationCallbackCommand
protected

Command handling source representation modified events.

Definition at line 613 of file vtkSegmentation.h.

◆ SourceRepresentationModifiedEnabled

bool vtkSegmentation::SourceRepresentationModifiedEnabled
protected

Modified events of source representations are observed.

Definition at line 616 of file vtkSegmentation.h.

◆ SourceRepresentationName

std::string vtkSegmentation::SourceRepresentationName
protected

Source representation type name.

  1. This representation is saved on disk
  2. If this representation is modified, the others are invalidated This value must be set by the creator of the segmentation object!

Definition at line 604 of file vtkSegmentation.h.

◆ UUIDSegmentIDs

bool vtkSegmentation::UUIDSegmentIDs
protected

Definition at line 632 of file vtkSegmentation.h.


The documentation for this class was generated from the following file: