MatchingData#

class MatchingData(target, template, template_mask=None, target_mask=None, invert_target=False, rotations=None)[source]#

Bases: object

Contains data required for template matching.

Parameters:
targetnp.ndarray or tme.density.Density

Target data.

templatenp.ndarray or tme.density.Density

Template data.

target_masknp.ndarray or tme.density.Density, optional

Target mask data.

template_masknp.ndarray or tme.density.Density, optional

Template mask data.

invert_targetbool, optional

Whether to invert the target before template matching..

rotations: np.ndarray, optional

Template rotations to sample. Can be a single (d, d) or a stack (n, d, d) of rotation matrices where d is the dimension of the template.

Examples

The following achieves the minimal definition of a MatchingData instance.

>>> import numpy as np
>>> from tme.matching_data import MatchingData
>>> target = np.random.rand(50,40,60)
>>> template = target[15:25, 10:20, 30:40]
>>> matching_data = MatchingData(target=target, template=template)

Attributes

MatchingData.rotations

Return stored rotation matrices.

MatchingData.target

Return the target.

MatchingData.target_filter

Returns the composable target filter.

MatchingData.target_mask

Return the target mask.

MatchingData.template

Return the reversed template.

MatchingData.template_filter

Returns the composable template filter.

MatchingData.template_mask

Return the reversed template mask.

Methods

MatchingData.fourier_padding([pad_fourier])

Computes efficient shape four Fourier transforms and potential associated shifts.

MatchingData.subset_array(arr, arr_slice, ...)

Extract a subset of the input array according to the given slice and apply padding.

MatchingData.subset_by_slice([target_slice, ...])

Subset class instance based on slices.

MatchingData.target_padding([pad_target])

Computes padding for the target based on the template's shape.

MatchingData.to_backend()

Transfer and convert types of class instance's data arrays to the current backend