code: def test_stockwell_core():
      """Test stockwell transform."""
      # adapted from
      # http://vcs.ynic.york.ac.uk/docs/naf/intro/concepts/timefreq.html
      sfreq = 1000.0  # make things easy to understand
      dur = 0.5
      onset, offset = 0.175, 0.275
      n_samp = int(sfreq * dur)
      t = np.arange(n_samp) / sfreq  # make an array for time
      pulse_freq = 15.0
      pulse = np.cos(2.0 * np.pi * pulse_freq * t)
      pulse[
          0 : int(onset * sfreq)
      ] = 0.0  # Zero before our desired pulse
      pulse[
          int(offset * sfreq) :
      ] = 0.0  # and zero after our desired pulse
  
      width = 0.5
      freqs = fftpack.fftfreq(len(pulse), 1.0 / sfreq)
      fmin, fmax = 1.0, 100.0
      start_f, stop_f = (
          np.abs(freqs - f).argmin() for f in (fmin, fmax)
      )
      W = _precompute_st_windows(n_samp, start_f, stop_f, sfreq, width)
  
      st_pulse = _st(pulse, start_f, W)
      st_pulse = np.abs(st_pulse) ** 2
      assert_equal(st_pulse.shape[-1], len(pulse))
      st_max_freq = freqs[
          st_pulse.max(axis=1).argmax(axis=0)
      ]  # max freq
      assert_allclose(st_max_freq, pulse_freq, atol=1.0)
      assert onset < t[st_pulse.max(axis=0).argmax(axis=0)] < offset
  
      # test inversion to FFT, by averaging local spectra, see eq. 5 in
      # Moukadem, A., Bouguila, Z., Ould Abdeslam, D. and Alain Dieterlen.
      # "Stockwell transform optimization applied on the detection of split in
      # heart sounds."
  
      width = 1.0
      start_f, stop_f = 0, len(pulse)
      W = _precompute_st_windows(n_samp, start_f, stop_f, sfreq, width)
      y = _st(pulse, start_f, W)
      # invert stockwell
      y_inv = fftpack.ifft(np.sum(y, axis=1)).real
      assert_array_almost_equal(pulse, y_inv)
  
file_path: mne-python/mne/time_frequency/tests/test_stockwell.py
imports: from pathlib import Path
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_almost_equal, assert_array_less, assert_equal
  from scipy import fftpack
  from mne import Epochs, make_fixed_length_events, read_events
  from mne.io import read_raw_fif
  from mne.time_frequency import AverageTFR, tfr_array_stockwell
  from mne.time_frequency._stockwell import _check_input_st, _precompute_st_windows, _st, _st_power_itc, tfr_stockwell
  from mne.utils import _record_warnings
label_desc: Use image node_id 4 for calling a global function with example usage: test_stockwell_core() without return types