go home Home | Main Page | Topics | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Loading...
Searching...
No Matches
ImpactTensorUtils Namespace Reference

Typedefs

template<typename ImagePointType>
using ImagesPatchValuesAndJacobiansEvaluator
template<typename ImagePointType>
using ImagesPatchValuesEvaluator

Functions

template<class ImagePointType>
std::vector< torch::Tensor > GenerateOutputs (const std::vector< itk::ImpactModelConfiguration > &modelConfig, const std::vector< ImagePointType > &fixedPoints, const std::vector< std::vector< std::vector< std::vector< float > > > > &patchIndex, const std::vector< torch::Tensor > subsetsOfFeatures, torch::Device device, const ImpactTensorUtils::ImagesPatchValuesEvaluator< ImagePointType > &imagesPatchValuesEvaluator)
template<typename ImagePointType>
std::vector< torch::Tensor > GenerateOutputsAndJacobian (const std::vector< itk::ImpactModelConfiguration > &modelConfig, const std::vector< ImagePointType > &fixedPoints, const std::vector< std::vector< std::vector< std::vector< float > > > > &patchIndex, std::vector< torch::Tensor > subsetsOfFeatures, std::vector< torch::Tensor > fixedOutputsTensor, torch::Device device, std::vector< std::unique_ptr< ImpactLoss::Loss > > &losses, const ImpactTensorUtils::ImagesPatchValuesAndJacobiansEvaluator< ImagePointType > &imagesPatchValuesAndJacobiansEvaluator)
template<typename TImage, typename FeaturesMaps, typename InterpolatorType, typename FeaturesImageType>
std::vector< FeaturesMaps > GetFeaturesMaps (typename TImage::ConstPointer image, typename InterpolatorType::Pointer interpolator, const std::vector< itk::ImpactModelConfiguration > &modelsConfiguration, torch::Device device, std::vector< unsigned int > pca, std::vector< torch::Tensor > &principalComponents, const std::function< void(typename TImage::ConstPointer, torch::Tensor &, const std::string &)> &writeInputImage, const std::function< typename TImage::PointType(const typename TImage::PointType &)> &transformPoint=nullptr)
std::vector< torch::Tensor > GetModelOutputsExample (std::vector< itk::ImpactModelConfiguration > &modelsConfig, const std::string &modelType, torch::Device device)
std::vector< std::vector< float > > GetPatchIndex (const itk::ImpactModelConfiguration &modelConfiguration, std::mt19937 &randomGenerator, unsigned int dimension)
template<typename TImage, typename TInterpolator>
torch::Tensor ImageToTensor (typename TImage::ConstPointer image, typename TInterpolator::Pointer interpolator, const std::vector< float > &voxelSize, const std::function< typename TImage::PointType(const typename TImage::PointType &)> &transformPoint)
template<typename TImage, typename TFeatureImage>
TFeatureImage::Pointer TensorToImage (typename TImage::ConstPointer image, torch::Tensor layers)

Typedef Documentation

◆ ImagesPatchValuesAndJacobiansEvaluator

template<typename ImagePointType>
using ImpactTensorUtils::ImagesPatchValuesAndJacobiansEvaluator
Initial value:
std::function<torch::Tensor(const ImagePointType &,
torch::Tensor &,
const std::vector<std::vector<float>> &,
const std::vector<int64_t> &,
int)>

Definition at line 174 of file ImpactTensorUtils.h.

◆ ImagesPatchValuesEvaluator

template<typename ImagePointType>
using ImpactTensorUtils::ImagesPatchValuesEvaluator
Initial value:
std::function<
torch::Tensor(const ImagePointType &, const std::vector<std::vector<float>> &, const std::vector<int64_t> &)>

Definition at line 146 of file ImpactTensorUtils.h.

Function Documentation

◆ GenerateOutputs()

template<class ImagePointType>
std::vector< torch::Tensor > ImpactTensorUtils::GenerateOutputs ( const std::vector< itk::ImpactModelConfiguration > & modelConfig,
const std::vector< ImagePointType > & fixedPoints,
const std::vector< std::vector< std::vector< std::vector< float > > > > & patchIndex,
const std::vector< torch::Tensor > subsetsOfFeatures,
torch::Device device,
const ImpactTensorUtils::ImagesPatchValuesEvaluator< ImagePointType > & imagesPatchValuesEvaluator )

Computes feature outputs for all patches using each model.

This function computes feature outputs for each patch by running a forward pass through the model and applying optional feature sub-selection.

Parameters
modelConfigVector of model configurations (dimensions, patch sizes, voxel sizes, etc.).
fixedPointsCentral points on the fixed image where features are computed.
patchIndexIndices defining the local patches around each point.
subsetsOfFeaturesTensors containing indices of feature channels to select.
deviceThe device (CPU or GPU) to perform the computation on.
imagesPatchValuesEvaluatorCallable that evaluate image values.
Returns
A vector of tensors containing the computed feature outputs for each patch.

◆ GenerateOutputsAndJacobian()

