Skip to main content

register_rigid

Function register_rigid 

Source
pub fn register_rigid(
    fixed: &[f64],
    fixed_dims: (usize, usize, usize),
    fixed_affine: &[f64; 16],
    moving: &[f64],
    moving_dims: (usize, usize, usize),
    moving_affine: &[f64; 16],
    mask: Option<&[u8]>,
    params: &RigidParams,
) -> Option<RigidTransform>
Expand description

Estimate the rigid transform that aligns moving to fixed.

Both volumes are column-major with their own dimensions and row-major voxel→world affine; they need not share a grid, voxel size or orientation. mask is optional and lives on the fixed grid: it restricts which fixed voxels the metric looks at, and a brain mask is worth passing — it keeps air, neck and the receive-field falloff out of the correlation.

Returns None if either affine is singular, if a volume’s data length does not match its dimensions, or if the metric could never be evaluated (empty mask, no overlap anywhere).

§Example

use qsm_core::registration::{register_rigid, RigidParams};
let t = register_rigid(
    fixed, dims, a_fixed,
    moving, dims, a_moving,
    Some(brain), &RigidParams::default(),
)?;
// The moving orientation's field map, on the fixed grid, with the B0 direction to match.
let field_on_common_grid = t.resample(moving)?;
let bdir = t.b0_direction_in_fixed(None);