spyrit.misc.dual_arm.MotionFieldProjector
- class spyrit.misc.dual_arm.MotionFieldProjector(deform_path: str | Path, deform_prefix: str, n: int, M: int, n_ppg: int, T: float, frame_ref: int = 0, homography: Tensor = tensor([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), translation: Tuple[float, float] = (0.0, 0.0), dtype: dtype | None = torch.float64, device: str | device | None = device(type='cpu'))[source]
Bases:
ModuleProjects the motion fields from the CMOS camera perspective to the single-pixel camera (SPC) perspective.
- This class loads pre-computed motion fields from NIfTI files and performs:
Geometric transformation via homography (CMOS to SPC coordinate mapping)
Temporal interpolation to match the SPC acquisition timing for each illumination pattern
Reference frame definition
The result is a motion field suitable for dynamic single-pixel imaging applications.
- Args:
deform_path: Path to deformation field files.deform_prefix: Prefix for deformation files.n: Pattern size.M: Number of illumination patterns.n_ppg: Number of patterns per gate. A gate is defined as the set of patterns between two CMOS frames.T: Total acquisition time.frame_ref(optional): Reference frame index.homography(optional): 3x3 homography transformation matrix.translation(optional): Translation offset (x, y).dtype(optional): Data type for computations (torch.float32, torch.float64, etc.).device(optional): Device to use for computations (‘cpu’, ‘cuda’, etc.).- Raises:
FileNotFoundError: If deformation path doesn’t exist. ValueError: If homography matrix is not 3x3.
Methods
Define reference frame by subtracting reference deformation from all frames.
estim_motion_from_CMOS(warping[, amp_max])Estimate motion field from CMOS camera data.
forward(warping[, amp_max])Complete forward pass for motion estimation.
Interpolate deformation field between frames for SPC acquisition timing.