code: def test_esss(regularize, bads):
      """Test extended-basis SSS."""
      # Make some fake "projectors" that actually contain external SSS bases
      raw_erm = read_crop(erm_fname).load_data().pick("meg")
      raw_erm.info["bads"] = bads
      proj_sss = mne.compute_proj_raw(
          raw_erm, meg="combined", verbose="error", n_mag=15, n_grad=15
      )
      good_info = pick_info(
          raw_erm.info, pick_types(raw_erm.info, meg=True)
      )
      S_tot = _trans_sss_basis(
          dict(int_order=0, ext_order=3, origin=(0.0, 0.0, 0.0)),
          all_coils=_prep_mf_coils(good_info),
          coil_scale=1.0,
          trans=None,
      )
      assert S_tot.shape[-1] == len(proj_sss)
      for a, b in zip(proj_sss, S_tot.T):
          a["data"]["data"][:] = b
      with catch_logging() as log:
          raw_sss = maxwell_filter(
              raw_erm,
              coord_frame="meg",
              regularize=regularize,
              verbose=True,
          )
      log = log.getvalue()
      assert "xtend" not in log
      with catch_logging() as log:
          raw_sss_2 = maxwell_filter(
              raw_erm,
              coord_frame="meg",
              regularize=regularize,
              ext_order=0,
              extended_proj=proj_sss,
              verbose=True,
          )
      log = log.getvalue()
      assert "Extending external SSS basis using 15 projection" in log
      assert_allclose(raw_sss_2._data, raw_sss._data, atol=1e-20)
  
      # This should work, as the projectors should be a superset
      raw_erm.info["bads"] = raw_erm.info["bads"] + ["MEG0112"]
      maxwell_filter(raw_erm, coord_frame="meg", extended_proj=proj_sss)
  
      # Degenerate condititons
      proj_sss = proj_sss[:2]
      proj_sss[0]["data"]["col_names"] = proj_sss[0]["data"][
          "col_names"
      ][:-1]
      with pytest.raises(ValueError, match="were missing"):
          maxwell_filter(
              raw_erm, coord_frame="meg", extended_proj=proj_sss
          )
      proj_sss[0] = 1.0
      with pytest.raises(
          TypeError, match=r"extended_proj\[0\] must be an inst"
      ):
          maxwell_filter(
              raw_erm, coord_frame="meg", extended_proj=proj_sss
          )
      with pytest.raises(
          TypeError, match="extended_proj must be an inst"
      ):
          maxwell_filter(raw_erm, coord_frame="meg", extended_proj=1.0)
  
imports: import pathlib
  import re
  from contextlib import contextmanager
  from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from scipy.special import sph_harm
  import mne
  from mne import compute_raw_covariance, concatenate_raws, pick_info, pick_types
  from mne._fiff.constants import FIFF
  from mne.annotations import _annotations_starts_stops
  from mne.chpi import filter_chpi, read_head_pos
  from mne.datasets import testing
  from mne.forward import _prep_meg_channels, use_coil_def
  from mne.io import BaseRaw, read_info, read_raw_bti, read_raw_ctf, read_raw_fif, read_raw_kit
  from mne.preprocessing import annotate_amplitude, annotate_movement, compute_maxwell_basis, find_bad_channels_maxwell, maxwell_filter, maxwell_filter_prepare_emptyroom
  from mne.preprocessing.maxwell import _bases_complex_to_real, _bases_real_to_complex, _get_n_moments, _prep_mf_coils, _sh_complex_to_real, _sh_negate, _sh_real_to_complex, _sss_basis_basic, _trans_sss_basis
  from mne.rank import _compute_rank_int, _get_rank_sss, compute_rank
  from mne.utils import _record_warnings, assert_meg_snr, buggy_mkl_svd, catch_logging, object_diff, use_log_level
label_desc: Use image node_id 19 for calling a global function with example usage: test_esss(regularize, bads) without return types