code: def test_spatiotemporal():
      """Test Maxwell filter (tSSS) spatiotemporal processing."""
      # Load raw testing data
      raw = read_crop(raw_fname)
  
      # Test that window is less than length of data
      with pytest.raises(ValueError, match="must be"):
          maxwell_filter(raw, st_duration=1000.0)
  
      # We could check both 4 and 10 seconds because Elekta handles them
      # differently (to ensure that std/non-std tSSS windows are correctly
      # handled), but the 4-s case should hopefully be sufficient.
      st_durations = [4.0]  # , 10.]
      tols = [(80, 100)]  # , 200.]
      kwargs = dict(
          origin=mf_head_origin, regularize=None, bad_condition="ignore"
      )
      for st_duration, tol in zip(st_durations, tols):
          # Load tSSS data depending on st_duration and get data
          tSSS_fname = sss_path / (
              "test_move_anon_st%0ds_raw_sss.fif" % st_duration
          )
          tsss_bench = read_crop(tSSS_fname)
          # Because Elekta's tSSS sometimes(!) lumps the tail window of data
          # onto the previous buffer if it's shorter than st_duration, we have to
          # crop the data here to compensate for Elekta's tSSS behavior.
          # if st_duration == 10.:
          #     tsss_bench.crop(0, st_duration)
          #     raw.crop(0, st_duration)
  
          # Test sss computation at the standard head origin. Same cropping issue
          # as mentioned above.
          raw_tsss = maxwell_filter(
              raw, st_duration=st_duration, **kwargs
          )
          assert _compute_rank_int(raw_tsss, proj=False) == 140
          assert_meg_snr(raw_tsss, tsss_bench, *tol)
          py_st = raw_tsss.info["proc_history"][0]["max_info"]["max_st"]
          assert len(py_st) > 0
          assert py_st["buflen"] == st_duration
          assert py_st["subspcorr"] == 0.98
  
      # Degenerate cases
      with pytest.raises(ValueError, match="Need 0 < st_correlation"):
          maxwell_filter(raw, st_duration=10.0, st_correlation=0.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 11 for calling a global function with example usage: test_spatiotemporal() without return types