Source code for AFQ.recognition.preprocess

from functools import cached_property

import numpy as np

import AFQ.recognition.utils as abu


[docs] class PreprocPlan: def __init__(self, tg):
[docs] self.tg = tg
@cached_property
[docs] def fgarray(self): return np.asarray(abu.resample_tg(self.tg, 20), dtype=np.float32)
@cached_property
[docs] def crosses(self): return np.logical_and( np.any(self.fgarray[:, :, 0] > 0, axis=1), np.any(self.fgarray[:, :, 0] < 0, axis=1), )
@cached_property
[docs] def lengths(self): segments = np.diff(self.fgarray, axis=1) return np.sum(np.sqrt(np.sum(segments**2, axis=2)), axis=1)
@cached_property
[docs] def endpoint_dists(self): return np.linalg.norm(self.fgarray[:, 0, :] - self.fgarray[:, -1, :], axis=1)