<commit_before># -*- coding: utf-8 -*-
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>


# License: BSD (3-clause)

from functools import partial
from math import factorial
from os import path as op

import numpy as np
from scipy import linalg

from .. import __version__
from ..annotations import _annotations_starts_stops
from ..bem import _check_origin
from ..transforms import (_str_to_frame, _get_trans, Transform, apply_trans,
                          _find_vector_rotation, _cart_to_sph, _get_n_moments,
                          _sph_to_cart_partials, _deg_ord_idx, _average_quats,
                          _sh_complex_to_real, _sh_real_to_complex, _sh_negate,
                          quat_to_rot, rot_to_quat)
from ..forward import _concatenate_coils, _prep_meg_channels, _create_meg_coils
from ..surface import _normalize_vectors
from ..io.constants import FIFF, FWD
from ..io.meas_info import _simplify_info
from ..io.proc_history import _read_ctc
from ..io.write import _generate_meas_id, DATE_NONE
from ..io import _loc_to_coil_trans, _coil_trans_to_loc, BaseRaw
from ..io.pick import pick_types, pick_info
from ..utils import (verbose, logger, _clean_names, warn, _time_mask, _pl,
                     _check_option)
from ..fixes import _get_args, _safe_svd, einsum, bincount
from ..channels.channels import _get_T1T2_mag_inds


# Note: MF uses single precision and some algorithms might use
# truncated versions of constants (e.g., μ0), which could lead to small
# differences between algorithms


@verbose
def maxwell_filter(raw, origin='auto', int_order=8, ext_order=3,
                   calibration=None, cross_talk=None, st_duration=None,
                   st_correlation=0.98, coord_frame='head', destination=None,
                   regularize='in', ignore_ref=False, bad_condition='error',
                   head_pos=None, st_fixed=True, st_only=False, mag_scale=100.,
                   skip_by_annotation=('edge', 'bad_acq_skip'), verbose=None):
    """Maxwell filter data using multipole moments.

    Parameters
    ----------
    raw : instance of mne.io.Raw
        Data to be filtered.

        .. warning:: Automatic bad channel detection is not currently
                     implemented. It is critical to mark bad channels in
                     ``raw.info['bads']`` prior to processing
                     in orider to prevent artifact spreading.
    origin : array-like, shape (3,) | str
        Origin of internal and external multipolar moment space in meters.
        The default is ``'auto'``, which means ``(0., 0., 0.)`` when
        ``coord_frame='meg'``, and a head-digitization-based
        origin fit using :func:`~mne.bem.fit_sphere_to_headshape`
        when ``coord_frame='head'``. If automatic fitting fails (e.g., due
        to having too few digitization points),
        consider separately calling the fitting function with different
        options or specifying the origin manually.
    int_order : int
        Order of internal component of spherical expansion.
    ext_order : int
        Order of external component of spherical expansion.
    calibration : str | None
        Path to the ``'.dat'`` file with fine calibration coefficients.
        File can have 1D or 3D gradiometer imbalance correction.
        This file is machine/site-specific.<commit_msg>DOC: Fix typo (#7389)<commit_after># -*- coding: utf-8 -*-
# Authors: <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>
#          <NAME> <<EMAIL>>


# License: BSD (3-clause)

from functools import partial
from math import factorial
from os import path as op

import numpy as np
from scipy import linalg

from .. import __version__
from ..annotations import _annotations_starts_stops
from ..bem import _check_origin
from ..transforms import (_str_to_frame, _get_trans, Transform, apply_trans,
                          _find_vector_rotation, _cart_to_sph, _get_n_moments,
                          _sph_to_cart_partials, _deg_ord_idx, _average_quats,
                          _sh_complex_to_real, _sh_real_to_complex, _sh_negate,
                          quat_to_rot, rot_to_quat)
from ..forward import _concatenate_coils, _prep_meg_channels, _create_meg_coils
from ..surface import _normalize_vectors
from ..io.constants import FIFF, FWD
from ..io.meas_info import _simplify_info
from ..io.proc_history import _read_ctc
from ..io.write import _generate_meas_id, DATE_NONE
from ..io import _loc_to_coil_trans, _coil_trans_to_loc, BaseRaw
from ..io.pick import pick_types, pick_info
from ..utils import (verbose, logger, _clean_names, warn, _time_mask, _pl,
                     _check_option)
from ..fixes import _get_args, _safe_svd, einsum, bincount
from ..channels.channels import _get_T1T2_mag_inds


# Note: MF uses single precision and some algorithms might use
# truncated versions of constants (e.g., μ0), which could lead to small
# differences between algorithms


@verbose
def maxwell_filter(raw, origin='auto', int_order=8, ext_order=3,
                   calibration=None, cross_talk=None, st_duration=None,
                   st_correlation=0.98, coord_frame='head', destination=None,
                   regularize='in', ignore_ref=False, bad_condition='error',
                   head_pos=None, st_fixed=True, st_only=False, mag_scale=100.,
                   skip_by_annotation=('edge', 'bad_acq_skip'), verbose=None):
    """Maxwell filter data using multipole moments.

    Parameters
    ----------
    raw : instance of mne.io.Raw
        Data to be filtered.

        .. warning:: Automatic bad channel detection is not currently
                     implemented. It is critical to mark bad channels in
                     ``raw.info['bads']`` prior to processing in order to
                     prevent artifact spreading.
    origin : array-like, shape (3,) | str
        Origin of internal and external multipolar moment space in meters.
        The default is ``'auto'``, which means ``(0., 0., 0.)`` when
        ``coord_frame='meg'``, and a head-digitization-based
        origin fit using :func:`~mne.bem.fit_sphere_to_headshape`
        when ``coord_frame='head'``. If automatic fitting fails (e.g., due
        to having too few digitization points),
        consider separately calling the fitting function with different
        options or specifying the origin manually.
    int_order : int
        Order of internal component of spherical expansion.
    ext_order : int
        Order of external component of spherical expansion.
    calibration : str | None
        Path to the ``'.dat'`` file with fine calibration coefficients.
        File can have 1D or 3D gradiometer imbalance correction.
        This file is machine/site-specific.
{'fraction_non_alphanumeric': 0.08517584211307315, 'fraction_numerical': 0.006232378691200475, 'mean_word_length': 2.8036117381489842, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4094339', 'n_tokens_mistral': 1999, 'n_tokens_neox': 1901, 'n_words': 634}