tools.estimate_rigid_motion

tools.estimate_rigid_motion#

bartorch.tools.estimate_rigid_motion()#

Rigid pose of each shot of a segmented 3D acquisition relative to the first, and its image.

Each of steps Gauss-Newton steps linearises the encoding of rigid_encoding() about the current poses and image and solves for the image and the pose steps together, by iterations conjugate gradients on \(\| A x + J \delta - y \|^2 + \lambda \| (x, \delta) \|^2\) with \(J\) scaled to unit columns, from the current image. Solved jointly, the image cannot absorb the inconsistency a pose leaves in the data, as it does when the two are fitted in turn. \(J\) is in closed form: a turn \(\delta\) composed after \(R_s\) moves the rotated wavenumber \(k'\) by \(-\delta \times k'\), so a sample’s derivative along it is \(2\pi i\, k' \times \mathcal{F}[S x\, r]\), which one transform of the image weighted by its position \(r\) gives for every shot at once; a shift multiplies a sample by \(-2\pi i\, k\). The normal chains the transforms rather than applying the encoding’s Toeplitz normal, whose gridding error biases the poses of a thin slab by a few hundredths of a voxel. The first shot stays at rest. Data are scaled to a peak of one for the solve. With centre below one, the fit runs on the central fraction of k-space along each axis, on the coarser grid of the same field of view, the maps and the starting image resampled onto it.

Parameters:
  • kspace (torch.Tensor) – (coils, z, y, x) centred k-space and coil maps.

  • maps (torch.Tensor) – (coils, z, y, x) centred k-space and coil maps.

  • masks (torch.Tensor) – (shots, z, y) booleans, the lines each shot placed.

  • image (torch.Tensor) – (z, y, x) complex starting image, in the first shot’s pose.

  • voxel_size (tuple of float) – (z, y, x) voxel size, in the length unit of the shifts.

  • rotations (torch.Tensor, default=None) – (shots, 3, 3) and (shots, 3) starting poses, as rigid_encoding() takes them; None starts at rest.

  • shifts (torch.Tensor, default=None) – (shots, 3, 3) and (shots, 3) starting poses, as rigid_encoding() takes them; None starts at rest.

  • steps (int, default=3) – Gauss-Newton steps.

  • iterations (int, default=40) – Conjugate-gradient iterations of each step.

  • lambda (float, default=1e-5) – Tikhonov weight of the joint solve, on the image and on the scaled pose steps alike; a larger weight damps the pose steps enough to stall them.

  • centre (float, default=1.0) – Fraction of k-space, along each axis, the fit reads.

  • device (torch.device or str, default=None) – Where the transforms run.

Returns:

  • rotations (torch.Tensor) – (shots, 3, 3) float64 rotation matrices.

  • shifts (torch.Tensor) – (shots, 3) float64 displacements.

  • image (torch.Tensor) – (z, y, x) image of the last step, on the grid the fit ran on, on the device of image.

  • residual (float) – ||A x - M y|| / ||M y|| of that image under the returned poses.