mne.chpi.refit_hpi#

mne.chpi.refit_hpi(info, *, amplitudes=True, locs=True, order=True, ext_order=1, gof_limit=0.98, dist_limit=0.005, use=None, colinearity_limit=0, verbose=None)[source]#

Refit HPI coil order.

This operates inplace on info, and will typically be called via refit_hpi(raw.info) before further processing.

Parameters:
infoinstance of Info

The measurement info.

amplitudesbool

Whether to recompute the HPI amplitudes (slopes) from the raw data obtained during the original fit using compute_chpi_amplitudes(), or used the already-computed ones stored in info['hpi_meas']. If this is True, locs and order must also be True.

locsbool

Whether to recompute the HPI coil locations using compute_chpi_locs(), or use the already-computed ones stored in info['hpi_results']. If this is True, order must also be True.

orderbool

Whether to refit the coil order by testing all permutations for the best goodness of fit between digitized coil locations and (rigid-transformed) fitted coil locations.

ext_orderint

The external order for SSS-like interfence suppression. The SSS bases are used as projection vectors during fitting.

Changed in version 0.20: Added ext_order=1 by default, which should improve detection of true HPI signals.

gof_limitfloat

The goodness-of-fit limit to use when choosing which coils to use for refitting.

dist_limitfloat

The distance limit (in meters) to use when choosing which coils to use for refitting.

useint | None

The maximum number of coils to use when testing different coil orderings. The default for hpifit in MEGIN software is 3. Default (None) means to use all coils above gof_limit. Can also be an ndarray of coil indices (0-indexed!) to use, e.g., [1, 2, 4].

colinearity_limitfloat

The RMS limit (in meters) to use when checking for colinearity of coil locations. If the RMS difference between the used points and a best-fit linear approximation is less than this limit, a warning is emitted. The default (0) avoids colinearity warnings altogether. The appropriate value here is dataset dependent, but for one problematic dataset the value of 0.03 worked well.

verbosebool | str | int | None

Control verbosity of the logging output. If None, use the default verbosity level. See the logging documentation and mne.verbose() for details. Should only be passed as a keyword argument.

Returns:
infoinstance of Info

The modified measurement info (same as input).

Notes

This adds additional entries to info["hpi_meas"] and info["hpi_results"], leaving the existing ones intact. It will always modify info["dev_head_t"] inplace.

The algorithm is as follows:

  1. Optionally recompute HPI amplitudes (sinusoidal fit for each channel) using compute_chpi_amplitudes().

  2. Optionally use HPI amplitudes to fit HPI coil locations using compute_chpi_locs().

  3. Optionally determine coil digitization order by testing all permutations for the best goodness of fit between digitized coil locations and (rigid-transformed) fitted coil locations.

  4. Subselect coils to use for fitting dev_head_t based on gof_limit, dist_limit, and use.

  5. Update info inplace by modifying info["dev_head_t"] and appending new entries to info["hpi_meas"] and info["hpi_results"].

New in v1.11.