ImFusion SDK 4.3
Operation Class Reference

#include <ImFusion/ML/Operation.h>

Class to define a pre-post processing operation on data items. More...

Inherited by RandomOperation< ConeBeamSimulationOperation >, RandomOperation< SimulateCBCTOperation >, RandomOperation< XRayFixtureOperation >, RandomOperation< XRaySamplingOperation >, RandomOperation< XRayUndoLogConversionOperation >, RandomOperation< ExtractSubsetOperation >, RandomOperation< AddDegradedLabelAsChannelOperation >, RandomOperation< AddRandomNoiseOperation >, RandomOperation< AxisFlipOperation >, RandomOperation< AxisRotationOperation >, RandomOperation< CropAroundLabelMapOperation >, RandomOperation< CropOperation >, RandomOperation< CutOutOperation >, RandomOperation< DeformationOperation >, RandomOperation< GammaCorrectionOperation >, RandomOperation< InvertOperation >, RandomOperation< LinearIntensityMappingOperation >, RandomOperation< MRIBiasFieldGenerationOperation >, RandomOperation< PolyCropOperation >, RandomOperation< ResolutionReductionOperation >, RandomOperation< RotationOperation >, RandomOperation< ScalingOperation >, RandomOperation< SmoothOperation >, RandomOperation< TemplateInpaintingOperation >, RandomOperation< FrameFromVolumeOperation >, ConeBeamSimulationOperation, SimulateCBCTOperation, SmoothCTEdgesOperation, XRayFixtureOperation, XRaySamplingOperation, XRayUndoLogConversionOperation, CropAroundVertebraeOperation, AddCenterBoxOperation, AddDegradedLabelAsChannelOperation, AddPixelwisePredictionChannelOperation, AddPositionChannelOperation, AddRandomNoiseOperation, AdjustShiftScaleOperation, ApproximateToHigherResolutionOperation, ArgMaxOperation, BakeDeformationOperation, BakePhotometricInterpretationOperation, BakeTransformationOperation, BlobsFromKeypointsOperation, CheckDataOperation, ClipOperation, ConcatenateNeighboringFramesToChannelsOperation, ConvertSlicesToVolumeOperation, ConvertToGrayOperation, ConvertVolumeToSlicesOperation, ConvolutionalCRFOperation, CopyOperation, CropAroundLabelMapOperation, CropOperation, CutOutOperation, DeformationOperation, EnsureExplicitMaskOperation, EnsureOneToOneMatrixMappingOperation, ExtractSubsetOperation, ForegroundGuidedLabelUpsamplingOperation, GammaCorrectionOperation, GenerateRandomKeypointsOperation, HighPassOperation, ImageMathOperation, ImageMattingOperation, ImageROISampler, InverseOperation, InvertOperation, InvertibleOperation, KeepLargestComponentOperation, KeypointsFromBlobsOperation, LinearIntensityMappingOperation, MRIBiasFieldCorrectionOperation, MRIBiasFieldGenerationOperation, MakeFloatOperation, MatrixBasedOperation, MergeAsChannelsOperation, MorphologicalFilterOperation, NormalizeMADOperation, NormalizeNormalOperation, NormalizePercentileOperation, NormalizeUniformOperation, OneHotOperation, PolyCropOperation, RandomChoiceOperation, RandomImageFromLabelOperation, RandomKeypointJitterOperation, RandomOperation< BaseOp >, RecombinePatchesOperation, RemoveMaskOperation, RemoveOperation, RenameOperation, ReplaceLabelsValuesOperation, ResampleDimsOperation, ResampleKeepingAspectRatioOperation, ResampleOperation, ResampleToInputOperation, ResolutionReductionOperation, RunModelOperation, SelectChannelsOperation, SetModalityOperation, SetSpacingOperation, SigmoidOperation, SmoothOperation, SoftmaxOperation, SplitIntoPatchesOperation, StandardizeImageAxesOperation, SwapImageAndLabelsOperation, SyncOperation, TagDataElementOperation, TanhOperation, TemplateInpaintingOperation, ThresholdOperation, UndoPaddingOperation, and FrameFromVolumeOperation.

Detailed Description

Class to define a pre-post processing operation on data items.

This class is the base interface for specifying an operation that transform input data contained in a DataItem. Unlike the Algorithm class, an Operation is constructed by specifying its parameters, while the actual data to process are passed as argument to the function process, which is the main entry point of the class. This allows the user to flexibly setup a processing pipeline based on operation beforehand, and later apply it to a collection of data. This is particularly useful when processing a dataset containing a large number of data, and it makes sense to specify a processing pipeline in advance.

