Skip to content

File I/O

yet_another_imod_wrapper.utils.io

read_xf(file)

Read an IMOD xf file into an (n, 6) numpy array.

An xf file contains one line with six numbers per image in the tilt-series, each specifying a linear transformation:

A11 A12 A21 A22 DX DY

where the coordinate (X, Y) is transformed to (X', Y') by:

X' = A11 * X + A12 * Y + DX
Y' = A21 * X + A22 * Y + DY
Source code in src/yet_another_imod_wrapper/utils/io.py
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def read_xf(file: os.PathLike) -> np.ndarray:
    """Read an IMOD xf file into an (n, 6) numpy array.

    An xf file contains one line with six numbers per image in the tilt-series,
    each specifying a linear transformation:

        A11 A12 A21 A22 DX DY

    where the coordinate (X, Y) is transformed to (X', Y') by:

        X' = A11 * X + A12 * Y + DX
        Y' = A21 * X + A22 * Y + DY
    """
    return np.loadtxt(fname=file, dtype=float).reshape((-1, 6))

read_tlt(file)

Read an IMOD tlt file into an (n, ) numpy array.

Source code in src/yet_another_imod_wrapper/utils/io.py
 8
 9
10
11
12
13
def read_tlt(file: os.PathLike) -> np.ndarray:
    """Read an IMOD tlt file into an (n, ) numpy array.


    """
    return np.loadtxt(fname=file, dtype=float).reshape(-1)

Model files

Support for reading model (.mod) files is provided in a separate package imodmodel. [repo, docs]