create_score_object#

create_score_object(score, **kwargs)[source]#

Initialize score object with name score using **kwargs.

Parameters:
score: str

Name of the score.

**kwargs: Dict

Keyword arguments passed to the __init__ method of the score object.

Returns:
object

Initialized score object.

Raises:
ValueError

If score is not a key in MATCHING_OPTIMIZATION_REGISTER.

See also

register_matching_optimization()

Examples

>>> from tme import Density
>>> from tme.matching_utils import create_mask, euler_to_rotationmatrix
>>> from tme.matching_optimization import CrossCorrelation, optimize_match
>>> translation, rotation = (5, -2, 7), (5, -10, 2)
>>> target = create_mask(
>>>     mask_type="ellipse",
>>>     radius=(5,5,5),
>>>     shape=(51,51,51),
>>>     center=(25,25,25),
>>> ).astype(float)
>>> template = Density(data=target)
>>> template = template.rigid_transform(
>>>     translation=translation,
>>>     rotation_matrix=euler_to_rotationmatrix(rotation),
>>> )
>>> template_coordinates = template.to_pointcloud(0)
>>> template_weights = template.data[tuple(template_coordinates)]
>>> score_object = CrossCorrelation(
>>>     target=target,
>>>     template_coordinates=template_coordinates,
>>>     template_weights=template_weights,
>>>     negate_score=True # Multiply returned score with -1 for minimization
>>> )