Operations can be constructed in two ways:

  1. Using the direct parametric constructor, where each parameter is specified in the argument list:
    DataItem inputItem{...};
    AxisRotationOperation axisRotationOp({"x", "z"}, {90, -90});
    resampleOp.process(inputItem);
    Rotate around image axis with axis-specific rotation angles that are signed multiples of 90 degrees.
    Definition AxisRotationOperation.h:17
    Class for holding a map of heterogeneous DataElements, see DataElement.
    Definition DataItem.h:45
    virtual void process(DataItem &item) override
    Main function that processes a DataItem in-place, may throw OperationException The data to be process...
  2. Using the default constructor and configuring the operation via Properties:
    DataItem inputItem{...};
    AxisRotationOperation axisRotationOp;
    Properties properties{{"axes", std::vector<std::string>{"x", "z"}}, {"angles", std::vector<int>{90, -90}}};
    axisRotationOp.configure(properties);
    resampleOp.process(inputItem);
    bool configure(const Properties &properties) override
    Configure an Operation with the given properties and return whether the configuration was successful.
    Storage container for serialization of arbitrary types, internally backed by strings.
    Definition Properties.h:50
    Option 1 is useful when using operations in code, option 2 is useful for setting up an operation using configuration files, like yaml training or inference files, see MachineLearningModel.

Once an operation is set up it can be run via the process function, which takes a DataItem as input and manipulate it in-place. If all you need is processing a SharedImageSet, you can use utilities overload of the process function, this will pack the input image in a DataItem, call the main process function on it, and retrieve the result:

std::shared_ptr<SharedImageSet> result = myOperation->process(std::move(images));
T make_shared(T... args)

The main process function has a default implementation which loops over each element in the input data item and according to the element type (see DataItem) calls a delegate process function which acts on that element type. The delegate functions are:

In most of the cases, when implementing your own operation, all you have to do is to overload one of the delegate function. If a delegate function is not implemented, the default version will be used, which does nothing on the data.

Example:

