Source code for timagetk.io.trsf

#!/usr/bin/env python
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#  Copyright (c) 2022 Univ. Lyon, ENS de Lyon, UCB Lyon 1, CNRS, INRAe, Inria
#  All rights reserved.
#  This file is part of the TimageTK library, and is released under the "GPLv3"
#  license. Please see the LICENSE.md file that should have been included as
#  part of this package.
# ------------------------------------------------------------------------------

"""Input/Output for Trsf objects."""

from timagetk.bin.logger import get_logger
from timagetk.components.trsf import Trsf

log = get_logger(__name__)


[docs] def save_trsf(trsf, filename): """Write a ``Trsf`` under given ``filename``. Parameters ---------- trsf : Trsf Transformation object to save. filename : str Name of the file to write. """ try: assert isinstance(trsf, Trsf) except AssertionError: raise TypeError("This is not a `Trsf` instance!") log.debug(f"Saving transformation file: {filename}") trsf.write(filename) return
[docs] def read_trsf(filename): """Read a transformation file. Parameters ---------- filename : str Name of the file containing a ``Trsf`` object. Returns ------- Trsf The loaded transformation object. """ log.debug(f"Loading transformation file: {filename}") trsf = Trsf(filename) return trsf