Orientations#

class Orientations(translations, rotations, scores, details)[source]#

Bases: object

Handle template matching orientations and conversion between formats.

Parameters:
translations: np.ndarray

Array with translations of each orientations (n, d).

rotations: np.ndarray

Array with euler angles of each orientation in zxy convention (n, d).

scores: np.ndarray

Array with the score of each orientation (n, ).

details: np.ndarray

Array with additional orientation details (n, ).

Examples

The following achieves the minimal definition of an Orientations instance

>>> import numpy as np
>>> from tme import Orientations
>>> translations = np.random.randint(low = 0, high = 100, size = (100,3))
>>> rotations = np.random.rand(100, 3)
>>> scores = np.random.rand(100)
>>> details = np.full((100,), fill_value = -1)
>>> orientations = Orientations(
>>>     translations = translations,
>>>     rotations = rotations,
>>>     scores = scores,
>>>     details = details,
>>> )

The created orientations object can be written to disk in a range of formats. See Orientations.to_file() for available formats. The following creates a STAR file

>>> orientations.to_file("test.star")

Orientations.from_file() can create Orientations instances from a range of formats, to enable conversion between formats

>>> orientations_star = Orientations.from_file("test.star")
>>> np.all(orientations.translations == orientations_star.translations)
True

Attributes

Orientations.translations

Array with translations of each orientation (n, d).

Orientations.rotations

Array with zyx euler angles of each orientation (n, d).

Orientations.scores

Array with scores of each orientation (n, ).

Orientations.details

Array with additional details of each orientation(n, ).

Methods

Orientations.copy()

Create a copy of the current class instance.

Orientations.from_file(filename[, file_format])

Create an instance of Orientations from a file.

Orientations.get_extraction_slices(...[, ...])

Calculate slices for extracting regions of interest within a larger array.

Orientations.to_file(filename[, file_format])

Save the current class instance to a file in the specified format.