nifreeze.registration package¶
Registration of each volume to its prediction, through interchangeable backends.
- class nifreeze.registration.Registration(self, align_config: 'Mapping | str | PathLike | None' = None, *, seed: 'int | None' = None, num_threads: 'int | None' = None, clip: 'str | bool | None' = 'both', debug_dir: 'str | Path | None' = None, phase_encoding: 'str | None' = None) 'None'[source]¶
Bases:
ABCEstimate the transform that maps each point of a fixed image into a moving one.
The fixed image is the model’s prediction; the moving image is the sample, on the same grid. Calls run one at a time (elastix sets ITK’s process-wide thread count).
- Parameters:
align_config (
Mappingoros.pathlike, optional) – The backend’s settings, or a YAML file with a section per backend, such asRIGID(the default) andAFFINE(seeload_config()).seed (
int, optional) – Seed of the backend’s random sampling.num_threads (
int, optional) – Threads of each registration.clip (
str, optional) – Clip"sample","predicted","both"(default) or"none"of the images to the sample’s intensity window, estimated within the mask.debug_dir (
os.pathlike, optional) – Keeppredicted_<index>.niiandsample_<index>.nii, the values registered, andaligned_<index>.nii, the sample with its affine corrected by the estimate (a viewer shows it on top of the prediction).phase_encoding (
str, optional) – The images’ phase-encoding direction, as BIDS writesPhaseEncodingDirection(i,jork, with an optional-). Only backends whose settings restrict a field to it use it (seesplit()).
- __call__(fixed: ndarray, moving: ndarray, affine: ndarray, mask: ndarray | None = None, index: int = 0, init: ndarray | None = None) Affine[source]¶
Register one volume.
- Parameters:
fixed, moving (
ndarray) – The fixed image (the prediction) and the moving one (the sample).affine (
ndarray) – The voxel-to-RAS+ affine of their grid.mask (
ndarray, optional) – The mask of the fixed image (the moving one is never masked).index (
int, optional) – The volume’s index, which names its files.init (
ndarray, optional) – The initial estimate, a RAS+ fixed-to-moving matrix.
- Returns:
The fixed-to-moving transform (RAS+), the initialization included.
- Return type:
- split(matrix: ndarray, affine: ndarray) tuple[ndarray, ndarray] | None[source]¶
Split an estimate into head motion and a field, when the backend models both.
A backend whose settings restrict the field to the phase-encoding direction estimates each mapping as head motion, then that field, and returns the two (see
split_phase_encoding()). The others returnNone, and the estimate is stored whole.
- class nifreeze.registration.RegistrationFactory(self, /, *args, **kwargs)[source]¶
Bases:
objectBuild a registration backend by name, as models are built by name.