// this class
class SetBorderValueOperation : public Operation
{
public:
explicit MyOperation(int borderSize = 0, double borderValue = 0.0) // please make sure each parameter has a default value, this way you also have a default constructor
{
m_borderSize = borderSize;
m_borderValue = borderValue;
}
protected:
// user shouldn't call this function directly, but use the utility overload std::shared_ptr<SharedImageSet> process(std::shared_ptr<SharedImageSet> images)
{
if (!images)
return nullptr;
for (int n = 0; n < images->size(); ++n)
{
// using image math block access
SharedImage* img = images->get(i);
T typedValue = static_cast<...>(m_borderValue.value()) ; // cast m_borderValue to the actual typed value
ImageMath::makeArray(*in).block(vec3i(0, 0, 0), vec3i(m_borderSize.value(), height, slices)) = typedValue;
ImageMath::makeArray(*in).block(vec3i(width - m_borderSize.value(), 0, 0), vec3i(m_borderSize.value(), height, slices)) = typedValue;
ImageMath::makeArray(*in).block(vec3i(0, 0, 0), vec3i(width, m_borderSize.value(), slices)) = typedValue;
ImageMath::makeArray(*in).block(vec3i(0, height - m_borderSize.value(), 0), vec3i(width, m_borderSize.value(), slices)) = typedValue;
ImageMath::makeArray(*in).block(vec3i(0, 0, 0), vec3i(width, height, m_borderSize.value())) = typedValue;
ImageMath::makeArray(*in).block(vec3i(0, 0, slices - m_borderSize.value()), vec3i(width, height, m_borderSize.value())) = typedValue;
}
return images;
}
private:
AdvancedParameter<int> m_borderSize =
{"border_size", // name of the parameter, this is the name you need to use to configure this param via Properties
0, // default value, make sure it matches the ctor default value
this, // pointer to the parent class, used for auto-configuration, see Parameter
ParamRequired::Yes // if the parameter is required, configure returns false if the parameter is not found in the Properties.
};
AdvancedParameter<double> m_borderValue = {"border_value", 0.0, this, ParamRequired::No}; // If value not configured, default is used
};
Operation(std::string name, ProcessingPolicy processingPolicy)
Derived classes must specify a name and whether, by default, the operation should also be applied to ...
virtual std::shared_ptr< SharedImageSet > processImages(std::shared_ptr< SharedImageSet > input) const
Virtual function that every subclass should override.
ProcessingPolicy
Policy used by default when selecting on the fields on which the operation will be applied Note that ...
Definition Operation.h:205
@ Everything
all images
Definition Operation.h:207
Image shared on multiple devices.
Definition SharedImage.h:86
auto makeArray(TypedImage< T > &img, bool ignoreShiftAndScale, MagFilter magFilter, Wrap wrap, const vec4f &borderColor)
Convenience function to create an array leaf (needed as until c++17 there is no template type deducti...
Definition Array.h:657

In some cases though, you want to write an Operation that adds/remove/swaps/change/rename/reorder fields or element in the input DataItem. In those cases, the user can directly overload the main process function, like in the following example

class SwapFieldsOperation : public Operation
{
public:
MockSwapFieldsOperation(std::string field1 = "", std::string field2 = "")
: Operation("MockSwapFieldsOperation", ProcessingPolicy::Everything)
{
m_field1 = std::move(field1);
m_field2 = std::move(field2);
}
void process(DataItem& item) final
{
if (item.numFields() >= 2)
{
std::string f1 = m_field1.value();
std::string f2 = m_field2.value();
if (f1 == f2);
throwOperationError("Fields to swap must have different names");
if (!item.contains(f1) || !item.contains(f2))
throwOperationError("Invalid fields");
auto el1 = item.pop(f1);
auto el2 = item.pop(f2);
item.set(f1, std::move(el2));
item.set(f2, std::move(el1));
}
else
{
throwOperationError("Item must contain at least two fields to swap");
}
}
// In this case utility overloads of the process functions don't make sense, so we disable them
ML_OPERATION_DISABLE_UTILITY_PROCESS;
private:
AdvancedParameter<std::string> m_field1 = {"field1", "", this, ParamRequired::Yes};
AdvancedParameter<std::string> m_field1 = {"field2", "", this, ParamRequired::Yes};
};
void throwOperationError(const std::string &msg) const
Helper function to throw an exception due to a runtime error.
Definition Operation.h:362
virtual void process(DataItem &item)
Main function that processes a DataItem in-place, may throw OperationException The data to be process...
Note
Operations have bindings to python.

Classes

struct  Specs
 Specifications required to fully instantiate an operation. More...
 

Public Types

enum  ProcessingPolicy { EverythingExceptLabels = 0 , Everything , OnlyLabels }
 Policy used by default when selecting on the fields on which the operation will be applied Note that "Labels" here refers to the target tag, not to be confused with Data::Modality::LABEL. More...
 
using PreProcessHook = std::function<void(Operation&, DataElement*)>
 
using PostProcessHook = std::function<void(Operation&, DataElement*)>
 

Public Member Functions

 Operation (std::string name, ProcessingPolicy processingPolicy)
 Derived classes must specify a name and whether, by default, the operation should also be applied to label maps.
 
virtual void process (DataItem &item)
 Main function that processes a DataItem in-place, may throw OperationException The data to be processed is determined by the active fields (if set) and the processing policy otherwise (if set), otherwise all fields are processed.
 
virtual std::shared_ptr< SharedImageSetprocess (std::shared_ptr< SharedImageSet > input)
 Utility function to directly apply an operation on a SharedImageSet irrespective of active fields and processing policy.
 
virtual std::shared_ptr< KeypointSetprocess (std::shared_ptr< KeypointSet > input)
 Utility function to directly apply an operation on a set of KeypointSet irrespective of active fields and processing policy.
 
virtual std::shared_ptr< BoundingBoxSetprocess (std::shared_ptr< BoundingBoxSet > input)
 Utility function to directly apply an operation on a set of BoundingBoxSet irrespective of active fields and processing policy.
 
virtual std::unique_ptr< SharedImageSetprocess (std::unique_ptr< SharedImageSet > input) final
 Utility function with unique_ptr as input and output to avoid breaking changes (must not be overridden)
 
void addTemporaryPreProcessHook (PreProcessHook hook)
 Add a temporary hook that will only be active for the next process call and then automatically removed after the DataItem is processed.
 
void addTemporaryPostProcessHook (PostProcessHook hook)
 Add a temporary hook that will only be active for the next process call and then automatically removed after the DataItem is processed.
 
virtual bool checkRequiredItemsTypes (const DataItem &item) const
 Checks if the data item holds fields with types required by the operation.
 
const std::stringname () const
 Returns the name of the operation.
 
virtual bool configure (const Properties &properties)
 Configure an Operation with the given properties and return whether the configuration was successful.
 
virtual Properties configuration () const
 Return the Operation configuration.
 
void setActiveFields (std::optional< std::unordered_set< std::string > > activeFields)
 
std::optional< std::unordered_set< std::string > > activeFields () const
 
virtual void setProcessingPolicy (ProcessingPolicy policy)
 
ProcessingPolicy processingPolicy () const
 
std::optional< uint32_t > seed () const
 Return the current seed (if there is one)
 
virtual void seedRandomEngine (uint32_t seed)
 Set a seed for the random generator.
 
ML::ComputingDevice computingDevice () const
 Get the computing device.
 
virtual void setComputingDevice (ML::ComputingDevice device)
 Set the computing device selection strategy.
 
void configFailed (const std::string &missingParam) const
 Helper function to show an error message due to a bad configuration.
 
void logDeprecatedParam (const std::string &oldName, const std::string &newName) const
 Helper function to print a warning because of a deprecated parameter has been specified.
 
bool errorOnUnexpectedBehaviour () const
 Get the policy whether to treat unexpected behavior warnings as errors.
 
virtual void setErrorOnUnexpectedBehaviour (bool error)
 Treat unexpected behavior warnings as errors.
 
void registerParameter (ParameterBase *param)
 Register a parameter so that the operation knows about it, and can automatically configure it (unless it has been marked as manually configured parameter via the Operation::setManuallyConfiguredParameters method).
 
std::vector< ParameterBase * > parameters () const
 Return the list of registered parameters.
 
virtual bool doesNotModifyInput () const
 Returns whether the operation is guaranteed to not modify its input element, either because it computes its output out-of-place or because it is a no-op.
 
virtual bool supportsInversion () const
 Whether the operation supports inversion. Returns False unless the operation derives from InvertibleOperation.
 
const std::stringrecordIdentifier () const
 Get the operation's record identifier.
 
virtual void setRecordIdentifier (const std::string &recordIdentifier)
 Set the operation's record identifier.
 
const std::stringlogDomain () const
 Log domain for AdvancedParameter.
 
std::optional< std::unordered_set< std::string > > selectedFields (const DataItem &item)
 Get the fields on which the operation will be applied.
 

Static Public Member Functions

static std::string processingPolicyToString (const ProcessingPolicy policy)
 
static ProcessingPolicy stringToProcessingPolicy (const std::string &s)
 
static std::unique_ptr< OperationcreateFromFactories (const Operation::Specs &specs)
 Helper function to create an operation from any factory (both C++ and Python factories are tested)
 

Protected Member Functions

virtual std::shared_ptr< SharedImageSetprocessImages (std::shared_ptr< SharedImageSet > input) const
 Virtual function that every subclass should override.
 
virtual std::shared_ptr< BoundingBoxSetprocessBoxes (std::shared_ptr< BoundingBoxSet > input) const
 Virtual function that every subclass should override.
 
virtual std::shared_ptr< KeypointSetprocessPoints (std::shared_ptr< KeypointSet > input) const
 Virtual function that every subclass should override.
 
virtual std::shared_ptr< SharedImageSetprocessVectors (std::shared_ptr< SharedImageSet > input) const
 Virtual function that every subclass should override.
 
virtual std::shared_ptr< TensorSetprocessTensors (std::shared_ptr< TensorSet > input) const
 
void throwOperationError (const std::string &msg) const
 Helper function to throw an exception due to a runtime error.
 
void warnOperationUnexpectedBehaviour (const std::string &msg) const
 Helper function to warn about a behavior different than asked.
 
bool inputIsEmptyOrNull (const SharedImageSet *input) const
 Helper function to check if the input is empty or null and print a warning if so.
 
virtual bool useGPU (const SharedImageSet *input) const
 Helper function that returns which device the operation should choose based on its configuration and a given input.
 
void prepareInputForDevice (SharedImageSet &input) const
 Make sure the input is on the correct device for the current device strategy.
 
virtual bool allowChannelBatchOnGPU () const
 Whether the operation implements channel-batching so that it can still be run on input with more than 4 channels.
 
bool configureOnly (const Properties &properties, const std::vector< ParameterBase * > &paramSelection) noexcept
 Helper method to configure only a subset of parameters.
 
void setManuallyConfiguredParameters (const std::vector< ParameterBase * > &manuallyConfiguredParams)
 Disable the auto-configuration of some of the parameters so that they can be parsed manually (in the configure function of the derived class).
 
void applyPreProcessHooks (DataElement *element)
 Apply the current pre-process hooks to an element.
 
void applyPostProcessHooks (DataElement *element)
 Apply the current post-process hooks to an element.
 

Protected Attributes

std::string m_name
 
ProcessingPolicy m_processingFieldsPolicy
 Flag specifying whether labels should be processed by default (when no active field has been specified)
 
std::optional< std::unordered_set< std::string > > m_activeFields
 Run the Operation only on those fields (if empty, will select suitable fields based on the current processing policy) when calling process()
 
std::unordered_set< std::stringm_alreadyWarned
 Set of warnings about unexpected behavior that have already been printed.
 
bool m_errorOnUnexpectedBehaviour = false
 Whether to throw an exception instead of warning about unexpected behavior.
 
std::optional< uint32_t > m_seed
 
Random::Generator m_randGenerator
 
ML::ComputingDevice m_device = ML::ComputingDevice::GPUIfOpenGl
 
std::vector< ParameterBase * > m_params
 All registered parameters.
 
std::vector< ParameterBase * > m_manuallyConfiguredParams
 All registered parameters that should not be configured automatically.
 
std::unordered_map< std::string, ElementTypem_requiredFieldsTypes
 List of all required field types used by checkRequiredItemsTypes.
 
std::string m_recordIdentifier
 User-provided unique identifier for this operation, used for recording processing history and inversion.
 
std::vector< PreProcessHookm_preProcessHooks
 
std::vector< PostProcessHookm_postProcessHooks
 
std::vector< PreProcessHookm_temporaryPreProcessHooks
 Pre-process hooks that will be used for the next processing call only.
 
std::vector< PostProcessHookm_temporaryPostProcessHooks
 Post-process hooks that will be used for the next processing call only.
 

Member Enumeration Documentation

◆ ProcessingPolicy

Policy used by default when selecting on the fields on which the operation will be applied Note that "Labels" here refers to the target tag, not to be confused with Data::Modality::LABEL.

Enumerator
EverythingExceptLabels 

all images but label maps

Everything 

all images

OnlyLabels 

only label maps

Member Function Documentation

◆ process() [1/5]

virtual void process ( DataItem & item)
virtual

Main function that processes a DataItem in-place, may throw OperationException The data to be processed is determined by the active fields (if set) and the processing policy otherwise (if set), otherwise all fields are processed.

Reimplemented in CropAroundVertebraeOperation, ConeBeamSimulationOperation, SimulateCBCTOperation, XRaySamplingOperation, AddDegradedLabelAsChannelOperation, BlobsFromKeypointsOperation, CheckDataOperation, ConvolutionalCRFOperation, CopyOperation, CropAroundLabelMapOperation, DeformationOperation, ForegroundGuidedLabelUpsamplingOperation, GenerateRandomKeypointsOperation, ImageMathOperation, ImageROISampler, InverseOperation, KeepLargestComponentOperation, KeypointsFromBlobsOperation, MatrixBasedOperation, MergeAsChannelsOperation, OrientedROISampler, RandomChoiceOperation, RandomImageFromLabelOperation, RandomOperation< BaseOp >, RandomOperation< AddDegradedLabelAsChannelOperation >, RandomOperation< AddRandomNoiseOperation >, RandomOperation< AxisFlipOperation >, RandomOperation< AxisRotationOperation >, RandomOperation< ConeBeamSimulationOperation >, RandomOperation< CropAroundLabelMapOperation >, RandomOperation< CropOperation >, RandomOperation< CutOutOperation >, RandomOperation< DeformationOperation >, RandomOperation< ExtractSubsetOperation >, RandomOperation< FrameFromVolumeOperation >, RandomOperation< GammaCorrectionOperation >, RandomOperation< InvertOperation >, RandomOperation< LinearIntensityMappingOperation >, RandomOperation< MRIBiasFieldGenerationOperation >, RandomOperation< PolyCropOperation >, RandomOperation< ResolutionReductionOperation >, RandomOperation< RotationOperation >, RandomOperation< ScalingOperation >, RandomOperation< SimulateCBCTOperation >, RandomOperation< SmoothOperation >, RandomOperation< TemplateInpaintingOperation >, RandomOperation< XRayFixtureOperation >, RandomOperation< XRaySamplingOperation >, RandomOperation< XRayUndoLogConversionOperation >, RectifyRotationOperation, RemoveOperation, RenameOperation, RotationOperation, RunModelOperation, SelectChannelsOperation, SetMatrixToIdentityOperation, SetSpacingOperation, SplitIntoPatchesOperation, SwapImageAndLabelsOperation, and TagDataElementOperation.

◆ process() [2/5]

virtual std::shared_ptr< SharedImageSet > process ( std::shared_ptr< SharedImageSet > input)
virtual

◆ process() [3/5]

virtual std::shared_ptr< KeypointSet > process ( std::shared_ptr< KeypointSet > input)
virtual

◆ process() [4/5]

virtual std::shared_ptr< BoundingBoxSet > process ( std::shared_ptr< BoundingBoxSet > input)
virtual

◆ process() [5/5]

virtual std::unique_ptr< SharedImageSet > process ( std::unique_ptr< SharedImageSet > input)
finalvirtual

◆ addTemporaryPreProcessHook()

void addTemporaryPreProcessHook ( PreProcessHook hook)
inline

Add a temporary hook that will only be active for the next process call and then automatically removed after the DataItem is processed.

Parameters
hookThe hook function to add

◆ addTemporaryPostProcessHook()

void addTemporaryPostProcessHook ( PostProcessHook hook)
inline

Add a temporary hook that will only be active for the next process call and then automatically removed after the DataItem is processed.

Parameters
hookThe hook function to add

◆ configure()

virtual bool configure ( const Properties & properties)
virtual

Configure an Operation with the given properties and return whether the configuration was successful.

Reimplemented in AddPositionChannelOperation, AddRandomNoiseOperation, ApplyTopDownFlagOperation, AxisFlipOperation, AxisRotationOperation, DeformationOperation, InverseOperation, KeepLargestComponentOperation, LabelROISampler, MakeFloatOperation, MorphologicalFilterOperation, MRIBiasFieldCorrectionOperation, NormalizeMADOperation, NormalizePercentileOperation, NormalizeUniformOperation, PadDimsOperation, PadDimsToNextMultipleOperation, PadOperation, RandomAddDegradedLabelAsChannelOperation, RandomAxisFlipOperation, RandomAxisRotationOperation, RandomChoiceOperation, RandomImageFromLabelOperation, RandomOperation< BaseOp >, RandomOperation< AddDegradedLabelAsChannelOperation >, RandomOperation< AddRandomNoiseOperation >, RandomOperation< AxisFlipOperation >, RandomOperation< AxisRotationOperation >, RandomOperation< ConeBeamSimulationOperation >, RandomOperation< CropAroundLabelMapOperation >, RandomOperation< CropOperation >, RandomOperation< CutOutOperation >, RandomOperation< DeformationOperation >, RandomOperation< ExtractSubsetOperation >, RandomOperation< FrameFromVolumeOperation >, RandomOperation< GammaCorrectionOperation >, RandomOperation< InvertOperation >, RandomOperation< LinearIntensityMappingOperation >, RandomOperation< MRIBiasFieldGenerationOperation >, RandomOperation< PolyCropOperation >, RandomOperation< ResolutionReductionOperation >, RandomOperation< RotationOperation >, RandomOperation< ScalingOperation >, RandomOperation< SimulateCBCTOperation >, RandomOperation< SmoothOperation >, RandomOperation< TemplateInpaintingOperation >, RandomOperation< XRayFixtureOperation >, RandomOperation< XRaySamplingOperation >, RandomOperation< XRayUndoLogConversionOperation >, RandomRotationOperation, RandomScalingOperation, ReplaceLabelsValuesOperation, ResampleKeepingAspectRatioOperation, RotationOperation, ScalingOperation, SmoothOperation, SplitIntoPatchesOperation, and SplitROISampler.

◆ configuration()

◆ seedRandomEngine()

◆ setComputingDevice()

◆ setErrorOnUnexpectedBehaviour()

◆ registerParameter()

void registerParameter ( ParameterBase * param)

Register a parameter so that the operation knows about it, and can automatically configure it (unless it has been marked as manually configured parameter via the Operation::setManuallyConfiguredParameters method).

This function is automatically called by each parameter if they have a parent operation, which should be the standard case.

◆ doesNotModifyInput()

virtual bool doesNotModifyInput ( ) const
inlinevirtual

Returns whether the operation is guaranteed to not modify its input element, either because it computes its output out-of-place or because it is a no-op.

This can be used to decide whether a copy of the input should be made before calling the Operation::process function. Note that this only relates to the overloads taking specific elements as inputs (e.g. images, keypoints, etc.), since the Operation::process(DataItem& item) function always modifies its input.

Reimplemented in AddCenterBoxOperation, AddDegradedLabelAsChannelOperation, AddPixelwisePredictionChannelOperation, AddPositionChannelOperation, AddRandomNoiseOperation, AdjustShiftScaleOperation, ApplyTopDownFlagOperation, ApproximateToHigherResolutionOperation, ArgMaxOperation, AxisFlipOperation, AxisRotationOperation, BakeDeformationOperation, BakePhotometricInterpretationOperation, BakeTransformationOperation, BlobsFromKeypointsOperation, CheckDataOperation, ClipOperation, ConcatenateNeighboringFramesToChannelsOperation, ConvertSlicesToVolumeOperation, ConvertToGrayOperation, ConvertVolumeToSlicesOperation, ConvolutionalCRFOperation, CopyOperation, CropAroundLabelMapOperation, CropOperation, CutOutOperation, DeformationOperation, EnsureExplicitMaskOperation, EnsureOneToOneMatrixMappingOperation, ExtractSubsetOperation, ForegroundGuidedLabelUpsamplingOperation, GammaCorrectionOperation, HighPassOperation, ImageMathOperation, ImageMattingOperation, ImageROISampler, InverseOperation, InvertOperation, KeepLargestComponentOperation, KeypointsFromBlobsOperation, LinearIntensityMappingOperation, MakeFloatOperation, MergeAsChannelsOperation, MorphologicalFilterOperation, MRIBiasFieldCorrectionOperation, MRIBiasFieldGenerationOperation, NormalizeMADOperation, NormalizeNormalOperation, NormalizePercentileOperation, NormalizeUniformOperation, OneHotOperation, PadDimsOperation, PadDimsToNextMultipleOperation, PadOperation, PolyCropOperation, RandomChoiceOperation, RandomImageFromLabelOperation, RandomKeypointJitterOperation, RandomOperation< BaseOp >, RandomOperation< AddDegradedLabelAsChannelOperation >, RandomOperation< AddRandomNoiseOperation >, RandomOperation< AxisFlipOperation >, RandomOperation< AxisRotationOperation >, RandomOperation< ConeBeamSimulationOperation >, RandomOperation< CropAroundLabelMapOperation >, RandomOperation< CropOperation >, RandomOperation< CutOutOperation >, RandomOperation< DeformationOperation >, RandomOperation< ExtractSubsetOperation >, RandomOperation< FrameFromVolumeOperation >, RandomOperation< GammaCorrectionOperation >, RandomOperation< InvertOperation >, RandomOperation< LinearIntensityMappingOperation >, RandomOperation< MRIBiasFieldGenerationOperation >, RandomOperation< PolyCropOperation >, RandomOperation< ResolutionReductionOperation >, RandomOperation< RotationOperation >, RandomOperation< ScalingOperation >, RandomOperation< SimulateCBCTOperation >, RandomOperation< SmoothOperation >, RandomOperation< TemplateInpaintingOperation >, RandomOperation< XRayFixtureOperation >, RandomOperation< XRaySamplingOperation >, RandomOperation< XRayUndoLogConversionOperation >, RecombinePatchesOperation, RectifyRotationOperation, RemoveMaskOperation, RemoveOperation, RenameOperation, ReplaceLabelsValuesOperation, ResampleDimsOperation, ResampleKeepingAspectRatioOperation, ResampleOperation, ResampleToInputOperation, ResolutionReductionOperation, RotationOperation, RunModelOperation, ScalingOperation, SelectChannelsOperation, SetMatrixToIdentityOperation, SetModalityOperation, SetSpacingOperation, SigmoidOperation, SmoothOperation, SoftmaxOperation, SplitIntoPatchesOperation, StandardizeImageAxesOperation, SwapImageAndLabelsOperation, SyncOperation, TagDataElementOperation, TanhOperation, TemplateInpaintingOperation, ThresholdOperation, and UndoPaddingOperation.

◆ supportsInversion()

virtual bool supportsInversion ( ) const
virtual

Whether the operation supports inversion. Returns False unless the operation derives from InvertibleOperation.

Reimplemented in InvertibleOperation.

◆ setRecordIdentifier()

virtual void setRecordIdentifier ( const std::string & recordIdentifier)
inlinevirtual

Set the operation's record identifier.

Reimplemented in PadDimsOperation, and PadDimsToNextMultipleOperation.

◆ selectedFields()

std::optional< std::unordered_set< std::string > > selectedFields ( const DataItem & item)

Get the fields on which the operation will be applied.

If active fields have been specified, will return them. Otherwise, will return the subset of the item's fields based on the default processing policy. A std::nullopt return value means that all fields should be considered.

◆ processImages()

virtual std::shared_ptr< SharedImageSet > processImages ( std::shared_ptr< SharedImageSet > input) const
protectedvirtual

Virtual function that every subclass should override.

Default implementation does nothing, so if those function are not implemented in a derived class, they won't act on the input in any way.

Reimplemented in SmoothCTEdgesOperation, XRayFixtureOperation, XRayUndoLogConversionOperation, AddCenterBoxOperation, AddPixelwisePredictionChannelOperation, AddPositionChannelOperation, AddRandomNoiseOperation, AdjustShiftScaleOperation, ApplyTopDownFlagOperation, ApproximateToHigherResolutionOperation, ArgMaxOperation, AxisFlipOperation, AxisRotationOperation, BakeDeformationOperation, BakePhotometricInterpretationOperation, BakeTransformationOperation, CheckDataOperation, ClipOperation, ConcatenateNeighboringFramesToChannelsOperation, ConvertSlicesToVolumeOperation, ConvertToGrayOperation, ConvertVolumeToSlicesOperation, ConvolutionalCRFOperation, CropOperation, CutOutOperation, DeformationOperation, EnsureExplicitMaskOperation, EnsureOneToOneMatrixMappingOperation, ExtractSubsetOperation, GammaCorrectionOperation, HighPassOperation, ImageMattingOperation, ImageROISampler, InvertOperation, KeepLargestComponentOperation, LinearIntensityMappingOperation, MakeFloatOperation, MorphologicalFilterOperation, MRIBiasFieldCorrectionOperation, MRIBiasFieldGenerationOperation, NormalizeMADOperation, NormalizeNormalOperation, NormalizePercentileOperation, NormalizeUniformOperation, OneHotOperation, PadDimsOperation, PadDimsToNextMultipleOperation, PadOperation, PolyCropOperation, RandomImageFromLabelOperation, RecombinePatchesOperation, RectifyRotationOperation, RemoveMaskOperation, ReplaceLabelsValuesOperation, ResampleDimsOperation, ResampleKeepingAspectRatioOperation, ResampleOperation, ResampleToInputOperation, ResolutionReductionOperation, RotationOperation, ScalingOperation, SelectChannelsOperation, SetMatrixToIdentityOperation, SetModalityOperation, SigmoidOperation, SmoothOperation, SoftmaxOperation, SplitIntoPatchesOperation, StandardizeImageAxesOperation, SyncOperation, TanhOperation, TemplateInpaintingOperation, ThresholdOperation, UndoPaddingOperation, and FrameFromVolumeOperation.

◆ processBoxes()

virtual std::shared_ptr< BoundingBoxSet > processBoxes ( std::shared_ptr< BoundingBoxSet > input) const
protectedvirtual

Virtual function that every subclass should override.

Default implementation does nothing, so if those function are not implemented in a derived class, they won't act on the input in any way.

Reimplemented in ConvertSlicesToVolumeOperation, ConvertVolumeToSlicesOperation, DeformationOperation, ExtractSubsetOperation, ImageROISampler, MatrixBasedOperation, SelectChannelsOperation, and FrameFromVolumeOperation.

◆ processPoints()

virtual std::shared_ptr< KeypointSet > processPoints ( std::shared_ptr< KeypointSet > input) const
protectedvirtual

Virtual function that every subclass should override.

Default implementation does nothing, so if those function are not implemented in a derived class, they won't act on the input in any way.

Reimplemented in ConvertSlicesToVolumeOperation, ConvertVolumeToSlicesOperation, DeformationOperation, ExtractSubsetOperation, ImageROISampler, MatrixBasedOperation, RandomKeypointJitterOperation, SelectChannelsOperation, and FrameFromVolumeOperation.

◆ processVectors()

virtual std::shared_ptr< SharedImageSet > processVectors ( std::shared_ptr< SharedImageSet > input) const
protectedvirtual

Virtual function that every subclass should override.

Default implementation does nothing, so if those function are not implemented in a derived class, they won't act on the input in any way.

Reimplemented in AddRandomNoiseOperation, ArgMaxOperation, ClipOperation, ExtractSubsetOperation, ImageROISampler, InvertOperation, LinearIntensityMappingOperation, OneHotOperation, ReplaceLabelsValuesOperation, SelectChannelsOperation, SigmoidOperation, SoftmaxOperation, TanhOperation, and ThresholdOperation.

◆ useGPU()

virtual bool useGPU ( const SharedImageSet * input) const
protectedvirtual

Helper function that returns which device the operation should choose based on its configuration and a given input.

Reimplemented in OneHotOperation.

◆ allowChannelBatchOnGPU()

virtual bool allowChannelBatchOnGPU ( ) const
inlineprotectedvirtual

Whether the operation implements channel-batching so that it can still be run on input with more than 4 channels.

Reimplemented in ForegroundGuidedLabelUpsamplingOperation, MatrixBasedOperation, ResampleDimsOperation, ResampleOperation, ResampleToInputOperation, ResolutionReductionOperation, ScalingOperation, and StandardizeImageAxesOperation.

◆ configureOnly()

bool configureOnly ( const Properties & properties,
const std::vector< ParameterBase * > & paramSelection )
protectednoexcept

Helper method to configure only a subset of parameters.

Useful when configuring Operations derived from other operations.

◆ setManuallyConfiguredParameters()

void setManuallyConfiguredParameters ( const std::vector< ParameterBase * > & manuallyConfiguredParams)
protected

Disable the auto-configuration of some of the parameters so that they can be parsed manually (in the configure function of the derived class).

This mechanism is only useful in a small number of cases.

◆ applyPreProcessHooks()

void applyPreProcessHooks ( DataElement * element)
protected

Apply the current pre-process hooks to an element.

Parameters
elementThe element to apply hooks to

◆ applyPostProcessHooks()

void applyPostProcessHooks ( DataElement * element)
protected

Apply the current post-process hooks to an element.

Parameters
elementThe element to apply hooks to

Member Data Documentation

◆ m_alreadyWarned

std::unordered_set<std::string> m_alreadyWarned
mutableprotected
Initial value:
=
{}

Set of warnings about unexpected behavior that have already been printed.

◆ m_requiredFieldsTypes

std::unordered_map<std::string, ElementType> m_requiredFieldsTypes
protected
Initial value:
=
{}

List of all required field types used by checkRequiredItemsTypes.

◆ m_recordIdentifier

std::string m_recordIdentifier
protected

User-provided unique identifier for this operation, used for recording processing history and inversion.

Setting this parameter to a non-empty string allows the operation to be inverted using InverseOperation if the operation supports inversion.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close