nifreeze.analysis.motion module

Motion analysis.

nifreeze.analysis.motion.compute_percentage_change(reference: ndarray, test: ndarray, mask: ndarray) ndarray[source]

Compute motion change between reference and test as a percentage.

If a mask is provided, the computation is only provided within the mask. Also, null values are ignored.

Parameters:
  • reference (ndarray) – Reference imaging volume.

  • test (ndarray) – Test (shifted) imaging volume.

  • mask (ndarray) – Mask for value consideration.

Returns:

rel_diff – Motion change between reference and test.

Return type:

ndarray

nifreeze.analysis.motion.identify_spikes(fd: ndarray, threshold: float = 2.0)[source]

Identify motion spikes in framewise displacement data.

Identifies high-motion frames as timepoint exceeding a given threshold value based on z-score normalized framewise displacement (FD) values.

Parameters:
  • fd (ndarray) – Framewise displacement data.

  • threshold (float, optional) – Threshold value to determine motion spikes.

Returns:

  • indices (ndarray) – Indices of identified motion spikes.

  • mask (ndarray) – Mask of identified motion spikes.