template<typename ImagePointType>
std::vector< torch::Tensor > ImpactTensorUtils::GenerateOutputsAndJacobian ( const std::vector< itk::ImpactModelConfiguration > & modelConfig,
const std::vector< ImagePointType > & fixedPoints,
const std::vector< std::vector< std::vector< std::vector< float > > > > & patchIndex,
std::vector< torch::Tensor > subsetsOfFeatures,
std::vector< torch::Tensor > fixedOutputsTensor,
torch::Device device,
std::vector< std::unique_ptr< ImpactLoss::Loss > > & losses,
const ImpactTensorUtils::ImagesPatchValuesAndJacobiansEvaluator< ImagePointType > & imagesPatchValuesAndJacobiansEvaluator )

Computes feature outputs and their spatial Jacobians for image registration.

This function calculates the feature outputs and their corresponding Jacobians at given points to aid in optimization. The Jacobians are used for gradient computation during image registration.

Parameters
modelConfigVector of model configurations (dimensions, patch sizes, voxel sizes, etc.).
fixedPointsCentral points on the fixed image where features are computed.
patchIndexIndices defining the local patches around each point for feature extraction.
subsetsOfFeaturesTensors containing indices of feature channels to select.
fixedOutputsTensorTensor containing feature outputs from the fixed image.
deviceThe device (CPU or GPU) to perform the computation on.
lossesVector of loss objects to be updated incrementally during optimization.
imagesPatchValuesAndJacobiansEvaluatorCallable that evaluate image values and Jacobians.
Returns
A vector of tensors with computed feature outputs.

◆ GetFeaturesMaps()

template<typename TImage, typename FeaturesMaps, typename InterpolatorType, typename FeaturesImageType>
std::vector< FeaturesMaps > ImpactTensorUtils::GetFeaturesMaps ( typename TImage::ConstPointer image,
typename InterpolatorType::Pointer interpolator,
const std::vector< itk::ImpactModelConfiguration > & modelsConfiguration,
torch::Device device,
std::vector< unsigned int > pca,
std::vector< torch::Tensor > & principalComponents,
const std::function< void(typename TImage::ConstPointer, torch::Tensor &, const std::string &)> & writeInputImage,
const std::function< typename TImage::PointType(const typename TImage::PointType &)> & transformPoint = nullptr )

Applies one or more models to an image to extract feature maps.

This function extracts feature maps from an image using one or more models. Optionally, it can export the resampled input image for debugging purposes.

Parameters
imageThe input image from which features are extracted.
interpolatorThe interpolator used for resampling.
modelsConfigurationThe configuration of the models used for feature extraction.
deviceThe device (CPU or GPU) to perform the computation on.
pcaThe number of principal components for dimensionality reduction.
principalComponentsA vector to store the computed principal components.
writeInputImageOptional function to export the resampled input image for debugging.
transformPointptional function to transform a point, used for geometric transformations on the moving image.
Returns
A vector of ITK feature images, one per layer and model.

◆ GetModelOutputsExample()

std::vector< torch::Tensor > ImpactTensorUtils::GetModelOutputsExample ( std::vector< itk::ImpactModelConfiguration > & modelsConfig,
const std::string & modelType,
torch::Device device )

Tests the configuration of each model by generating outputs from dummy input.

This function validates the compatibility of TorchScript models and checks the output structure (e.g., number of layers, spatial shape, channels). It ensures that models are properly loaded and executable during initialization.

Parameters
modelsConfigVector of model configurations.
modelTypeThe type of the model being tested (fixed, moving) for logging errors.
deviceThe device (CPU or GPU) to perform the computation on.
Returns
A vector of tensors with the generated outputs from dummy input.

◆ GetPatchIndex()

std::vector< std::vector< float > > ImpactTensorUtils::GetPatchIndex ( const itk::ImpactModelConfiguration & modelConfiguration,
std::mt19937 & randomGenerator,
unsigned int dimension )

Computes patch index offsets around a center point based on model configuration.

This function generates the offsets for local patches (e.g., 5x5x5) around a center point using the model's configuration. It helps in extracting features from local neighborhoods.

Parameters
modelConfigurationConfiguration of the model, including patch size and voxel size.
randomGeneratorRandom generator used for randomizing 2D patch slices in a 3D volume.
dimensionThe image dimension (2D or 3D).
Returns
A vector of offsets for the patch around the center point.

◆ ImageToTensor()

template<typename TImage, typename TInterpolator>
torch::Tensor ImpactTensorUtils::ImageToTensor ( typename TImage::ConstPointer image,
typename TInterpolator::Pointer interpolator,
const std::vector< float > & voxelSize,
const std::function< typename TImage::PointType(const typename TImage::PointType &)> & transformPoint )

Converts an ITK image to a Torch tensor using physical spacing.

Parameters
voxelSizeTarget voxel size in mm, used for resampling the image.
transformPointOptional point-wise transform to apply to the moving image.
Returns
A Torch tensor representing the resampled ITK image.

◆ TensorToImage()

template<typename TImage, typename TFeatureImage>
TFeatureImage::Pointer ImpactTensorUtils::TensorToImage ( typename TImage::ConstPointer image,
torch::Tensor layers )

Converts a tensor (C×D×H×W) to a multi-channel ITK image. Converts the given tensor to an ITK image, preserving the original image metadata (origin, spacing, direction).

Parameters
imageThe original input image used to retrieve metadata.
layersThe tensor representing the feature layers.
Returns
A multi-channel ITK image constructed from the tensor.


Generated on 1774142652 for elastix by doxygen 1.15.0 elastix logo