From 28ee215c6cc0f10c55f63220894618d2f09934f8 Mon Sep 17 00:00:00 2001 From: Patrick Kaifosh Date: Fri, 16 Jan 2015 14:09:05 -0500 Subject: [PATCH] Created Transform class for motion correction --- sima/motion/transform.py | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 sima/motion/transform.py diff --git a/sima/motion/transform.py b/sima/motion/transform.py new file mode 100644 index 0000000..df2c525 --- /dev/null +++ b/sima/motion/transform.py @@ -0,0 +1,54 @@ +import abc + + +class Transform(object): + """Abstract class for geometric transforms.""" + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def apply(self, source, grid=None): + """Apply the transform to raw source data. + + Parameters + ---------- + source : np.ndarray + grid : + + Returns + ------- + transformed : np.ndarray + """ + pass + + +class InvertibleTransform(Transform): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def inverse(self): + pass + + +class DifferentiableTransform(Transform): + __metaclass__ = abc.ABCMeta + + @abc.abstractmethod + def jacobian(self): + pass + + +class NullTransform(Transform): + """Class to represent a null transform. + + This may be useful to indicate that a transform could not be estimated. + It could return a grid of all NaN values when applied. + """ + pass + + +class Identity(Transform): + pass + + +class WithinFrameTranslation(Transform): + pass