diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 14b4ba53f19..1f3f0eb7ea8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -23,7 +23,6 @@ jobs: - uses: actions/setup-python@v4 with: python-version: '3.11' - - uses: psf/black@stable - uses: pre-commit/action@v3.0.0 bandit: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 25d15b2157d..29c11f935ec 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,29 +1,29 @@ repos: - - repo: https://github.com/psf/black - rev: 23.11.0 - hooks: - - id: black - args: [--quiet] - # Ruff mne - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.6 hooks: - id: ruff - name: ruff mne + name: ruff lint mne args: ["--fix"] files: ^mne/ + - id: ruff-format + name: ruff format mne + files: ^mne/ # Ruff tutorials and examples - repo: https://github.com/astral-sh/ruff-pre-commit rev: v0.1.6 hooks: - id: ruff - name: ruff tutorials and examples + name: ruff lint tutorials and examples # D103: missing docstring in public function # D400: docstring first line must end with period args: ["--ignore=D103,D400", "--fix"] files: ^tutorials/|^examples/ + - id: ruff-format + name: ruff format tutorials and examples + files: ^tutorials/|^examples/ # Codespell - repo: https://github.com/codespell-project/codespell diff --git a/mne/_fiff/tag.py b/mne/_fiff/tag.py index 1b87d828619..81ed12baf6f 100644 --- a/mne/_fiff/tag.py +++ b/mne/_fiff/tag.py @@ -45,7 +45,7 @@ class Tag: Position of Tag is the original file. """ - def __init__(self, kind, type_, size, next, pos=None): # noqa: D102 + def __init__(self, kind, type_, size, next, pos=None): self.kind = int(kind) self.type = int(type_) self.size = int(size) diff --git a/mne/_fiff/tests/test_constants.py b/mne/_fiff/tests/test_constants.py index 3fc33513635..8f65e2609d5 100644 --- a/mne/_fiff/tests/test_constants.py +++ b/mne/_fiff/tests/test_constants.py @@ -385,16 +385,16 @@ def test_constants(tmp_path): for key in fif["coil"]: if key not in _missing_coil_def and key not in coil_def: bad_list.append((" %s," % key).ljust(10) + " # " + fif["coil"][key][1]) - assert ( - len(bad_list) == 0 - ), "\nIn fiff-constants, missing from coil_def:\n" + "\n".join(bad_list) + assert len(bad_list) == 0, ( + "\nIn fiff-constants, missing from coil_def:\n" + "\n".join(bad_list) + ) # Assert that enum(coil) has all `coil_def.dat` entries for key, desc in zip(coil_def, coil_desc): if key not in fif["coil"]: bad_list.append((" %s," % key).ljust(10) + " # " + desc) - assert ( - len(bad_list) == 0 - ), "In coil_def, missing from fiff-constants:\n" + "\n".join(bad_list) + assert len(bad_list) == 0, ( + "In coil_def, missing from fiff-constants:\n" + "\n".join(bad_list) + ) @pytest.mark.parametrize( diff --git a/mne/annotations.py b/mne/annotations.py index be62dac9dba..20ee351e7fa 100644 --- a/mne/annotations.py +++ b/mne/annotations.py @@ -276,9 +276,7 @@ class Annotations: :meth:`Raw.save() ` notes for details. """ # noqa: E501 - def __init__( - self, onset, duration, description, orig_time=None, ch_names=None - ): # noqa: D102 + def __init__(self, onset, duration, description, orig_time=None, ch_names=None): self._orig_time = _handle_meas_date(orig_time) self.onset, self.duration, self.description, self.ch_names = _check_o_d_s_c( onset, duration, description, ch_names diff --git a/mne/beamformer/tests/test_rap_music.py b/mne/beamformer/tests/test_rap_music.py index c98c83a7722..de6f047def8 100644 --- a/mne/beamformer/tests/test_rap_music.py +++ b/mne/beamformer/tests/test_rap_music.py @@ -50,9 +50,7 @@ def simu_data(evoked, forward, noise_cov, n_dipoles, times, nave=1): # Generate the two dipoles data mu, sigma = 0.1, 0.005 s1 = ( - 1 - / (sigma * np.sqrt(2 * np.pi)) - * np.exp(-((times - mu) ** 2) / (2 * sigma**2)) + 1 / (sigma * np.sqrt(2 * np.pi)) * np.exp(-((times - mu) ** 2) / (2 * sigma**2)) ) mu, sigma = 0.075, 0.008 diff --git a/mne/channels/channels.py b/mne/channels/channels.py index bc0f52cb56c..325be7350a6 100644 --- a/mne/channels/channels.py +++ b/mne/channels/channels.py @@ -585,14 +585,13 @@ def drop_channels(self, ch_names, on_missing="raise"): all_str = all([isinstance(ch, str) for ch in ch_names]) except TypeError: raise ValueError( - "'ch_names' must be iterable, got " - "type {} ({}).".format(type(ch_names), ch_names) + f"'ch_names' must be iterable, got type {type(ch_names)} ({ch_names})." ) if not all_str: raise ValueError( "Each element in 'ch_names' must be str, got " - "{}.".format([type(ch) for ch in ch_names]) + f"{[type(ch) for ch in ch_names]}." ) missing = [ch for ch in ch_names if ch not in self.ch_names] @@ -1057,9 +1056,7 @@ class _BuiltinChannelAdjacency: name="bti248grad", description="BTI 248 gradiometer system", fname="bti248grad_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="bti248grad_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="bti248grad_neighb.mat"), ), _BuiltinChannelAdjacency( name="ctf64", @@ -1083,25 +1080,19 @@ class _BuiltinChannelAdjacency: name="easycap32ch-avg", description="", fname="easycap32ch-avg_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycap32ch-avg_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycap32ch-avg_neighb.mat"), ), _BuiltinChannelAdjacency( name="easycap64ch-avg", description="", fname="easycap64ch-avg_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycap64ch-avg_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycap64ch-avg_neighb.mat"), ), _BuiltinChannelAdjacency( name="easycap128ch-avg", description="", fname="easycap128ch-avg_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycap128ch-avg_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycap128ch-avg_neighb.mat"), ), _BuiltinChannelAdjacency( name="easycapM1", @@ -1113,25 +1104,19 @@ class _BuiltinChannelAdjacency: name="easycapM11", description="Easycap M11", fname="easycapM11_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycapM11_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycapM11_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="easycapM14", description="Easycap M14", fname="easycapM14_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycapM14_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycapM14_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="easycapM15", description="Easycap M15", fname="easycapM15_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="easycapM15_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="easycapM15_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="KIT-157", @@ -1179,49 +1164,37 @@ class _BuiltinChannelAdjacency: name="neuromag306mag", description="Neuromag306, only magnetometers", fname="neuromag306mag_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="neuromag306mag_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="neuromag306mag_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="neuromag306planar", description="Neuromag306, only planar gradiometers", fname="neuromag306planar_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="neuromag306planar_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="neuromag306planar_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="neuromag122cmb", description="Neuromag122, only combined planar gradiometers", fname="neuromag122cmb_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="neuromag122cmb_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="neuromag122cmb_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="neuromag306cmb", description="Neuromag306, only combined planar gradiometers", fname="neuromag306cmb_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="neuromag306cmb_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="neuromag306cmb_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="ecog256", description="ECOG 256channels, average referenced", fname="ecog256_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="ecog256_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="ecog256_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="ecog256bipolar", description="ECOG 256channels, bipolar referenced", fname="ecog256bipolar_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="ecog256bipolar_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="ecog256bipolar_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="eeg1010_neighb", @@ -1263,33 +1236,25 @@ class _BuiltinChannelAdjacency: name="language29ch-avg", description="MPI for Psycholinguistic: Averaged 29-channel cap", fname="language29ch-avg_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="language29ch-avg_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="language29ch-avg_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="mpi_59_channels", description="MPI for Psycholinguistic: 59-channel cap", fname="mpi_59_channels_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="mpi_59_channels_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="mpi_59_channels_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="yokogawa160", description="", fname="yokogawa160_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="yokogawa160_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="yokogawa160_neighb.mat"), # noqa: E501 ), _BuiltinChannelAdjacency( name="yokogawa440", description="", fname="yokogawa440_neighb.mat", - source_url=_ft_neighbor_url_t.substitute( - fname="yokogawa440_neighb.mat" - ), # noqa: E501 + source_url=_ft_neighbor_url_t.substitute(fname="yokogawa440_neighb.mat"), # noqa: E501 ), ] diff --git a/mne/channels/interpolation.py b/mne/channels/interpolation.py index 77e660901a9..807639b8bcf 100644 --- a/mne/channels/interpolation.py +++ b/mne/channels/interpolation.py @@ -165,10 +165,7 @@ def _interpolate_bads_eeg(inst, origin, exclude=None, verbose=None): pos_good = pos[goods_idx_pos] - origin pos_bad = pos[bads_idx_pos] - origin - logger.info( - "Computing interpolation matrix from {} sensor " - "positions".format(len(pos_good)) - ) + logger.info(f"Computing interpolation matrix from {len(pos_good)} sensor positions") interpolation = _make_interpolation_matrix(pos_good, pos_bad) logger.info("Interpolating {} sensors".format(len(pos_bad))) diff --git a/mne/channels/layout.py b/mne/channels/layout.py index a0f12cc594f..043bb9c33b7 100644 --- a/mne/channels/layout.py +++ b/mne/channels/layout.py @@ -58,7 +58,7 @@ class Layout: The type of Layout (e.g. 'Vectorview-all'). """ - def __init__(self, box, pos, names, ids, kind): # noqa: D102 + def __init__(self, box, pos, names, ids, kind): self.box = box self.pos = pos self.names = names diff --git a/mne/commands/mne_freeview_bem_surfaces.py b/mne/commands/mne_freeview_bem_surfaces.py index 7f1c6491ba1..504ca3378bf 100644 --- a/mne/commands/mne_freeview_bem_surfaces.py +++ b/mne/commands/mne_freeview_bem_surfaces.py @@ -41,8 +41,7 @@ def freeview_bem_surfaces(subject, subjects_dir, method): if not op.isdir(subject_dir): raise ValueError( - "Wrong path: '{}'. Check subjects-dir or" - "subject argument.".format(subject_dir) + f"Wrong path: '{subject_dir}'. Check subjects-dir or subject argument." ) env = os.environ.copy() diff --git a/mne/coreg.py b/mne/coreg.py index fe6895270b7..32f2cb6d614 100644 --- a/mne/coreg.py +++ b/mne/coreg.py @@ -422,8 +422,8 @@ def fit_matched_points( tgt_pts = np.atleast_2d(tgt_pts) if src_pts.shape != tgt_pts.shape: raise ValueError( - "src_pts and tgt_pts must have same shape (got " - "{}, {})".format(src_pts.shape, tgt_pts.shape) + "src_pts and tgt_pts must have same shape " + f"(got {src_pts.shape}, {tgt_pts.shape})" ) if weights is not None: weights = np.asarray(weights, src_pts.dtype) diff --git a/mne/datasets/sleep_physionet/_utils.py b/mne/datasets/sleep_physionet/_utils.py index db9982e8c71..8e4506a1be5 100644 --- a/mne/datasets/sleep_physionet/_utils.py +++ b/mne/datasets/sleep_physionet/_utils.py @@ -20,9 +20,7 @@ ) TEMAZEPAM_RECORDS_URL_SHA1 = "f52fffe5c18826a2bd4c5d5cb375bb4a9008c885" -AGE_RECORDS_URL = ( - "https://physionet.org/physiobank/database/sleep-edfx/SC-subjects.xls" # noqa: E501 -) +AGE_RECORDS_URL = "https://physionet.org/physiobank/database/sleep-edfx/SC-subjects.xls" AGE_RECORDS_URL_SHA1 = "0ba6650892c5d33a8e2b3f62ce1cc9f30438c54f" sha1sums_fname = op.join(op.dirname(__file__), "SHA1SUMS") diff --git a/mne/datasets/sleep_physionet/age.py b/mne/datasets/sleep_physionet/age.py index 29afe9d9562..f947874aa0d 100644 --- a/mne/datasets/sleep_physionet/age.py +++ b/mne/datasets/sleep_physionet/age.py @@ -21,9 +21,7 @@ data_path = _data_path # expose _data_path(..) as data_path(..) -BASE_URL = ( - "https://physionet.org/physiobank/database/sleep-edfx/sleep-cassette/" # noqa: E501 -) +BASE_URL = "https://physionet.org/physiobank/database/sleep-edfx/sleep-cassette/" @verbose diff --git a/mne/decoding/base.py b/mne/decoding/base.py index 08a0d65e951..8caea981194 100644 --- a/mne/decoding/base.py +++ b/mne/decoding/base.py @@ -64,7 +64,7 @@ class LinearModel(BaseEstimator): "classes_", ) - def __init__(self, model=None): # noqa: D102 + def __init__(self, model=None): if model is None: from sklearn.linear_model import LogisticRegression diff --git a/mne/decoding/search_light.py b/mne/decoding/search_light.py index 06b7b010651..873efe89465 100644 --- a/mne/decoding/search_light.py +++ b/mne/decoding/search_light.py @@ -46,7 +46,7 @@ def __init__( position=0, allow_2d=False, verbose=None, - ): # noqa: D102 + ): _check_estimator(base_estimator) self.base_estimator = base_estimator self.n_jobs = n_jobs diff --git a/mne/decoding/time_frequency.py b/mne/decoding/time_frequency.py index e085e9e2706..bd0076d0355 100644 --- a/mne/decoding/time_frequency.py +++ b/mne/decoding/time_frequency.py @@ -74,7 +74,7 @@ def __init__( output="complex", n_jobs=1, verbose=None, - ): # noqa: D102 + ): """Init TimeFrequency transformer.""" # Check non-average output output = _check_option("output", output, ["complex", "power", "phase"]) diff --git a/mne/decoding/transformer.py b/mne/decoding/transformer.py index 44930417e89..184bfca8f53 100644 --- a/mne/decoding/transformer.py +++ b/mne/decoding/transformer.py @@ -107,9 +107,7 @@ class Scaler(TransformerMixin, BaseEstimator): if ``scalings`` is a dict or None). """ - def __init__( - self, info=None, scalings=None, with_mean=True, with_std=True - ): # noqa: D102 + def __init__(self, info=None, scalings=None, with_mean=True, with_std=True): self.info = info self.with_mean = with_mean self.with_std = with_std @@ -384,7 +382,7 @@ def __init__( normalization="length", *, verbose=None, - ): # noqa: D102 + ): self.sfreq = sfreq self.fmin = fmin self.fmax = fmax @@ -512,7 +510,7 @@ def __init__( fir_design="firwin", *, verbose=None, - ): # noqa: D102 + ): self.info = info self.l_freq = l_freq self.h_freq = h_freq @@ -625,7 +623,7 @@ class UnsupervisedSpatialFilter(TransformerMixin, BaseEstimator): (e.g. epochs). """ - def __init__(self, estimator, average=False): # noqa: D102 + def __init__(self, estimator, average=False): # XXX: Use _check_estimator #3381 for attr in ("fit", "transform", "fit_transform"): if not hasattr(estimator, attr): @@ -838,7 +836,7 @@ def __init__( fir_design="firwin", *, verbose=None, - ): # noqa: D102 + ): self.l_freq = l_freq self.h_freq = h_freq self.sfreq = sfreq diff --git a/mne/dipole.py b/mne/dipole.py index 59531463da8..42e27438b4a 100644 --- a/mne/dipole.py +++ b/mne/dipole.py @@ -130,7 +130,7 @@ def __init__( nfree=None, *, verbose=None, - ): # noqa: D102 + ): self._set_times(np.array(times)) self.pos = np.array(pos) self.amplitude = np.array(amplitude) @@ -481,7 +481,7 @@ class DipoleFixed(ExtendedTimeMixin): @verbose def __init__( self, info, data, times, nave, aspect_kind, comment="", *, verbose=None - ): # noqa: D102 + ): self.info = info self.nave = nave self._aspect_kind = aspect_kind @@ -654,7 +654,9 @@ def _read_dipole_text(fname): def_line, ) fields = re.sub( - r"\((.*?)\)", lambda match: "/" + match.group(1), fields # "Q(nAm)", etc. + r"\((.*?)\)", + lambda match: "/" + match.group(1), + fields, # "Q(nAm)", etc. ) fields = re.sub( "(begin|end) ", # "begin" and "end" with no units @@ -1522,9 +1524,7 @@ def fit_dipole( # Use the minimum distance to the MEG sensors as the radius then R = np.dot( np.linalg.inv(info["dev_head_t"]["trans"]), np.hstack([r0, [1.0]]) - )[ - :3 - ] # r0 -> device + )[:3] # r0 -> device R = R - [ info["chs"][pick]["loc"][:3] for pick in pick_types(info, meg=True, exclude=[]) diff --git a/mne/epochs.py b/mne/epochs.py index 864f4021b42..915670af516 100644 --- a/mne/epochs.py +++ b/mne/epochs.py @@ -465,7 +465,7 @@ def __init__( raw_sfreq=None, annotations=None, verbose=None, - ): # noqa: D102 + ): if events is not None: # RtEpochs can have events=None events = _ensure_events(events) # Allow reading empty epochs (ToDo: Maybe not anymore in the future) @@ -3231,7 +3231,7 @@ def __init__( metadata=None, event_repeated="error", verbose=None, - ): # noqa: D102 + ): from .io import BaseRaw if not isinstance(raw, BaseRaw): @@ -3403,7 +3403,7 @@ def __init__( drop_log=None, raw_sfreq=None, verbose=None, - ): # noqa: D102 + ): dtype = np.complex128 if np.any(np.iscomplex(data)) else np.float64 data = np.asanyarray(data, dtype=dtype) if data.ndim != 3: @@ -3873,9 +3873,7 @@ def read_epochs(fname, proj=True, preload=True, verbose=None): class _RawContainer: """Helper for a raw data container.""" - def __init__( - self, fid, data_tag, event_samps, epoch_shape, cals, fmt - ): # noqa: D102 + def __init__(self, fid, data_tag, event_samps, epoch_shape, cals, fmt): self.fid = fid self.data_tag = data_tag self.event_samps = event_samps @@ -3909,7 +3907,7 @@ class EpochsFIF(BaseEpochs): """ @verbose - def __init__(self, fname, proj=True, preload=True, verbose=None): # noqa: D102 + def __init__(self, fname, proj=True, preload=True, verbose=None): from .io.base import _get_fname_rep if _path_like(fname): diff --git a/mne/event.py b/mne/event.py index 211ed4e5d5d..fca229f2884 100644 --- a/mne/event.py +++ b/mne/event.py @@ -1144,7 +1144,7 @@ class AcqParserFIF: "OldMask", ) - def __init__(self, info): # noqa: D102 + def __init__(self, info): acq_pars = info["acq_pars"] if not acq_pars: raise ValueError("No acquisition parameters") diff --git a/mne/evoked.py b/mne/evoked.py index 31083795507..03923533fbb 100644 --- a/mne/evoked.py +++ b/mne/evoked.py @@ -174,7 +174,7 @@ def __init__( allow_maxshield=False, *, verbose=None, - ): # noqa: D102 + ): _validate_type(proj, bool, "'proj'") # Read the requested data fname = str(_check_fname(fname=fname, must_exist=True, overwrite="read")) @@ -1316,7 +1316,7 @@ def __init__( baseline=None, *, verbose=None, - ): # noqa: D102 + ): dtype = np.complex128 if np.iscomplexobj(data) else np.float64 data = np.asanyarray(data, dtype=dtype) diff --git a/mne/forward/forward.py b/mne/forward/forward.py index 9531445edd1..dc39a58bd8f 100644 --- a/mne/forward/forward.py +++ b/mne/forward/forward.py @@ -1456,8 +1456,10 @@ def compute_depth_prior( # d[k] = linalg.svdvals(x)[0] G.shape = (G.shape[0], -1, 3) d = np.linalg.norm( - np.einsum("svj,svk->vjk", G, G), ord=2, axis=(1, 2) # vector dot prods - ) # ord=2 spectral (largest s.v.) + np.einsum("svj,svk->vjk", G, G), # vector dot prods + ord=2, # ord=2 spectral (largest s.v.) + axis=(1, 2), + ) G.shape = (G.shape[0], -1) # XXX Currently the fwd solns never have "patch_areas" defined diff --git a/mne/forward/tests/test_field_interpolation.py b/mne/forward/tests/test_field_interpolation.py index f19b844d46c..4f09a90df73 100644 --- a/mne/forward/tests/test_field_interpolation.py +++ b/mne/forward/tests/test_field_interpolation.py @@ -237,10 +237,16 @@ def test_make_field_map_meeg(): assert_allclose(map_["data"].min(), min_, rtol=5e-2) # calculated from correct looking mapping on 2015/12/26 assert_allclose( - np.sqrt(np.sum(maps[0]["data"] ** 2)), 19.0903, atol=1e-3, rtol=1e-3 # 16.6088, + np.sqrt(np.sum(maps[0]["data"] ** 2)), + 19.0903, + atol=1e-3, + rtol=1e-3, ) assert_allclose( - np.sqrt(np.sum(maps[1]["data"] ** 2)), 19.4748, atol=1e-3, rtol=1e-3 # 20.1245, + np.sqrt(np.sum(maps[1]["data"] ** 2)), + 19.4748, + atol=1e-3, + rtol=1e-3, ) diff --git a/mne/inverse_sparse/mxne_optim.py b/mne/inverse_sparse/mxne_optim.py index b70476991a2..5d785f5eec5 100644 --- a/mne/inverse_sparse/mxne_optim.py +++ b/mne/inverse_sparse/mxne_optim.py @@ -778,7 +778,7 @@ def safe_max_abs_diff(A, ia, B, ib): class _Phi: """Have phi stft as callable w/o using a lambda that does not pickle.""" - def __init__(self, wsize, tstep, n_coefs, n_times): # noqa: D102 + def __init__(self, wsize, tstep, n_coefs, n_times): self.wsize = np.atleast_1d(wsize) self.tstep = np.atleast_1d(tstep) self.n_coefs = np.atleast_1d(n_coefs) @@ -819,7 +819,7 @@ def norm(self, z, ord=2): class _PhiT: """Have phi.T istft as callable w/o using a lambda that does not pickle.""" - def __init__(self, tstep, n_freqs, n_steps, n_times): # noqa: D102 + def __init__(self, tstep, n_freqs, n_steps, n_times): self.tstep = tstep self.n_freqs = n_freqs self.n_steps = n_steps @@ -977,9 +977,9 @@ def norm_epsilon(Y, l1_ratio, phi, w_space=1.0, w_time=None): p_sum_w2 = np.cumsum(w_time**2) p_sum_Yw = np.cumsum(Y * w_time) upper = p_sum_Y2 / (Y / w_time) ** 2 - 2.0 * p_sum_Yw / (Y / w_time) + p_sum_w2 - upper_greater = np.where( - upper > w_space**2 * (1.0 - l1_ratio) ** 2 / l1_ratio**2 - )[0] + upper_greater = np.where(upper > w_space**2 * (1.0 - l1_ratio) ** 2 / l1_ratio**2)[ + 0 + ] i0 = upper_greater[0] - 1 if upper_greater.size else K - 1 diff --git a/mne/io/array/array.py b/mne/io/array/array.py index 456bd763015..a0df061821f 100644 --- a/mne/io/array/array.py +++ b/mne/io/array/array.py @@ -52,9 +52,7 @@ class RawArray(BaseRaw): """ @verbose - def __init__( - self, data, info, first_samp=0, copy="auto", verbose=None - ): # noqa: D102 + def __init__(self, data, info, first_samp=0, copy="auto", verbose=None): _validate_type(info, "info", "info") _check_option("copy", copy, ("data", "info", "both", "auto", None)) dtype = np.complex128 if np.any(np.iscomplex(data)) else np.float64 diff --git a/mne/io/artemis123/artemis123.py b/mne/io/artemis123/artemis123.py index 3cdedb3770d..fb7b33e5b6c 100644 --- a/mne/io/artemis123/artemis123.py +++ b/mne/io/artemis123/artemis123.py @@ -340,7 +340,7 @@ def __init__( verbose=None, pos_fname=None, add_head_trans=True, - ): # noqa: D102 + ): from ...chpi import ( _fit_coil_order_dev_head_trans, compute_chpi_amplitudes, diff --git a/mne/io/base.py b/mne/io/base.py index fd8dde30258..95ba7038865 100644 --- a/mne/io/base.py +++ b/mne/io/base.py @@ -203,7 +203,7 @@ def __init__( orig_units=None, *, verbose=None, - ): # noqa: D102 + ): # wait until the end to preload data, but triage here if isinstance(preload, np.ndarray): # some functions (e.g., filtering) only work w/64-bit data @@ -265,8 +265,7 @@ def __init__( if orig_units: if not isinstance(orig_units, dict): raise ValueError( - "orig_units must be of type dict, but got " - " {}".format(type(orig_units)) + f"orig_units must be of type dict, but got {type(orig_units)}" ) # original units need to be truncated to 15 chars or renamed @@ -291,8 +290,7 @@ def __init__( if not all(ch_correspond): ch_without_orig_unit = ch_names[ch_correspond.index(False)] raise ValueError( - "Channel {} has no associated original " - "unit.".format(ch_without_orig_unit) + f"Channel {ch_without_orig_unit} has no associated original unit." ) # Final check of orig_units, editing a unit if it is not a valid @@ -1127,7 +1125,7 @@ def filter( skip_by_annotation=("edge", "bad_acq_skip"), pad="reflect_limited", verbose=None, - ): # noqa: D102 + ): return super().filter( l_freq, h_freq, @@ -2522,7 +2520,7 @@ def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): class _RawShell: """Create a temporary raw object.""" - def __init__(self): # noqa: D102 + def __init__(self): self.first_samp = None self.last_samp = None self._first_time = None diff --git a/mne/io/bti/bti.py b/mne/io/bti/bti.py index 190625f8ee0..99a77cd2b8c 100644 --- a/mne/io/bti/bti.py +++ b/mne/io/bti/bti.py @@ -72,7 +72,7 @@ def _instantiate_default_info_chs(): class _bytes_io_mock_context: """Make a context for BytesIO.""" - def __init__(self, target): # noqa: D102 + def __init__(self, target): self.target = target def __enter__(self): # noqa: D105 @@ -1077,7 +1077,7 @@ def __init__( eog_ch=("E63", "E64"), preload=False, verbose=None, - ): # noqa: D102 + ): _validate_type(pdf_fname, ("path-like", BytesIO), "pdf_fname") info, bti_info = _get_bti_info( pdf_fname=pdf_fname, diff --git a/mne/io/cnt/cnt.py b/mne/io/cnt/cnt.py index a242e85952b..496ed91cd38 100644 --- a/mne/io/cnt/cnt.py +++ b/mne/io/cnt/cnt.py @@ -508,7 +508,7 @@ def __init__( header="auto", preload=False, verbose=None, - ): # noqa: D102 + ): _check_option("date_format", date_format, ["mm/dd/yy", "dd/mm/yy"]) if date_format == "dd/mm/yy": _date_format = "%d/%m/%y %H:%M:%S" diff --git a/mne/io/ctf/ctf.py b/mne/io/ctf/ctf.py index feb5a04dda2..1d4970624bd 100644 --- a/mne/io/ctf/ctf.py +++ b/mne/io/ctf/ctf.py @@ -111,7 +111,7 @@ def __init__( preload=False, verbose=None, clean_names=False, - ): # noqa: D102 + ): # adapted from mne_ctf2fiff.c directory = str( _check_fname(directory, "read", True, "directory", need_dir=True) diff --git a/mne/io/ctf/tests/test_ctf.py b/mne/io/ctf/tests/test_ctf.py index f5340421a70..20fdf2e0127 100644 --- a/mne/io/ctf/tests/test_ctf.py +++ b/mne/io/ctf/tests/test_ctf.py @@ -92,9 +92,7 @@ def test_read_ctf(tmp_path): args = ( str(ch_num + 1), raw.ch_names[ch_num], - ) + tuple( - "%0.5f" % x for x in 100 * pos[ii] - ) # convert to cm + ) + tuple("%0.5f" % x for x in 100 * pos[ii]) # convert to cm fid.write(("\t".join(args) + "\n").encode("ascii")) pos_read_old = np.array([raw.info["chs"][p]["loc"][:3] for p in picks]) with pytest.warns(RuntimeWarning, match="RMSP .* changed to a MISC ch"): diff --git a/mne/io/eeglab/eeglab.py b/mne/io/eeglab/eeglab.py index 413a8ae4bfc..f4beee56119 100644 --- a/mne/io/eeglab/eeglab.py +++ b/mne/io/eeglab/eeglab.py @@ -449,7 +449,7 @@ def __init__( uint16_codec=None, montage_units="auto", verbose=None, - ): # noqa: D102 + ): input_fname = str(_check_fname(input_fname, "read", True, "input_fname")) eeg = _check_load_mat(input_fname, uint16_codec) if eeg.trials != 1: @@ -602,7 +602,7 @@ def __init__( uint16_codec=None, montage_units="auto", verbose=None, - ): # noqa: D102 + ): input_fname = str( _check_fname(fname=input_fname, must_exist=True, overwrite="read") ) diff --git a/mne/io/eeglab/tests/test_eeglab.py b/mne/io/eeglab/tests/test_eeglab.py index 7d78f95ef6a..ce34a186910 100644 --- a/mne/io/eeglab/tests/test_eeglab.py +++ b/mne/io/eeglab/tests/test_eeglab.py @@ -568,9 +568,7 @@ def test_position_information(three_chanpos_fname): input_fname=three_chanpos_fname, preload=True, montage_units="cm", - ).set_montage( - None - ) # Flush the montage builtin within input_fname + ).set_montage(None) # Flush the montage builtin within input_fname _assert_array_allclose_nan( np.array([ch["loc"] for ch in raw.info["chs"]]), EXPECTED_LOCATIONS_FROM_MONTAGE diff --git a/mne/io/egi/egi.py b/mne/io/egi/egi.py index 0b62d7b6389..32cb71db28f 100644 --- a/mne/io/egi/egi.py +++ b/mne/io/egi/egi.py @@ -193,7 +193,7 @@ def __init__( preload=False, channel_naming="E%d", verbose=None, - ): # noqa: D102 + ): input_fname = str(_check_fname(input_fname, "read", True, "input_fname")) if eog is None: eog = [] diff --git a/mne/io/fiff/raw.py b/mne/io/fiff/raw.py index d81fd99c556..f4053f88b37 100644 --- a/mne/io/fiff/raw.py +++ b/mne/io/fiff/raw.py @@ -97,7 +97,7 @@ def __init__( preload=False, on_split_missing="raise", verbose=None, - ): # noqa: D102 + ): raws = [] do_check_ext = not _file_like(fname) next_fname = fname diff --git a/mne/io/fil/fil.py b/mne/io/fil/fil.py index 08b7778398a..ea990b741de 100644 --- a/mne/io/fil/fil.py +++ b/mne/io/fil/fil.py @@ -311,8 +311,8 @@ def _from_tsv(fname, dtypes=None): dtypes = [dtypes] * info.shape[1] if not len(dtypes) == info.shape[1]: raise ValueError( - "dtypes length mismatch. Provided: {0}, " - "Expected: {1}".format(len(dtypes), info.shape[1]) + f"dtypes length mismatch. Provided: {len(dtypes)}, " + f"Expected: {info.shape[1]}" ) for i, name in enumerate(column_names): data_dict[name] = info[:, i].astype(dtypes[i]).tolist() diff --git a/mne/io/hitachi/tests/test_hitachi.py b/mne/io/hitachi/tests/test_hitachi.py index edad56dc75e..300af7cf5e8 100644 --- a/mne/io/hitachi/tests/test_hitachi.py +++ b/mne/io/hitachi/tests/test_hitachi.py @@ -22,9 +22,7 @@ ) CONTENTS = dict() -CONTENTS[ - "1.18" -] = b"""\ +CONTENTS["1.18"] = b"""\ Header,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, File Version,1.18,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, Patient Information,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, @@ -129,9 +127,7 @@ """ # noqa: E501 -CONTENTS[ - "1.25" -] = b"""\ +CONTENTS["1.25"] = b"""\ Header File Version,1.25 Patient Information diff --git a/mne/io/kit/kit.py b/mne/io/kit/kit.py index fa9ff8cfeea..88af0b2dc85 100644 --- a/mne/io/kit/kit.py +++ b/mne/io/kit/kit.py @@ -75,7 +75,7 @@ def _call_digitization(info, mrk, elp, hsp, kit_info): class UnsupportedKITFormat(ValueError): """Our reader is not guaranteed to work with old files.""" - def __init__(self, sqd_version, *args, **kwargs): # noqa: D102 + def __init__(self, sqd_version, *args, **kwargs): self.sqd_version = sqd_version ValueError.__init__(self, *args, **kwargs) @@ -134,7 +134,7 @@ def __init__( allow_unknown_format=False, standardize_names=None, verbose=None, - ): # noqa: D102 + ): logger.info("Extracting SQD Parameters from %s..." % input_fname) input_fname = op.abspath(input_fname) self.preload = False @@ -382,7 +382,7 @@ def __init__( allow_unknown_format=False, standardize_names=None, verbose=None, - ): # noqa: D102 + ): if isinstance(events, (str, PathLike, Path)): events = read_events(events) diff --git a/mne/io/nicolet/nicolet.py b/mne/io/nicolet/nicolet.py index 85a7d1e5607..37855b97054 100644 --- a/mne/io/nicolet/nicolet.py +++ b/mne/io/nicolet/nicolet.py @@ -183,7 +183,7 @@ def __init__( misc=(), preload=False, verbose=None, - ): # noqa: D102 + ): input_fname = path.abspath(input_fname) info, header_info = _get_nicolet_info(input_fname, ch_type, eog, ecg, emg, misc) last_samps = [header_info["num_samples"] - 1] diff --git a/mne/io/nihon/nihon.py b/mne/io/nihon/nihon.py index b39a18af838..919719f24a2 100644 --- a/mne/io/nihon/nihon.py +++ b/mne/io/nihon/nihon.py @@ -178,8 +178,7 @@ def _read_nihon_header(fname): control_block = np.fromfile(fid, "|S16", 1).astype("U16")[0] if control_block not in _valid_headers: raise ValueError( - "Not a valid Nihon Kohden EEG file " - "(control block {})".format(version) + f"Not a valid Nihon Kohden EEG file (control block {version})" ) fid.seek(0x17FE) diff --git a/mne/label.py b/mne/label.py index b57b466df27..77ddf5bcffd 100644 --- a/mne/label.py +++ b/mne/label.py @@ -242,7 +242,7 @@ def __init__( color=None, *, verbose=None, - ): # noqa: D102 + ): # check parameters if not isinstance(hemi, str): raise ValueError("hemi must be a string, not %s" % type(hemi)) @@ -1017,7 +1017,7 @@ class BiHemiLabel: The name of the subject. """ - def __init__(self, lh, rh, name=None, color=None): # noqa: D102 + def __init__(self, lh, rh, name=None, color=None): if lh.subject != rh.subject: raise ValueError( "lh.subject (%s) and rh.subject (%s) must " diff --git a/mne/preprocessing/eyetracking/eyetracking.py b/mne/preprocessing/eyetracking/eyetracking.py index ab3d51c6af1..f6b1b0fd0d4 100644 --- a/mne/preprocessing/eyetracking/eyetracking.py +++ b/mne/preprocessing/eyetracking/eyetracking.py @@ -78,8 +78,7 @@ def set_channel_types_eyetrack(inst, mapping): ch_type = ch_desc[0].lower() if ch_type not in valid_types: raise ValueError( - "ch_type must be one of {}. " - "Got '{}' instead.".format(valid_types, ch_type) + f"ch_type must be one of {valid_types}. Got '{ch_type}' instead." ) if ch_type == "eyegaze": coil_type = FIFF.FIFFV_COIL_EYETRACK_POS diff --git a/mne/preprocessing/ica.py b/mne/preprocessing/ica.py index 64667185330..1290c3d1e5a 100644 --- a/mne/preprocessing/ica.py +++ b/mne/preprocessing/ica.py @@ -445,7 +445,7 @@ def __init__( max_iter="auto", allow_ref_meg=False, verbose=None, - ): # noqa: D102 + ): _validate_type(method, str, "method") _validate_type(n_components, (float, "int-like", None)) diff --git a/mne/preprocessing/interpolate.py b/mne/preprocessing/interpolate.py index 8e69f364a10..828261d2651 100644 --- a/mne/preprocessing/interpolate.py +++ b/mne/preprocessing/interpolate.py @@ -123,8 +123,7 @@ def interpolate_bridged_electrodes(inst, bridged_idx, bad_limit=4): pos = montage.get_positions() if pos["coord_frame"] != "head": raise RuntimeError( - "Montage channel positions must be in ``head``" - "got {}".format(pos["coord_frame"]) + f"Montage channel positions must be in ``head`` got {pos['coord_frame']}" ) # store bads orig to put back at the end bads_orig = inst.info["bads"] diff --git a/mne/preprocessing/tests/test_annotate_amplitude.py b/mne/preprocessing/tests/test_annotate_amplitude.py index d39fabdb3ce..3618e480657 100644 --- a/mne/preprocessing/tests/test_annotate_amplitude.py +++ b/mne/preprocessing/tests/test_annotate_amplitude.py @@ -247,11 +247,11 @@ def test_flat_bad_acq_skip(): raw = read_raw_fif(skip_fname, preload=True) annots, bads = annotate_amplitude(raw, flat=0) assert len(annots) == 0 - assert bads == [ # MaxFilter finds the same 21 channels - "MEG%04d" % (int(num),) + assert bads == [ + f"MEG{num.zfill(4)}" for num in "141 331 421 431 611 641 1011 1021 1031 1241 1421 " "1741 1841 2011 2131 2141 2241 2531 2541 2611 2621".split() - ] + ] # MaxFilter finds the same 21 channels # -- overlap of flat segment with bad_acq_skip -- n_ch, n_times = 11, 1000 diff --git a/mne/preprocessing/tests/test_eeglab_infomax.py b/mne/preprocessing/tests/test_eeglab_infomax.py index f0835099c96..f4f4d1d68dc 100644 --- a/mne/preprocessing/tests/test_eeglab_infomax.py +++ b/mne/preprocessing/tests/test_eeglab_infomax.py @@ -171,9 +171,7 @@ def test_mne_python_vs_eeglab(): sources = np.dot(unmixing, Y) mixing = pinv(unmixing) - mvar = ( - np.sum(mixing**2, axis=0) * np.sum(sources**2, axis=1) / (N * T - 1) - ) + mvar = np.sum(mixing**2, axis=0) * np.sum(sources**2, axis=1) / (N * T - 1) windex = np.argsort(mvar)[::-1] unmixing_ordered = unmixing[windex, :] diff --git a/mne/preprocessing/tests/test_maxwell.py b/mne/preprocessing/tests/test_maxwell.py index b806ccf577a..6234b79c544 100644 --- a/mne/preprocessing/tests/test_maxwell.py +++ b/mne/preprocessing/tests/test_maxwell.py @@ -992,9 +992,9 @@ def _assert_shielding(raw_sss, erm_power, min_factor, max_factor=np.inf, meg="ma sss_power = raw_sss[picks][0].ravel() sss_power = np.sqrt(np.sum(sss_power * sss_power)) factor = erm_power / sss_power - assert ( - min_factor <= factor < max_factor - ), "Shielding factor not %0.3f <= %0.3f < %0.3f" % (min_factor, factor, max_factor) + assert min_factor <= factor < max_factor, ( + "Shielding factor not %0.3f <= %0.3f < %0.3f" % (min_factor, factor, max_factor) + ) @buggy_mkl_svd diff --git a/mne/source_estimate.py b/mne/source_estimate.py index efc5a06515a..213d00e5baa 100644 --- a/mne/source_estimate.py +++ b/mne/source_estimate.py @@ -497,9 +497,7 @@ class _BaseSourceEstimate(TimeMixin): _data_ndim = 2 @verbose - def __init__( - self, data, vertices, tmin, tstep, subject=None, verbose=None - ): # noqa: D102 + def __init__(self, data, vertices, tmin, tstep, subject=None, verbose=None): assert hasattr(self, "_data_ndim"), self.__class__.__name__ assert hasattr(self, "_src_type"), self.__class__.__name__ assert hasattr(self, "_src_count"), self.__class__.__name__ @@ -2001,7 +1999,7 @@ class _BaseVectorSourceEstimate(_BaseSourceEstimate): @verbose def __init__( self, data, vertices=None, tmin=None, tstep=None, subject=None, verbose=None - ): # noqa: D102 + ): assert hasattr(self, "_scalar_class") super().__init__(data, vertices, tmin, tstep, subject, verbose) @@ -2138,7 +2136,7 @@ def plot( add_data_kwargs=None, brain_kwargs=None, verbose=None, - ): # noqa: D102 + ): return plot_vector_source_estimates( self, subject=subject, @@ -2643,7 +2641,7 @@ def plot_3d( add_data_kwargs=None, brain_kwargs=None, verbose=None, - ): # noqa: D102 + ): return _BaseVectorSourceEstimate.plot( self, subject=subject, @@ -2734,7 +2732,7 @@ class _BaseMixedSourceEstimate(_BaseSourceEstimate): @verbose def __init__( self, data, vertices=None, tmin=None, tstep=None, subject=None, verbose=None - ): # noqa: D102 + ): if not isinstance(vertices, list) or len(vertices) < 2: raise ValueError( "Vertices must be a list of numpy arrays with " diff --git a/mne/source_space/_source_space.py b/mne/source_space/_source_space.py index e1d8611354c..ee8ef432a90 100644 --- a/mne/source_space/_source_space.py +++ b/mne/source_space/_source_space.py @@ -286,7 +286,7 @@ class SourceSpaces(list): access, like ``src.kind``. """ # noqa: E501 - def __init__(self, source_spaces, info=None): # noqa: D102 + def __init__(self, source_spaces, info=None): # First check the types is actually a valid config _validate_type(source_spaces, list, "source_spaces") super(SourceSpaces, self).__init__(source_spaces) # list diff --git a/mne/stats/permutations.py b/mne/stats/permutations.py index 3f515559c72..15c78ae0872 100644 --- a/mne/stats/permutations.py +++ b/mne/stats/permutations.py @@ -146,7 +146,7 @@ def stat_fun(x): rng = check_random_state(random_state) boot_indices = rng.choice(indices, replace=True, size=(n_bootstraps, len(indices))) stat = np.array([stat_fun(arr[inds]) for inds in boot_indices]) - ci = (((1 - ci) / 2) * 100, ((1 - ((1 - ci) / 2))) * 100) + ci = (((1 - ci) / 2) * 100, (1 - ((1 - ci) / 2)) * 100) ci_low, ci_up = np.percentile(stat, ci, axis=0) return np.array([ci_low, ci_up]) diff --git a/mne/tests/test_annotations.py b/mne/tests/test_annotations.py index 12964118f32..1a351de5527 100644 --- a/mne/tests/test_annotations.py +++ b/mne/tests/test_annotations.py @@ -425,7 +425,11 @@ def test_raw_reject(first_samp): with pytest.warns(RuntimeWarning, match="outside the data range"): raw.set_annotations(Annotations([2, 100, 105, 148], [2, 8, 5, 8], "BAD")) data, times = raw.get_data( - [0, 1, 3, 4], 100, 11200, "omit", return_times=True # 1-112 s + [0, 1, 3, 4], + 100, + 11200, + "omit", + return_times=True, # 1-112 s ) bad_times = np.concatenate( [np.arange(200, 400), np.arange(10000, 10800), np.arange(10500, 11000)] diff --git a/mne/tests/test_docstring_parameters.py b/mne/tests/test_docstring_parameters.py index 0118a6c36ba..f42147f378f 100644 --- a/mne/tests/test_docstring_parameters.py +++ b/mne/tests/test_docstring_parameters.py @@ -278,9 +278,7 @@ def test_tabs(): whiten_evoked write_fiducials write_info -""".split( - "\n" -) +""".split("\n") def test_documented(): diff --git a/mne/time_frequency/_stockwell.py b/mne/time_frequency/_stockwell.py index 1abf0c8e5a6..f92cc02a804 100644 --- a/mne/time_frequency/_stockwell.py +++ b/mne/time_frequency/_stockwell.py @@ -22,7 +22,7 @@ def _check_input_st(x_in, n_fft): n_times = x_in.shape[-1] def _is_power_of_two(n): - return not (n > 0 and ((n & (n - 1)))) + return not (n > 0 and (n & (n - 1))) if n_fft is None or (not _is_power_of_two(n_fft) and n_times > n_fft): # Compute next power of 2 diff --git a/mne/time_frequency/tfr.py b/mne/time_frequency/tfr.py index ce547568232..400b711512e 100644 --- a/mne/time_frequency/tfr.py +++ b/mne/time_frequency/tfr.py @@ -1401,7 +1401,7 @@ class AverageTFR(_BaseTFR): @verbose def __init__( self, info, data, times, freqs, nave, comment=None, method=None, verbose=None - ): # noqa: D102 + ): super().__init__() self.info = info if data.ndim != 3: @@ -2699,7 +2699,6 @@ def __init__( metadata=None, verbose=None, ): - # noqa: D102 super().__init__() self.info = info if data.ndim != 4: diff --git a/mne/transforms.py b/mne/transforms.py index f0efd287f40..b8dcb1728ff 100644 --- a/mne/transforms.py +++ b/mne/transforms.py @@ -111,7 +111,7 @@ class Transform(dict): ``'ctf_meg'``, ``'unknown'``. """ - def __init__(self, fro, to, trans=None): # noqa: D102 + def __init__(self, fro, to, trans=None): super(Transform, self).__init__() # we could add some better sanity checks here fro = _to_const(fro) diff --git a/mne/utils/_bunch.py b/mne/utils/_bunch.py index 0fdac59139f..ff04fcec91a 100644 --- a/mne/utils/_bunch.py +++ b/mne/utils/_bunch.py @@ -15,7 +15,7 @@ class Bunch(dict): """Dictionary-like object that exposes its keys as attributes.""" - def __init__(self, **kwargs): # noqa: D102 + def __init__(self, **kwargs): dict.__init__(self, kwargs) self.__dict__ = self diff --git a/mne/utils/_logging.py b/mne/utils/_logging.py index 1dcb1a5e8a6..f4546e5e7d8 100644 --- a/mne/utils/_logging.py +++ b/mne/utils/_logging.py @@ -159,7 +159,7 @@ class use_log_level: This message will be printed! """ - def __init__(self, verbose=None, *, add_frames=None): # noqa: D102 + def __init__(self, verbose=None, *, add_frames=None): self._level = verbose self._add_frames = add_frames self._old_frames = _filter.add_frames diff --git a/mne/utils/_testing.py b/mne/utils/_testing.py index 999d6242695..d767e25711c 100644 --- a/mne/utils/_testing.py +++ b/mne/utils/_testing.py @@ -50,7 +50,7 @@ def __new__(self): # noqa: D105 new = str.__new__(self, tempfile.mkdtemp(prefix="tmp_mne_tempdir_")) return new - def __init__(self): # noqa: D102 + def __init__(self): self._path = self.__str__() def __del__(self): # noqa: D105 @@ -121,7 +121,7 @@ def run_command_if_main(): class ArgvSetter: """Temporarily set sys.argv.""" - def __init__(self, args=(), disable_stdout=True, disable_stderr=True): # noqa: D102 + def __init__(self, args=(), disable_stdout=True, disable_stderr=True): self.argv = list(("python",) + args) self.stdout = ClosingStringIO() if disable_stdout else sys.stdout self.stderr = ClosingStringIO() if disable_stderr else sys.stderr diff --git a/mne/utils/docs.py b/mne/utils/docs.py index a1d1d15679d..806d774f221 100644 --- a/mne/utils/docs.py +++ b/mne/utils/docs.py @@ -64,42 +64,32 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # A -docdict[ - "accept" -] = """ +docdict["accept"] = """ accept : bool If True (default False), accept the license terms of this dataset. """ -docdict[ - "add_ch_type_export_params" -] = """ +docdict["add_ch_type_export_params"] = """ add_ch_type : bool Whether to incorporate the channel type into the signal label (e.g. whether to store channel "Fz" as "EEG Fz"). Only used for EDF format. Default is ``False``. """ -docdict[ - "add_data_kwargs" -] = """ +docdict["add_data_kwargs"] = """ add_data_kwargs : dict | None Additional arguments to brain.add_data (e.g., ``dict(time_label_size=10)``). """ -docdict[ - "add_frames" -] = """ +docdict["add_frames"] = """ add_frames : int | None If int, enable (>=1) or disable (0) the printing of stack frame information using formatting. Default (None) does not change the formatting. This can add overhead so is meant only for debugging. """ -docdict[ - "adjacency_clust" -] = """ +docdict["adjacency_clust"] = """ adjacency : scipy.sparse.spmatrix | None | False Defines adjacency between locations in the data, where "locations" can be spatial vertices, frequency bins, time points, etc. For spatial vertices @@ -155,25 +145,19 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["adjacency_clust"].format(**st).format(**groups) ) -docdict[ - "adjust_dig_chpi" -] = """ +docdict["adjust_dig_chpi"] = """ adjust_dig : bool If True, adjust the digitization locations used for fitting based on the positions localized at the start of the file. """ -docdict[ - "agg_fun_psd_topo" -] = """ +docdict["agg_fun_psd_topo"] = """ agg_fun : callable The function used to aggregate over frequencies. Defaults to :func:`numpy.sum` if ``normalize=True``, else :func:`numpy.mean`. """ -docdict[ - "align_view" -] = """ +docdict["align_view"] = """ align : bool If True, consider view arguments relative to canonical MRI directions (closest to MNI for the subject) rather than native MRI @@ -181,16 +165,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): have large rotations). """ -docdict[ - "allow_2d" -] = """ +docdict["allow_2d"] = """ allow_2d : bool If True, allow 2D data as input (i.e. n_samples, n_features). """ -docdict[ - "allow_empty_eltc" -] = """ +docdict["allow_empty_eltc"] = """ allow_empty : bool | str ``False`` (default) will emit an error if there are labels that have no vertices in the source estimate. ``True`` and ``'ignore'`` will return @@ -202,16 +182,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Support for "ignore". """ -docdict[ - "alpha" -] = """ +docdict["alpha"] = """ alpha : float in [0, 1] Alpha level to control opacity. """ -docdict[ - "anonymize_info_notes" -] = """ +docdict["anonymize_info_notes"] = """ Removes potentially identifying information if it exists in ``info``. Specifically for each of the following we use: @@ -261,16 +237,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["applyfun_summary_evoked"] = applyfun_summary.format("evoked", "") docdict["applyfun_summary_raw"] = applyfun_summary.format("raw", applyfun_preload) -docdict[ - "area_alpha_plot_psd" -] = """\ +docdict["area_alpha_plot_psd"] = """\ area_alpha : float Alpha for the area. """ -docdict[ - "area_mode_plot_psd" -] = """\ +docdict["area_mode_plot_psd"] = """\ area_mode : str | None Mode for plotting area. If 'std', the mean +/- 1 STD (across channels) will be plotted. If 'range', the min and max (across channels) will be @@ -278,18 +250,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): If None, no area will be plotted. If average=False, no area is plotted. """ -docdict[ - "aseg" -] = """ +docdict["aseg"] = """ aseg : str The anatomical segmentation file. Default ``aparc+aseg``. This may be any anatomical segmentation file in the mri subdirectory of the Freesurfer subject directory. """ -docdict[ - "average_plot_evoked_topomap" -] = """ +docdict["average_plot_evoked_topomap"] = """ average : float | array-like of float, shape (n_times,) | None The time window (in seconds) around a given time point to be used for averaging. For example, 0.2 would translate into a time window that @@ -303,9 +271,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Support for ``array-like`` input. """ -docdict[ - "average_plot_psd" -] = """\ +docdict["average_plot_psd"] = """\ average : bool If False, the PSDs of all channels is displayed. No averaging is done and parameters area_mode and area_alpha are ignored. When @@ -313,9 +279,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): drag) to plot a topomap. """ -docdict[ - "average_psd" -] = """\ +docdict["average_psd"] = """\ average : str | None How to average the segments. If ``mean`` (default), calculate the arithmetic mean. If ``median``, calculate the median, corrected for @@ -323,9 +287,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): segments. """ -docdict[ - "average_tfr" -] = """ +docdict["average_tfr"] = """ average : bool, default True If ``False`` return an `EpochsTFR` containing separate TFRs for each epoch. If ``True`` return an `AverageTFR` containing the average of all @@ -358,9 +320,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["axes_evoked_plot_topomap"] = _axes_list.format( "axes", "match the number of ``times`` provided (unless ``times`` is ``None``)" ) -docdict[ - "axes_montage" -] = """ +docdict["axes_montage"] = """ axes : instance of Axes | instance of Axes3D | None Axes to draw the sensors to. If ``kind='3d'``, axes must be an instance of Axes3D. If None (default), a new axes will be created.""" @@ -380,17 +340,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): "axes", "match the length of ``bands``" ) -docdict[ - "axis_facecolor" -] = """\ +docdict["axis_facecolor"] = """\ axis_facecolor : str | tuple A matplotlib-compatible color to use for the axis background. Defaults to black. """ -docdict[ - "azimuth" -] = """ +docdict["azimuth"] = """ azimuth : float The azimuthal angle of the camera rendering the view in degrees. """ @@ -398,17 +354,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # B -docdict[ - "bad_condition_maxwell_cond" -] = """ +docdict["bad_condition_maxwell_cond"] = """ bad_condition : str How to deal with ill-conditioned SSS matrices. Can be ``"error"`` (default), ``"warning"``, ``"info"``, or ``"ignore"``. """ -docdict[ - "bands_psd_topo" -] = """ +docdict["bands_psd_topo"] = """ bands : None | dict | list of tuple The frequencies or frequency ranges to plot. If a :class:`dict`, keys will be used as subplot titles and values should be either a single frequency @@ -431,9 +383,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Allow passing a dict and discourage passing tuples. """ -docdict[ - "base_estimator" -] = """ +docdict["base_estimator"] = """ base_estimator : object The base estimator to iteratively fit on a subset of the dataset. """ @@ -452,9 +402,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): timepoints ``t`` such that ``a <= t <= b``. """ -docdict[ - "baseline_epochs" -] = f"""{_baseline_rescale_base} +docdict["baseline_epochs"] = f"""{_baseline_rescale_base} Correction is applied **to each epoch and channel individually** in the following way: @@ -463,9 +411,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ -docdict[ - "baseline_evoked" -] = f"""{_baseline_rescale_base} +docdict["baseline_evoked"] = f"""{_baseline_rescale_base} Correction is applied **to each channel individually** in the following way: @@ -474,9 +420,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ -docdict[ - "baseline_report" -] = f"""{_baseline_rescale_base} +docdict["baseline_report"] = f"""{_baseline_rescale_base} Correction is applied in the following way **to each channel:** 1. Calculate the mean signal of the baseline period. @@ -487,9 +431,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["baseline_rescale"] = _baseline_rescale_base -docdict[ - "baseline_stc" -] = f"""{_baseline_rescale_base} +docdict["baseline_stc"] = f"""{_baseline_rescale_base} Correction is applied **to each source individually** in the following way: @@ -505,47 +447,35 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ -docdict[ - "block" -] = """\ +docdict["block"] = """\ block : bool Whether to halt program execution until the figure is closed. May not work on all systems / platforms. Defaults to ``False``. """ -docdict[ - "border_topomap" -] = """ +docdict["border_topomap"] = """ border : float | 'mean' Value to extrapolate to on the topomap borders. If ``'mean'`` (default), then each extrapolated point has the average value of its neighbours. """ -docdict[ - "brain_kwargs" -] = """ +docdict["brain_kwargs"] = """ brain_kwargs : dict | None Additional arguments to the :class:`mne.viz.Brain` constructor (e.g., ``dict(silhouette=True)``). """ -docdict[ - "brain_update" -] = """ +docdict["brain_update"] = """ update : bool Force an update of the plot. Defaults to True. """ -docdict[ - "browser" -] = """ +docdict["browser"] = """ fig : matplotlib.figure.Figure | mne_qt_browser.figure.MNEQtBrowser Browser instance. """ -docdict[ - "buffer_size_clust" -] = """ +docdict["buffer_size_clust"] = """ buffer_size : int | None Block size to use when computing test statistics. This can significantly reduce memory usage when ``n_jobs > 1`` and memory sharing between @@ -554,9 +484,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): a small block of locations at a time. """ -docdict[ - "by_event_type" -] = """ +docdict["by_event_type"] = """ by_event_type : bool When ``False`` (the default) all epochs are processed together and a single :class:`~mne.Evoked` object is returned. When ``True``, epochs are first @@ -571,18 +499,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # C -docdict[ - "calibration_maxwell_cal" -] = """ +docdict["calibration_maxwell_cal"] = """ 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. """ -docdict[ - "cbar_fmt_topomap" -] = """\ +docdict["cbar_fmt_topomap"] = """\ cbar_fmt : str Formatting string for colorbar tick labels. See :ref:`formatspec` for details. @@ -595,17 +519,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ ) -docdict[ - "center" -] = """ +docdict["center"] = """ center : float or None If not None, center of a divergent colormap, changes the meaning of fmin, fmax and fmid. """ -docdict[ - "ch_name_ecg" -] = """ +docdict["ch_name_ecg"] = """ ch_name : None | str The name of the channel to use for ECG peak detection. If ``None`` (default), ECG channel is used if present. If ``None`` and @@ -614,9 +534,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): MEG channels. """ -docdict[ - "ch_name_eog" -] = """ +docdict["ch_name_eog"] = """ ch_name : str | list of str | None The name of the channel(s) to use for EOG peak detection. If a string, can be an arbitrary channel. This doesn't have to be a channel of @@ -628,9 +546,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): If ``None`` (default), use the channel(s) in ``raw`` with type ``eog``. """ -docdict[ - "ch_names_annot" -] = """ +docdict["ch_names_annot"] = """ ch_names : list | None List of lists of channel names associated with the annotations. Empty entries are assumed to be associated with no specific channel, @@ -644,9 +560,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ch_names=[[], ['MEG0111', 'MEG2563'], ['MEG1443']]) """ -docdict[ - "ch_type_set_eeg_reference" -] = """ +docdict["ch_type_set_eeg_reference"] = """ ch_type : list of str | str The name of the channel type to apply the reference to. Valid channel types are ``'auto'``, ``'eeg'``, ``'ecog'``, ``'seeg'``, @@ -685,34 +599,26 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["channel_wise_applyfun_epo"] = chwise.format("in each epoch ", "epochs and ") -docdict[ - "check_disjoint_clust" -] = """ +docdict["check_disjoint_clust"] = """ check_disjoint : bool Whether to check if the connectivity matrix can be separated into disjoint sets before clustering. This may lead to faster clustering, especially if the second dimension of ``X`` (usually the "time" dimension) is large. """ -docdict[ - "chpi_amplitudes" -] = """ +docdict["chpi_amplitudes"] = """ chpi_amplitudes : dict The time-varying cHPI coil amplitudes, with entries "times", "proj", and "slopes". """ -docdict[ - "chpi_locs" -] = """ +docdict["chpi_locs"] = """ chpi_locs : dict The time-varying cHPI coils locations, with entries "times", "rrs", "moments", and "gofs". """ -docdict[ - "clim" -] = """ +docdict["clim"] = """ clim : str | dict Colorbar properties specification. If 'auto', set clim automatically based on data percentiles. If dict, should contain: @@ -731,9 +637,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): only divergent colormaps should be used with ``pos_lims``. """ -docdict[ - "clim_onesided" -] = """ +docdict["clim_onesided"] = """ clim : str | dict Colorbar properties specification. If 'auto', set clim automatically based on data percentiles. If dict, should contain: @@ -747,17 +651,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``pos_lims``, as the surface plot must show the magnitude. """ -docdict[ - "cmap" -] = """ +docdict["cmap"] = """ cmap : matplotlib colormap | str | None The :class:`~matplotlib.colors.Colormap` to use. Defaults to ``None``, which will use the matplotlib default colormap. """ -docdict[ - "cmap_topomap" -] = """ +docdict["cmap_topomap"] = """ cmap : matplotlib colormap | (colormap, bool) | 'interactive' | None Colormap to use. If :class:`tuple`, the first value indicates the colormap to use and the second value is a boolean defining interactivity. In @@ -774,17 +674,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): 2 topomaps. """ -docdict[ - "cmap_topomap_simple" -] = """ +docdict["cmap_topomap_simple"] = """ cmap : matplotlib colormap | None Colormap to use. If None, 'Reds' is used for all positive data, otherwise defaults to 'RdBu_r'. """ -docdict[ - "cnorm" -] = """ +docdict["cnorm"] = """ cnorm : matplotlib.colors.Normalize | None How to normalize the colormap. If ``None``, standard linear normalization is performed. If not ``None``, ``vmin`` and ``vmax`` will be ignored. @@ -793,57 +689,43 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): :ref:`the ERDs example` for an example of its use. """ -docdict[ - "color_matplotlib" -] = """ +docdict["color_matplotlib"] = """ color : color A list of anything matplotlib accepts: string, RGB, hex, etc. """ -docdict[ - "color_plot_psd" -] = """\ +docdict["color_plot_psd"] = """\ color : str | tuple A matplotlib-compatible color to use. Has no effect when spatial_colors=True. """ -docdict[ - "color_spectrum_plot_topo" -] = """\ +docdict["color_spectrum_plot_topo"] = """\ color : str | tuple A matplotlib-compatible color to use for the curves. Defaults to white. """ -docdict[ - "colorbar_topomap" -] = """ +docdict["colorbar_topomap"] = """ colorbar : bool Plot a colorbar in the rightmost column of the figure. """ -docdict[ - "colormap" -] = """ +docdict["colormap"] = """ colormap : str | np.ndarray of float, shape(n_colors, 3 | 4) Name of colormap to use or a custom look up table. If array, must be (n x 3) or (n x 4) array for with RGB or RGBA values between 0 and 255. """ -docdict[ - "combine" -] = """ +docdict["combine"] = """ combine : None | str | callable How to combine information across channels. If a :class:`str`, must be one of 'mean', 'median', 'std' (standard deviation) or 'gfp' (global field power). """ -docdict[ - "compute_proj_ecg" -] = """This function will: +docdict["compute_proj_ecg"] = """This function will: #. Filter the ECG data channel. @@ -858,9 +740,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): #. Calculate SSP projection vectors on that data to capture the artifacts.""" -docdict[ - "compute_proj_eog" -] = """This function will: +docdict["compute_proj_eog"] = """This function will: #. Filter the EOG data channel. @@ -876,18 +756,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): #. Calculate SSP projection vectors on that data to capture the artifacts.""" -docdict[ - "compute_ssp" -] = """This function aims to find those SSP vectors that +docdict["compute_ssp"] = """This function aims to find those SSP vectors that will project out the ``n`` most prominent signals from the data for each specified sensor type. Consequently, if the provided input data contains high levels of noise, the produced SSP vectors can then be used to eliminate that noise from the data. """ -docdict[ - "contours_topomap" -] = """ +docdict["contours_topomap"] = """ contours : int | array-like The number of contour lines to draw. If ``0``, no contours will be drawn. If a positive integer, that number of contour levels are chosen using the @@ -898,9 +774,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): corresponding to the contour levels. Default is ``6``. """ -docdict[ - "coord_frame_maxwell" -] = """ +docdict["coord_frame_maxwell"] = """ coord_frame : str The coordinate frame that the ``origin`` is specified in, either ``'meg'`` or ``'head'``. For empty-room recordings that do not have @@ -908,17 +782,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): frame should be used. """ -docdict[ - "copy_df" -] = """ +docdict["copy_df"] = """ copy : bool If ``True``, data will be copied. Otherwise data may be modified in place. Defaults to ``True``. """ -docdict[ - "create_ecg_epochs" -] = """This function will: +docdict["create_ecg_epochs"] = """This function will: #. Filter the ECG data channel. @@ -927,9 +797,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): #. Create `~mne.Epochs` around the R wave peaks, capturing the heartbeats. """ -docdict[ - "create_eog_epochs" -] = """This function will: +docdict["create_eog_epochs"] = """This function will: #. Filter the EOG data channel. @@ -939,9 +807,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): #. Create `~mne.Epochs` around the eyeblinks. """ -docdict[ - "cross_talk_maxwell" -] = """ +docdict["cross_talk_maxwell"] = """ cross_talk : str | None Path to the FIF file with cross-talk correction information. """ @@ -955,9 +821,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): 10 × log₁₀(spectral power){}.{} """ -docdict[ - "dB_plot_psd" -] = """\ +docdict["dB_plot_psd"] = """\ dB : bool Plot Power Spectral Density (PSD), in units (amplitude**2/Hz (dB)) if ``dB=True``, and ``estimate='power'`` or ``estimate='auto'``. Plot PSD @@ -973,9 +837,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["dB_spectrum_plot"] = _dB.format("", "") docdict["dB_spectrum_plot_topo"] = _dB.format("", " Ignored if ``normalize=True``.") -docdict[ - "daysback_anonymize_info" -] = """ +docdict["daysback_anonymize_info"] = """ daysback : int | None Number of days to subtract from all dates. If ``None`` (default), the acquisition date, ``info['meas_date']``, @@ -983,15 +845,11 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``info['meas_date']`` is ``None`` (i.e., no acquisition date has been set). """ -docdict[ - "dbs" -] = """ +docdict["dbs"] = """ dbs : bool If True (default), show DBS (deep brain stimulation) electrodes. """ -docdict[ - "decim" -] = """ +docdict["decim"] = """ decim : int Factor by which to subsample the data. @@ -1002,9 +860,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): may occur. """ -docdict[ - "decim_notes" -] = """ +docdict["decim_notes"] = """ For historical reasons, ``decim`` / "decimation" refers to simply subselecting samples from a given signal. This contrasts with the broader signal processing literature, where decimation is defined as (quoting @@ -1024,9 +880,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``inst.decimate(4)``. """ -docdict[ - "decim_tfr" -] = """ +docdict["decim_tfr"] = """ decim : int | slice, default 1 To reduce memory usage, decimation factor after time-frequency decomposition. @@ -1039,9 +893,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): artifacts. """ -docdict[ - "depth" -] = """ +docdict["depth"] = """ depth : None | float | dict How to weight (or normalize) the forward using a depth prior. If float (default 0.8), it acts as the depth weighting exponent (``exp``) @@ -1054,9 +906,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Depth bias ignored for ``method='eLORETA'``. """ -docdict[ - "destination_maxwell_dest" -] = """ +docdict["destination_maxwell_dest"] = """ destination : path-like | array-like, shape (3,) | None The destination location for the head. Can be ``None``, which will not change the head position, or a path to a FIF file @@ -1067,9 +917,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): head location). """ -docdict[ - "detrend_epochs" -] = """ +docdict["detrend_epochs"] = """ detrend : int | None If 0 or 1, the data channels (MEG and EEG) will be detrended when loaded. 0 is a constant (DC) detrend, 1 is a linear detrend. None @@ -1080,17 +928,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): (will yield equivalent results but be slower). """ -docdict[ - "df_return" -] = """ +docdict["df_return"] = """ df : instance of pandas.DataFrame A dataframe suitable for usage with other statistical/plotting/analysis packages. """ -docdict[ - "dig_kinds" -] = """ +docdict["dig_kinds"] = """ dig_kinds : list of str | str Kind of digitization points to use in the fitting. These can be any combination of ('cardinal', 'hpi', 'eeg', 'extra'). Can also @@ -1099,9 +943,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): 'eeg' points. """ -docdict[ - "dipole" -] = """ +docdict["dipole"] = """ dipole : instance of Dipole | list of Dipole Dipole object containing position, orientation and amplitude of one or more dipoles. Multiple simultaneous dipoles may be defined by @@ -1112,9 +954,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Added support for a list of :class:`mne.Dipole` instances. """ -docdict[ - "distance" -] = """ +docdict["distance"] = """ distance : float | "auto" | None The distance from the camera rendering the view to the focalpoint in plot units (either m or mm). If "auto", the bounds of visible objects will be @@ -1124,17 +964,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``None`` will no longer change the distance, use ``"auto"`` instead. """ -docdict[ - "drop_log" -] = """ +docdict["drop_log"] = """ drop_log : tuple | None Tuple of tuple of strings indicating which epochs have been marked to be ignored. """ -docdict[ - "dtype_applyfun" -] = """ +docdict["dtype_applyfun"] = """ dtype : numpy.dtype Data type to use after applying the function. If None (default) the data type is not modified. @@ -1143,16 +979,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # E -docdict[ - "ecog" -] = """ +docdict["ecog"] = """ ecog : bool If True (default), show ECoG sensors. """ -docdict[ - "edf_resamp_note" -] = """ +docdict["edf_resamp_note"] = """ :class:`mne.io.Raw` only stores signals with matching sampling frequencies. Therefore, if mixed sampling frequency signals are requested, all signals are upsampled to the highest loaded sampling frequency. In this case, using @@ -1160,9 +992,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): slices of the signal are requested. """ -docdict[ - "eeg" -] = """ +docdict["eeg"] = """ eeg : bool | str | list | dict String options are: @@ -1180,16 +1010,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Added support for specifying alpha values as a dict. """ -docdict[ - "elevation" -] = """ +docdict["elevation"] = """ elevation : float The The zenith angle of the camera rendering the view in degrees. """ -docdict[ - "eltc_mode_notes" -] = """ +docdict["eltc_mode_notes"] = """ Valid values for ``mode`` are: - ``'max'`` @@ -1228,32 +1054,24 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``'max'``, and ``'auto'``. """ -docdict[ - "emit_warning" -] = """ +docdict["emit_warning"] = """ emit_warning : bool Whether to emit warnings when cropping or omitting annotations. """ -docdict[ - "encoding_edf" -] = """ +docdict["encoding_edf"] = """ encoding : str Encoding of annotations channel(s). Default is "utf8" (the only correct encoding according to the EDF+ standard). """ -docdict[ - "epochs_preload" -] = """ +docdict["epochs_preload"] = """ Load all epochs from disk when creating the object or wait before accessing each epoch (more memory efficient but can be slower). """ -docdict[ - "epochs_reject_tmin_tmax" -] = """ +docdict["epochs_reject_tmin_tmax"] = """ reject_tmin, reject_tmax : float | None Start and end of the time window used to reject epochs based on peak-to-peak (PTP) amplitudes as specified via ``reject`` and ``flat``. @@ -1264,27 +1082,21 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): both, ``reject`` and ``flat``. """ -docdict[ - "epochs_tmin_tmax" -] = """ +docdict["epochs_tmin_tmax"] = """ tmin, tmax : float Start and end time of the epochs in seconds, relative to the time-locked event. The closest or matching samples corresponding to the start and end time are included. Defaults to ``-0.2`` and ``0.5``, respectively. """ -docdict[ - "estimate_plot_psd" -] = """\ +docdict["estimate_plot_psd"] = """\ estimate : str, {'auto', 'power', 'amplitude'} Can be "power" for power spectral density (PSD), "amplitude" for amplitude spectrum density (ASD), or "auto" (default), which uses "power" when dB is True and "amplitude" otherwise. """ -docdict[ - "event_color" -] = """ +docdict["event_color"] = """ event_color : color object | dict | None Color(s) to use for :term:`events`. To show all :term:`events` in the same color, pass any matplotlib-compatible color. To color events differently, @@ -1294,9 +1106,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): color cycle. """ -docdict[ - "event_id" -] = """ +docdict["event_id"] = """ event_id : int | list of int | dict | None The id of the :term:`events` to consider. If dict, the keys can later be used to access associated :term:`events`. Example: @@ -1305,16 +1115,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): are used. If None, all :term:`events` will be used and a dict is created with string integer names corresponding to the event id integers.""" -docdict[ - "event_id_ecg" -] = """ +docdict["event_id_ecg"] = """ event_id : int The index to assign to found ECG events. """ -docdict[ - "event_repeated_epochs" -] = """ +docdict["event_repeated_epochs"] = """ event_repeated : str How to handle duplicates in ``events[:, 0]``. Can be ``'error'`` (default), to raise an error, 'drop' to only retain the row occurring @@ -1324,17 +1130,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.19 """ -docdict[ - "events" -] = """ +docdict["events"] = """ events : array of int, shape (n_events, 3) The array of :term:`events`. The first column contains the event time in samples, with :term:`first_samp` included. The third column contains the event id.""" -docdict[ - "events_epochs" -] = """ +docdict["events_epochs"] = """ events : array of int, shape (n_events, 3) The array of :term:`events`. The first column contains the event time in samples, with :term:`first_samp` included. The third column contains the @@ -1342,9 +1144,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): If some events don't match the events of interest as specified by ``event_id``, they will be marked as ``IGNORED`` in the drop log.""" -docdict[ - "evoked_by_event_type_returns" -] = """ +docdict["evoked_by_event_type_returns"] = """ evoked : instance of Evoked | list of Evoked The averaged epochs. When ``by_event_type=True`` was specified, a list is returned containing a @@ -1353,18 +1153,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): dictionary. """ -docdict[ - "exclude_clust" -] = """ +docdict["exclude_clust"] = """ exclude : bool array or None Mask to apply to the data to exclude certain points from clustering (e.g., medial wall vertices). Should be the same shape as ``X``. If ``None``, no points are excluded. """ -docdict[ - "exclude_frontal" -] = """ +docdict["exclude_frontal"] = """ exclude_frontal : bool If True, exclude points that have both negative Z values (below the nasion) and positive Y values (in front of the LPA/RPA). @@ -1383,9 +1179,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): " from being drawn", "spectrum." ) -docdict[ - "export_edf_note" -] = """ +docdict["export_edf_note"] = """ For EDF exports, only channels measured in Volts are allowed; in MNE-Python this means channel types 'eeg', 'ecog', 'seeg', 'emg', 'eog', 'ecg', 'dbs', 'bio', and 'misc'. 'stim' channels are dropped. Although this function @@ -1404,9 +1198,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): `. """ -docdict[ - "export_eeglab_note" -] = """ +docdict["export_eeglab_note"] = """ For EEGLAB exports, channel locations are expanded to full EEGLAB format. For more details see :func:`eeglabio.utils.cart_to_eeglab`. """ @@ -1416,59 +1208,39 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): from the filename extension. See supported formats above for more information.""" -docdict[ - "export_fmt_params_epochs" -] = """ +docdict["export_fmt_params_epochs"] = """ fmt : 'auto' | 'eeglab' {} -""".format( - _export_fmt_params_base -) +""".format(_export_fmt_params_base) -docdict[ - "export_fmt_params_evoked" -] = """ +docdict["export_fmt_params_evoked"] = """ fmt : 'auto' | 'mff' {} -""".format( - _export_fmt_params_base -) +""".format(_export_fmt_params_base) -docdict[ - "export_fmt_params_raw" -] = """ +docdict["export_fmt_params_raw"] = """ fmt : 'auto' | 'brainvision' | 'edf' | 'eeglab' {} -""".format( - _export_fmt_params_base -) +""".format(_export_fmt_params_base) -docdict[ - "export_fmt_support_epochs" -] = """\ +docdict["export_fmt_support_epochs"] = """\ Supported formats: - EEGLAB (``.set``, uses :mod:`eeglabio`) """ -docdict[ - "export_fmt_support_evoked" -] = """\ +docdict["export_fmt_support_evoked"] = """\ Supported formats: - MFF (``.mff``, uses :func:`mne.export.export_evokeds_mff`) """ -docdict[ - "export_fmt_support_raw" -] = """\ +docdict["export_fmt_support_raw"] = """\ Supported formats: - BrainVision (``.vhdr``, ``.vmrk``, ``.eeg``, uses `pybv `_) - EEGLAB (``.set``, uses :mod:`eeglabio`) - EDF (``.edf``, uses `edfio `_) """ # noqa: E501 -docdict[ - "export_warning" -] = """\ +docdict["export_warning"] = """\ .. warning:: Since we are exporting to external formats, there's no guarantee that all the info will be preserved in the external format. See Notes for details. @@ -1488,9 +1260,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["export_warning_note_raw"] = _export_warning_note_base.format("io.Raw") -docdict[ - "ext_order_chpi" -] = """ +docdict["ext_order_chpi"] = """ ext_order : int The external order for SSS-like interfence suppression. The SSS bases are used as projection vectors during fitting. @@ -1500,16 +1270,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): detection of true HPI signals. """ -docdict[ - "ext_order_maxwell" -] = """ +docdict["ext_order_maxwell"] = """ ext_order : int Order of external component of spherical expansion. """ -docdict[ - "extended_proj_maxwell" -] = """ +docdict["extended_proj_maxwell"] = """ extended_proj : list The empty-room projection vectors used to extend the external SSS basis (i.e., use eSSS). @@ -1517,9 +1283,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.21 """ -docdict[ - "extrapolate_topomap" -] = """ +docdict["extrapolate_topomap"] = """ extrapolate : str Options: @@ -1538,18 +1302,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): the head circle. """ -docdict[ - "eyelink_apply_offsets" -] = """ +docdict["eyelink_apply_offsets"] = """ apply_offsets : bool (default False) Adjusts the onset time of the :class:`~mne.Annotations` created from Eyelink experiment messages, if offset values exist in the ASCII file. If False, any offset-like values will be prepended to the annotation description. """ -docdict[ - "eyelink_create_annotations" -] = """ +docdict["eyelink_create_annotations"] = """ create_annotations : bool | list (default True) Whether to create :class:`~mne.Annotations` from occular events (blinks, fixations, saccades) and experiment messages. If a list, must @@ -1558,24 +1318,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): experiment messages. """ -docdict[ - "eyelink_find_overlaps" -] = """ +docdict["eyelink_find_overlaps"] = """ find_overlaps : bool (default False) Combine left and right eye :class:`mne.Annotations` (blinks, fixations, saccades) if their start times and their stop times are both not separated by more than overlap_threshold. """ -docdict[ - "eyelink_fname" -] = """ +docdict["eyelink_fname"] = """ fname : path-like Path to the eyelink file (``.asc``).""" -docdict[ - "eyelink_overlap_threshold" -] = """ +docdict["eyelink_overlap_threshold"] = """ overlap_threshold : float (default 0.05) Time in seconds. Threshold of allowable time-gap between both the start and stop times of the left and right eyes. If the gap is larger than the threshold, @@ -1591,9 +1345,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # F -docdict[ - "f_power_clust" -] = """ +docdict["f_power_clust"] = """ t_power : float Power to raise the statistical values (usually F-values) by before summing (sign will be retained). Note that ``t_power=0`` will give a @@ -1601,9 +1353,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): by its statistical score. """ -docdict[ - "fiducials" -] = """ +docdict["fiducials"] = """ fiducials : list | dict | str The fiducials given in the MRI (surface RAS) coordinate system. If a dictionary is provided, it must contain the **keys** @@ -1618,17 +1368,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): and if absent, falls back to ``'estimated'``. """ -docdict[ - "fig_facecolor" -] = """\ +docdict["fig_facecolor"] = """\ fig_facecolor : str | tuple A matplotlib-compatible color to use for the figure background. Defaults to black. """ -docdict[ - "filter_length" -] = """ +docdict["filter_length"] = """ filter_length : str | int Length of the FIR filter to use (if applicable): @@ -1645,16 +1391,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): this should not be used. """ -docdict[ - "filter_length_ecg" -] = """ +docdict["filter_length_ecg"] = """ filter_length : str | int | None Number of taps to use for filtering. """ -docdict[ - "filter_length_notch" -] = """ +docdict["filter_length_notch"] = """ filter_length : str | int Length of the FIR filter to use (if applicable): @@ -1679,9 +1421,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): The default in 0.21 is None, but this will change to ``'10s'`` in 0.22. """ -docdict[ - "fir_design" -] = """ +docdict["fir_design"] = """ fir_design : str Can be "firwin" (default) to use :func:`scipy.signal.firwin`, or "firwin2" to use :func:`scipy.signal.firwin2`. "firwin" uses @@ -1691,9 +1431,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.15 """ -docdict[ - "fir_window" -] = """ +docdict["fir_window"] = """ fir_window : str The window to use in FIR design, can be "hamming" (default), "hann" (default in 0.13), or "blackman". @@ -1708,9 +1446,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): is smaller than this threshold, the epoch will be dropped. If ``None`` then no rejection is performed based on flatness of the signal.""" -docdict[ - "flat" -] = f""" +docdict["flat"] = f""" flat : dict | None {_flat_common} @@ -1718,9 +1454,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): quality, pass the ``reject_tmin`` and ``reject_tmax`` parameters. """ -docdict[ - "flat_drop_bad" -] = f""" +docdict["flat_drop_bad"] = f""" flat : dict | str | None {_flat_common} If ``'existing'``, then the flat parameters set during epoch creation are @@ -1737,9 +1471,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["fmin_fmax_psd_topo"] = _fmin_fmax.format("``fmin=0, fmax=100``.") -docdict[ - "fmin_fmid_fmax" -] = """ +docdict["fmin_fmid_fmax"] = """ fmin : float Minimum value in colormap (uses real fmin if None). fmid : float @@ -1749,33 +1481,25 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Maximum value in colormap (uses real max if None). """ -docdict[ - "fname_epochs" -] = """ +docdict["fname_epochs"] = """ fname : path-like | file-like The epochs to load. If a filename, should end with ``-epo.fif`` or ``-epo.fif.gz``. If a file-like object, preloading must be used. """ -docdict[ - "fname_export_params" -] = """ +docdict["fname_export_params"] = """ fname : str Name of the output file. """ -docdict[ - "fname_fwd" -] = """ +docdict["fname_fwd"] = """ fname : path-like File name to save the forward solution to. It should end with ``-fwd.fif`` or ``-fwd.fif.gz`` to save to FIF, or ``-fwd.h5`` to save to HDF5. """ -docdict[ - "fnirs" -] = """ +docdict["fnirs"] = """ fnirs : str | list | dict | bool | None Can be "channels", "pairs", "detectors", and/or "sources" to show the fNIRS channel locations, optode locations, or line between @@ -1788,34 +1512,26 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Added support for specifying alpha values as a dict. """ -docdict[ - "focalpoint" -] = """ +docdict["focalpoint"] = """ focalpoint : tuple, shape (3,) | str | None The focal point of the camera rendering the view: (x, y, z) in plot units (either m or mm). When ``"auto"``, it is set to the center of mass of the visible bounds. """ -docdict[ - "forward_set_eeg_reference" -] = """ +docdict["forward_set_eeg_reference"] = """ forward : instance of Forward | None Forward solution to use. Only used with ``ref_channels='REST'``. .. versionadded:: 0.21 """ -docdict[ - "freqs_tfr" -] = """ +docdict["freqs_tfr"] = """ freqs : array of float, shape (n_freqs,) The frequencies of interest in Hz. """ -docdict[ - "fullscreen" -] = """ +docdict["fullscreen"] = """ fullscreen : bool Whether to start in fullscreen (``True``) or windowed mode (``False``). @@ -1835,17 +1551,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): " because it will apply channel-wise" ) -docdict[ - "fwd" -] = """ +docdict["fwd"] = """ fwd : instance of Forward The forward solution. If present, the orientations of the dipoles present in the forward solution are displayed. """ -docdict[ - "fwhm_morlet_notes" -] = r""" +docdict["fwhm_morlet_notes"] = r""" Convolution of a signal with a Morlet wavelet will impose temporal smoothing that is determined by the duration of the wavelet. In MNE-Python, the duration of the wavelet is determined by the ``sigma`` parameter, which gives the @@ -1879,9 +1591,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # G -docdict[ - "get_peak_parameters" -] = """ +docdict["get_peak_parameters"] = """ tmin : float | None The minimum point in time to be considered for peak getting. tmax : float | None @@ -1911,9 +1621,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["getitem_epochspectrum_return"] = _getitem_base.format(*_fill_epochs) docdict["getitem_spectrum_return"] = _getitem_base.format("", "", "") -docdict[ - "group_by_browse" -] = """ +docdict["group_by_browse"] = """ group_by : str How to group channels. ``'type'`` groups by channel type, ``'original'`` plots in the order of ch_names, ``'selection'`` uses @@ -1929,17 +1637,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # H -docdict[ - "h_freq" -] = """ +docdict["h_freq"] = """ h_freq : float | None For FIR filters, the upper pass-band edge; for IIR filters, the upper cutoff frequency. If None the data are only high-passed. """ -docdict[ - "h_trans_bandwidth" -] = """ +docdict["h_trans_bandwidth"] = """ h_trans_bandwidth : float | str Width of the transition band at the high cut-off frequency in Hz (low pass or cutoff 2 in bandpass). Can be "auto" @@ -1950,9 +1654,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Only used for ``method='fir'``. """ -docdict[ - "head_pos" -] = """ +docdict["head_pos"] = """ head_pos : None | path-like | dict | tuple | array Path to the position estimates file. Should be in the format of the files produced by MaxFilter. If dict, keys should @@ -1964,26 +1666,20 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): :func:`mne.chpi.read_head_pos`. """ -docdict[ - "head_pos_maxwell" -] = """ +docdict["head_pos_maxwell"] = """ head_pos : array | None If array, movement compensation will be performed. The array should be of shape (N, 10), holding the position parameters as returned by e.g. ``read_head_pos``. """ -docdict[ - "head_source" -] = """ +docdict["head_source"] = """ head_source : str | list of str Head source(s) to use. See the ``source`` option of :func:`mne.get_head_surf` for more information. """ -docdict[ - "hitachi_fname" -] = """ +docdict["hitachi_fname"] = """ fname : list | str Path(s) to the Hitachi CSV file(s). This should only be a list for multiple probes that were acquired simultaneously. @@ -1992,9 +1688,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Added support for list-of-str. """ -docdict[ - "hitachi_notes" -] = """ +docdict["hitachi_notes"] = """ Hitachi does not encode their channel positions, so you will need to create a suitable mapping using :func:`mne.channels.make_standard_montage` or :func:`mne.channels.make_dig_montage` like (for a 3x5/ETG-7000 example): @@ -2049,9 +1743,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # I -docdict[ - "idx_pctf" -] = """ +docdict["idx_pctf"] = """ idx : list of int | list of Label Source for indices for which to compute PSFs or CTFs. If mode is None, PSFs/CTFs will be returned for all indices. If mode is not None, the @@ -2065,27 +1757,21 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): specified labels. """ -docdict[ - "ignore_ref_maxwell" -] = """ +docdict["ignore_ref_maxwell"] = """ ignore_ref : bool If True, do not include reference channels in compensation. This option should be True for KIT files, since Maxwell filtering with reference channels is not currently supported. """ -docdict[ - "iir_params" -] = """ +docdict["iir_params"] = """ iir_params : dict | None Dictionary of parameters to use for IIR filtering. If ``iir_params=None`` and ``method="iir"``, 4th order Butterworth will be used. For more information, see :func:`mne.filter.construct_iir_filter`. """ -docdict[ - "image_format_report" -] = """ +docdict["image_format_report"] = """ image_format : 'png' | 'svg' | 'gif' | None The image format to be used for the report, can be ``'png'``, ``'svg'``, or ``'gif'``. @@ -2093,9 +1779,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): instantiation. """ -docdict[ - "image_interp_topomap" -] = """ +docdict["image_interp_topomap"] = """ image_interp : str The image interpolation to be used. Options are ``'cubic'`` (default) to use :class:`scipy.interpolate.CloughTocher2DInterpolator`, @@ -2103,9 +1787,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``'linear'`` to use :class:`scipy.interpolate.LinearNDInterpolator`. """ -docdict[ - "include_tmax" -] = """ +docdict["include_tmax"] = """ include_tmax : bool If True (default), include tmax. If False, exclude tmax (similar to how Python indexing typically works). @@ -2139,39 +1821,29 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): "sensors and methods of measurement." ) -docdict[ - "info" -] = f""" +docdict["info"] = f""" info : mne.Info | None {_info_base} """ -docdict[ - "info_not_none" -] = f""" +docdict["info_not_none"] = f""" info : mne.Info {_info_base} """ -docdict[ - "info_str" -] = f""" +docdict["info_str"] = f""" info : mne.Info | path-like {_info_base} If ``path-like``, it should be a :class:`str` or :class:`pathlib.Path` to a file with measurement information (e.g. :class:`mne.io.Raw`). """ -docdict[ - "int_order_maxwell" -] = """ +docdict["int_order_maxwell"] = """ int_order : int Order of internal component of spherical expansion. """ -docdict[ - "interaction_scene" -] = """ +docdict["interaction_scene"] = """ interaction : 'trackball' | 'terrain' How interactions with the scene via an input device (e.g., mouse or trackpad) modify the camera position. If ``'terrain'``, one axis is @@ -2181,9 +1853,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): some axes. """ -docdict[ - "interaction_scene_none" -] = """ +docdict["interaction_scene_none"] = """ interaction : 'trackball' | 'terrain' | None How interactions with the scene via an input device (e.g., mouse or trackpad) modify the camera position. If ``'terrain'``, one axis is @@ -2195,27 +1865,21 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): used. """ -docdict[ - "interp" -] = """ +docdict["interp"] = """ interp : str Either ``'hann'``, ``'cos2'`` (default), ``'linear'``, or ``'zero'``, the type of forward-solution interpolation to use between forward solutions at different head positions. """ -docdict[ - "interpolation_brain_time" -] = """ +docdict["interpolation_brain_time"] = """ interpolation : str | None Interpolation method (:class:`scipy.interpolate.interp1d` parameter). Must be one of ``'linear'``, ``'nearest'``, ``'zero'``, ``'slinear'``, ``'quadratic'`` or ``'cubic'``. """ -docdict[ - "inversion_bf" -] = """ +docdict["inversion_bf"] = """ inversion : 'single' | 'matrix' This determines how the beamformer deals with source spaces in "free" orientation. Such source spaces define three orthogonal dipoles at each @@ -2232,9 +1896,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # J -docdict[ - "joint_set_eeg_reference" -] = """ +docdict["joint_set_eeg_reference"] = """ joint : bool How to handle list-of-str ``ch_type``. If False (default), one projector is created per channel type. If True, one projector is created across @@ -2246,9 +1908,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # K -docdict[ - "keep_his_anonymize_info" -] = """ +docdict["keep_his_anonymize_info"] = """ keep_his : bool If ``True``, ``his_id`` of ``subject_info`` will **not** be overwritten. Defaults to ``False``. @@ -2257,35 +1917,27 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): anonymized. Use with caution. """ -docdict[ - "kit_elp" -] = """ +docdict["kit_elp"] = """ elp : path-like | array of shape (8, 3) | None Digitizer points representing the location of the fiducials and the marker coils with respect to the digitized head shape, or path to a file containing these points. """ -docdict[ - "kit_hsp" -] = """ +docdict["kit_hsp"] = """ hsp : path-like | array of shape (n_points, 3) | None Digitizer head shape points, or path to head shape file. If more than 10,000 points are in the head shape, they are automatically decimated. """ -docdict[ - "kit_mrk" -] = """ +docdict["kit_mrk"] = """ mrk : path-like | array of shape (5, 3) | list | None Marker points representing the location of the marker coils with respect to the MEG sensors, or path to a marker file. If list, all of the markers will be averaged together. """ -docdict[ - "kit_slope" -] = r""" +docdict["kit_slope"] = r""" slope : ``'+'`` | ``'-'`` How to interpret values on KIT trigger channels when synthesizing a Neuromag-style stim channel. With ``'+'``\, a positive slope (low-to-high) @@ -2293,9 +1945,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): is interpreted as an event. """ -docdict[ - "kit_stim" -] = r""" +docdict["kit_stim"] = r""" stim : list of int | ``'<'`` | ``'>'`` | None Channel-value correspondence when converting KIT trigger channels to a Neuromag-style stim channel. For ``'<'``\, the largest values are @@ -2305,25 +1955,19 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): generated. """ -docdict[ - "kit_stimcode" -] = """ +docdict["kit_stimcode"] = """ stim_code : ``'binary'`` | ``'channel'`` How to decode trigger values from stim channels. ``'binary'`` read stim channel events as binary code, 'channel' encodes channel number. """ -docdict[ - "kit_stimthresh" -] = """ +docdict["kit_stimthresh"] = """ stimthresh : float | None The threshold level for accepting voltage changes in KIT trigger channels as a trigger event. If None, stim must also be set to None. """ -docdict[ - "kwargs_fun" -] = """ +docdict["kwargs_fun"] = """ **kwargs : dict Additional keyword arguments to pass to ``fun``. """ @@ -2331,26 +1975,20 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # L -docdict[ - "l_freq" -] = """ +docdict["l_freq"] = """ l_freq : float | None For FIR filters, the lower pass-band edge; for IIR filters, the lower cutoff frequency. If None the data are only low-passed. """ -docdict[ - "l_freq_ecg_filter" -] = """ +docdict["l_freq_ecg_filter"] = """ l_freq : float Low pass frequency to apply to the ECG channel while finding events. h_freq : float High pass frequency to apply to the ECG channel while finding events. """ -docdict[ - "l_trans_bandwidth" -] = """ +docdict["l_trans_bandwidth"] = """ l_trans_bandwidth : float | str Width of the transition band at the low cut-off frequency in Hz (high pass or cutoff 1 in bandpass). Can be "auto" @@ -2361,16 +1999,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Only used for ``method='fir'``. """ -docdict[ - "label_tc_el_returns" -] = """ +docdict["label_tc_el_returns"] = """ label_tc : array | list (or generator) of array, shape (n_labels[, n_orient], n_times) Extracted time course for each label and source estimate. """ -docdict[ - "labels_eltc" -] = """ +docdict["labels_eltc"] = """ labels : Label | BiHemiLabel | list | tuple | str If using a surface or mixed source space, this should be the :class:`~mne.Label`'s for which to extract the time course. @@ -2387,18 +2021,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Support for volume source estimates. """ -docdict[ - "layout_spectrum_plot_topo" -] = """\ +docdict["layout_spectrum_plot_topo"] = """\ layout : instance of Layout | None Layout instance specifying sensor positions (does not need to be specified for Neuromag data). If ``None`` (default), the layout is inferred from the data. """ -docdict[ - "line_alpha_plot_psd" -] = """\ +docdict["line_alpha_plot_psd"] = """\ line_alpha : float | None Alpha for the PSD line. Can be None (default) to use 1.0 when ``average=True`` and 0.1 when ``average=False``. @@ -2425,9 +2055,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["long_format_df_spe"] = _long_format_df_base.format(*spe) docdict["long_format_df_stc"] = _long_format_df_base.format(*stc) -docdict[ - "loose" -] = """ +docdict["loose"] = """ loose : float | 'auto' | dict Value that weights the source variances of the dipole components that are parallel (tangential) to the cortical surface. Can be: @@ -2446,9 +2074,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # M -docdict[ - "mag_scale_maxwell" -] = """ +docdict["mag_scale_maxwell"] = """ mag_scale : float | str The magenetometer scale-factor used to bring the magnetometers to approximately the same order of magnitude as the gradiometers @@ -2458,9 +2084,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): 59.5 for VectorView). """ -docdict[ - "mapping_rename_channels_duplicates" -] = """ +docdict["mapping_rename_channels_duplicates"] = """ mapping : dict | callable A dictionary mapping the old channel to a new channel name e.g. ``{'EEG061' : 'EEG161'}``. Can also be a callable function @@ -2490,9 +2114,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): "statistical test of the data reaches significance)", ) -docdict[ - "mask_params_topomap" -] = """ +docdict["mask_params_topomap"] = """ mask_params : dict | None Additional plotting parameters for plotting significant sensors. Default (None) equals:: @@ -2509,9 +2131,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): shape="(n_channels,)", shape_appendix="(s)", example="" ) -docdict[ - "match_alias" -] = """ +docdict["match_alias"] = """ match_alias : bool | dict Whether to use a lookup table to match unrecognized channel location names to their known aliases. If True, uses the mapping in @@ -2522,18 +2142,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.23 """ -docdict[ - "match_case" -] = """ +docdict["match_case"] = """ match_case : bool If True (default), channel name matching will be case sensitive. .. versionadded:: 0.20 """ -docdict[ - "max_dist_ieeg" -] = """ +docdict["max_dist_ieeg"] = """ max_dist : float The maximum distance to project a sensor to the pial surface in meters. Sensors that are greater than this distance from the pial surface will @@ -2541,17 +2157,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): flat brain. """ -docdict[ - "max_iter_multitaper" -] = """ +docdict["max_iter_multitaper"] = """ max_iter : int Maximum number of iterations to reach convergence when combining the tapered spectra with adaptive weights (see argument ``adaptive``). This argument has not effect if ``adaptive`` is set to ``False``.""" -docdict[ - "max_step_clust" -] = """ +docdict["max_step_clust"] = """ max_step : int Maximum distance between samples along the second axis of ``X`` to be considered adjacent (typically the second axis is the "time" dimension). @@ -2562,9 +2174,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): :func:`mne.stats.combine_adjacency`). """ -docdict[ - "measure" -] = """ +docdict["measure"] = """ measure : 'zscore' | 'correlation' Which method to use for finding outliers among the components: @@ -2577,9 +2187,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.21""" -docdict[ - "meg" -] = """ +docdict["meg"] = """ meg : str | list | dict | bool | None Can be "helmet", "sensors" or "ref" to show the MEG helmet, sensors or reference sensors respectively, or a combination like @@ -2591,9 +2199,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Added support for specifying alpha values as a dict. """ -docdict[ - "metadata_epochs" -] = """ +docdict["metadata_epochs"] = """ metadata : instance of pandas.DataFrame | None A :class:`pandas.DataFrame` specifying metadata about each epoch. If given, ``len(metadata)`` must equal ``len(events)``. The DataFrame @@ -2607,17 +2213,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.16 """ -docdict[ - "method_fir" -] = """ +docdict["method_fir"] = """ method : str ``'fir'`` will use overlap-add FIR filtering, ``'iir'`` will use IIR forward-backward filtering (via :func:`~scipy.signal.filtfilt`). """ -docdict[ - "method_kw_psd" -] = """\ +docdict["method_kw_psd"] = """\ **method_kw Additional keyword arguments passed to the spectral estimation function (e.g., ``n_fft, n_overlap, n_per_seg, average, window`` @@ -2643,16 +2245,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["method_psd"] = _method_psd.format("", "") docdict["method_psd_auto"] = _method_psd.format(" | ``'auto'``", "") -docdict[ - "mode_eltc" -] = """ +docdict["mode_eltc"] = """ mode : str Extraction mode, see Notes. """ -docdict[ - "mode_pctf" -] = """ +docdict["mode_pctf"] = """ mode : None | 'mean' | 'max' | 'svd' Compute summary of PSFs/CTFs across all indices specified in 'idx'. Can be: @@ -2666,9 +2264,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): n_comp first SVD components. """ -docdict[ - "montage" -] = """ +docdict["montage"] = """ montage : None | str | DigMontage A montage containing channel positions. If a string or :class:`~mne.channels.DigMontage` is @@ -2682,9 +2278,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["montage_types"] = """EEG/sEEG/ECoG/DBS/fNIRS""" -docdict[ - "montage_units" -] = """ +docdict["montage_units"] = """ montage_units : str Units that channel positions are represented in. Defaults to "mm" (millimeters), but can be any prefix + "m" combination (including just @@ -2693,22 +2287,16 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 1.3 """ -docdict[ - "morlet_reference" -] = """ +docdict["morlet_reference"] = """ The Morlet wavelets follow the formulation in :footcite:t:`Tallon-BaudryEtAl1997`. """ -docdict[ - "moving" -] = """ +docdict["moving"] = """ moving : instance of SpatialImage The image to morph ("from" volume). """ -docdict[ - "mri_resolution_eltc" -] = """ +docdict["mri_resolution_eltc"] = """ mri_resolution : bool If True (default), the volume source space will be upsampled to the original MRI resolution via trilinear interpolation before the atlas values @@ -2722,17 +2310,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # N -docdict[ - "n_comp_pctf_n" -] = """ +docdict["n_comp_pctf_n"] = """ n_comp : int Number of PSF/CTF components to return for mode='max' or mode='svd'. Default n_comp=1. """ -docdict[ - "n_cycles_tfr" -] = """ +docdict["n_cycles_tfr"] = """ n_cycles : int | array of int, shape (n_freqs,) Number of cycles in the wavelet, either a fixed number or one per frequency. The number of cycles ``n_cycles`` and the frequencies of @@ -2741,9 +2325,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): and about time and frequency smoothing. """ -docdict[ - "n_jobs" -] = """\ +docdict["n_jobs"] = """\ n_jobs : int | None The number of jobs to run in parallel. If ``-1``, it is set to the number of CPU cores. Requires the :mod:`joblib` package. @@ -2753,25 +2335,19 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): value for ``n_jobs``. """ -docdict[ - "n_jobs_cuda" -] = """ +docdict["n_jobs_cuda"] = """ n_jobs : int | str Number of jobs to run in parallel. Can be ``'cuda'`` if ``cupy`` is installed properly. """ -docdict[ - "n_jobs_fir" -] = """ +docdict["n_jobs_fir"] = """ n_jobs : int | str Number of jobs to run in parallel. Can be ``'cuda'`` if ``cupy`` is installed properly and ``method='fir'``. """ -docdict[ - "n_pca_components_apply" -] = """ +docdict["n_pca_components_apply"] = """ n_pca_components : int | float | None The number of PCA components to be kept, either absolute (int) or fraction of the explained variance (float). If None (default), @@ -2779,24 +2355,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): in 0.23 all components will be used. """ -docdict[ - "n_permutations_clust_all" -] = """ +docdict["n_permutations_clust_all"] = """ n_permutations : int | 'all' The number of permutations to compute. Can be 'all' to perform an exact test. """ -docdict[ - "n_permutations_clust_int" -] = """ +docdict["n_permutations_clust_int"] = """ n_permutations : int The number of permutations to compute. """ -docdict[ - "n_proj_vectors" -] = """ +docdict["n_proj_vectors"] = """ n_grad : int | float between ``0`` and ``1`` Number of vectors for gradiometers. Either an integer or a float between 0 and 1 to select the number of vectors to explain the cumulative variance greater than @@ -2811,18 +2381,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``n_eeg``. """ -docdict[ - "names_topomap" -] = """\ +docdict["names_topomap"] = """\ names : None | list Labels for the sensors. If a :class:`list`, labels should correspond to the order of channels in ``data``. If ``None`` (default), no channel names are plotted. """ -docdict[ - "nirx_notes" -] = """ +docdict["nirx_notes"] = """ This function has only been tested with NIRScout and NIRSport devices, and with the NIRStar software version 15 and above and Aurora software 2021 and above. @@ -2836,9 +2402,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): saturated data. """ -docdict[ - "niter" -] = """ +docdict["niter"] = """ niter : dict | tuple | None For each phase of the volume registration, ``niter`` is the number of iterations per successive stage of optimization. If a tuple is @@ -2857,9 +2421,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): sdr=(5, 5, 3)) """ -docdict[ - "norm_pctf" -] = """ +docdict["norm_pctf"] = """ norm : None | 'max' | 'norm' Whether and how to normalise the PSFs and CTFs. This will be applied before computing summaries as specified in 'mode'. @@ -2870,24 +2432,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): * 'norm' : Normalize to maximum norm across all PSFs/CTFs. """ -docdict[ - "normalization" -] = """normalization : 'full' | 'length' +docdict["normalization"] = """normalization : 'full' | 'length' Normalization strategy. If "full", the PSD will be normalized by the sampling rate as well as the length of the signal (as in :ref:`Nitime `). Default is ``'length'``.""" -docdict[ - "normalize_psd_topo" -] = """ +docdict["normalize_psd_topo"] = """ normalize : bool If True, each band will be divided by the total power. Defaults to False. """ -docdict[ - "notes_2d_backend" -] = """\ +docdict["notes_2d_backend"] = """\ MNE-Python provides two different backends for browsing plots (i.e., :meth:`raw.plot()`, :meth:`epochs.plot()`, and :meth:`ica.plot_sources()`). One is @@ -2915,9 +2471,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["notes_plot_*_psd_func"] = _notes_plot_psd.format("function") docdict["notes_plot_psd_meth"] = _notes_plot_psd.format("method") -docdict[ - "notes_spectrum_array" -] = """ +docdict["notes_spectrum_array"] = """ It is assumed that the data passed in represent spectral *power* (not amplitude, phase, model coefficients, etc) and downstream methods (such as :meth:`~mne.time_frequency.SpectrumArray.plot`) assume power data. If you pass in @@ -2925,27 +2479,21 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): other things may also not work or be incorrect). """ -docdict[ - "notes_tmax_included_by_default" -] = """ +docdict["notes_tmax_included_by_default"] = """ Unlike Python slices, MNE time intervals by default include **both** their end points; ``crop(tmin, tmax)`` returns the interval ``tmin <= t <= tmax``. Pass ``include_tmax=False`` to specify the half-open interval ``tmin <= t < tmax`` instead. """ -docdict[ - "npad" -] = """ +docdict["npad"] = """ npad : int | str Amount to pad the start and end of the data. Can also be ``"auto"`` to use a padding that will result in a power-of-two size (can be much faster). """ -docdict[ - "nrows_ncols_ica_components" -] = """ +docdict["nrows_ncols_ica_components"] = """ nrows, ncols : int | 'auto' The number of rows and columns of topographies to plot. If both ``nrows`` and ``ncols`` are ``'auto'``, will plot up to 20 components in a 5×4 grid, @@ -2956,9 +2504,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``nrows='auto', ncols='auto'``. """ -docdict[ - "nrows_ncols_topomap" -] = """ +docdict["nrows_ncols_topomap"] = """ nrows, ncols : int | 'auto' The number of rows and columns of topographies to plot. If either ``nrows`` or ``ncols`` is ``'auto'``, the necessary number will be inferred. Defaults @@ -2968,9 +2514,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # O -docdict[ - "offset_decim" -] = """ +docdict["offset_decim"] = """ offset : int Apply an offset to where the decimation starts relative to the sample corresponding to t=0. The offset is in samples at the @@ -2979,9 +2523,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.12 """ -docdict[ - "on_baseline_ica" -] = """ +docdict["on_baseline_ica"] = """ on_baseline : str How to handle baseline-corrected epochs or evoked data. Can be ``'raise'`` to raise an error, ``'warn'`` (default) to emit a @@ -2990,9 +2532,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 1.2 """ -docdict[ - "on_defects" -] = """ +docdict["on_defects"] = """ on_defects : 'raise' | 'warn' | 'ignore' What to do if the surface is found to have topological defects. Can be ``'raise'`` (default) to raise an error, ``'warn'`` to emit a @@ -3003,9 +2543,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): fail irrespective of this parameter. """ -docdict[ - "on_header_missing" -] = """ +docdict["on_header_missing"] = """ on_header_missing : str Can be ``'raise'`` (default) to raise an error, ``'warn'`` to emit a warning, or ``'ignore'`` to ignore when the FastSCAN header is missing. @@ -3018,9 +2556,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): warning, or ``'ignore'`` to ignore when""" -docdict[ - "on_mismatch_info" -] = f""" +docdict["on_mismatch_info"] = f""" on_mismatch : 'raise' | 'warn' | 'ignore' {_on_missing_base} the device-to-head transformation differs between instances. @@ -3028,27 +2564,21 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.24 """ -docdict[ - "on_missing_ch_names" -] = f""" +docdict["on_missing_ch_names"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} entries in ch_names are not present in the raw instance. .. versionadded:: 0.23.0 """ -docdict[ - "on_missing_chpi" -] = f""" +docdict["on_missing_chpi"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} no cHPI information can be found. If ``'ignore'`` or ``'warn'``, all return values will be empty arrays or ``None``. If ``'raise'``, an exception will be raised. """ -docdict[ - "on_missing_epochs" -] = """ +docdict["on_missing_epochs"] = """ on_missing : 'raise' | 'warn' | 'ignore' What to do if one or several event ids are not found in the recording. Valid keys are 'raise' | 'warn' | 'ignore' @@ -3060,9 +2590,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): automatically generated irrespective of this parameter. """ -docdict[ - "on_missing_events" -] = f""" +docdict["on_missing_events"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} event numbers from ``event_id`` are missing from :term:`events`. When numbers from :term:`events` are missing from @@ -3072,32 +2600,24 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.21 """ -docdict[ - "on_missing_fiducials" -] = f""" +docdict["on_missing_fiducials"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} some necessary fiducial points are missing. """ -docdict[ - "on_missing_fwd" -] = f""" +docdict["on_missing_fwd"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} ``stc`` has vertices that are not in ``fwd``. """ -docdict[ - "on_missing_montage" -] = f""" +docdict["on_missing_montage"] = f""" on_missing : 'raise' | 'warn' | 'ignore' {_on_missing_base} channels have missing coordinates. .. versionadded:: 0.20.1 """ -docdict[ - "on_rank_mismatch" -] = """ +docdict["on_rank_mismatch"] = """ on_rank_mismatch : str If an explicit MEG value is passed, what to do when it does not match an empirically computed rank (only used for covariances). @@ -3107,18 +2627,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.23 """ -docdict[ - "on_split_missing" -] = f""" +docdict["on_split_missing"] = f""" on_split_missing : str {_on_missing_base} split file is missing. .. versionadded:: 0.22 """ -docdict[ - "ordered" -] = """ +docdict["ordered"] = """ ordered : bool If True (default False), ensure that the order of the channels in the modified instance matches the order of ``ch_names``. @@ -3128,9 +2644,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): The default changed from False in 1.4 to True in 1.5. """ -docdict[ - "origin_maxwell" -] = """ +docdict["origin_maxwell"] = """ 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 @@ -3142,9 +2656,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): options or specifying the origin manually. """ -docdict[ - "out_type_clust" -] = """ +docdict["out_type_clust"] = """ out_type : 'mask' | 'indices' Output format of clusters within a list. If ``'mask'``, returns a list of boolean arrays, @@ -3157,9 +2669,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Default is ``'indices'``. """ -docdict[ - "outlines_topomap" -] = """ +docdict["outlines_topomap"] = """ outlines : 'head' | dict | None The outlines to be drawn. If 'head', the default head scheme will be drawn. If dict, each key refers to a tuple of x and y positions, the values @@ -3170,9 +2680,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Defaults to 'head'. """ -docdict[ - "overview_mode" -] = """ +docdict["overview_mode"] = """ overview_mode : str | None Can be "channels", "empty", or "hidden" to set the overview bar mode for the ``'qt'`` backend. If None (default), the config option @@ -3180,9 +2688,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): if it's not found. """ -docdict[ - "overwrite" -] = """ +docdict["overwrite"] = """ overwrite : bool If True (default False), overwrite the destination file if it exists. @@ -3208,26 +2714,20 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ ) -docdict[ - "pca_vars_pctf" -] = """ +docdict["pca_vars_pctf"] = """ pca_vars : array, shape (n_comp,) | list of array The explained variances of the first n_comp SVD components across the PSFs/CTFs for the specified vertices. Arrays for multiple labels are returned as list. Only returned if ``mode='svd'`` and ``return_pca_vars=True``. """ -docdict[ - "per_sample_metric" -] = """ +docdict["per_sample_metric"] = """ per_sample : bool If True the metric is computed for each sample separately. If False, the metric is spatio-temporal. """ -docdict[ - "phase" -] = """ +docdict["phase"] = """ phase : str Phase of the filter. When ``method='fir'``, symmetric linear-phase FIR filters are constructed, @@ -3247,9 +2747,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.13 """ -docdict[ - "physical_range_export_params" -] = """ +docdict["physical_range_export_params"] = """ physical_range : str | tuple The physical range of the data. If 'auto' (default), then it will infer the physical min and max from the data itself, @@ -3283,9 +2781,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): """ ) -docdict[ - "pick_ori_bf" -] = """ +docdict["pick_ori_bf"] = """ pick_ori : None | str For forward solutions with fixed orientation, None (default) must be used and a scalar beamformer is computed. For free-orientation forward @@ -3307,9 +2803,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): + _pick_ori_novec ) -docdict[ - "pick_types_params" -] = """ +docdict["pick_types_params"] = """ meg : bool | str If True include MEG channels. If string it can be 'mag', 'grad', 'planar1' or 'planar2' to select only magnetometers, all @@ -3423,9 +2917,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): f"{picks_base} good data channels {noref}" ) docdict["picks_header"] = _picks_header -docdict[ - "picks_ica" -] = """ +docdict["picks_ica"] = """ picks : int | list of int | slice | None Indices of the independent components (ICs) to visualize. If an integer, represents the index of the IC to pick. @@ -3434,24 +2926,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): IC: ``ICA001``. ``None`` will pick all independent components in the order fitted. """ -docdict[ - "picks_nostr" -] = f"""picks : list | slice | None +docdict["picks_nostr"] = f"""picks : list | slice | None {_picks_desc} {_picks_int} None (default) will pick all channels. {reminder_nostr}""" -docdict[ - "picks_plot_projs_joint_trace" -] = f"""\ +docdict["picks_plot_projs_joint_trace"] = f"""\ picks_trace : {_picks_types} Channels to show alongside the projected time courses. Typically these are the ground-truth channels for an artifact (e.g., ``'eog'`` or ``'ecg'``). {_picks_int} {_picks_str} no channels. """ -docdict[ - "pipeline" -] = """ +docdict["pipeline"] = """ pipeline : str | tuple The volume registration steps to perform (a ``str`` for a single step, or ``tuple`` for a set of sequential steps). The following steps can be @@ -3490,9 +2976,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): the SDR step. """ -docdict[ - "plot_psd_doc" -] = """\ +docdict["plot_psd_doc"] = """\ Plot power or amplitude spectra. Separate plots are drawn for each channel type. When the data have been @@ -3512,16 +2996,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["pos_topomap"] = _pos_topomap.format(" | instance of Info") docdict["pos_topomap_psd"] = _pos_topomap.format("") -docdict[ - "position" -] = """ +docdict["position"] = """ position : int The position for the progress bar. """ -docdict[ - "precompute" -] = """ +docdict["precompute"] = """ precompute : bool | str Whether to load all data (not just the visible portion) into RAM and apply preprocessing (e.g., projectors) to the full data array in a separate @@ -3536,9 +3016,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Support for the MNE_BROWSER_PRECOMPUTE config variable. """ -docdict[ - "preload" -] = """ +docdict["preload"] = """ preload : bool or str (default False) Preload data into memory for data manipulation and faster indexing. If True, the data will be preloaded into memory (fast, requires @@ -3546,9 +3024,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): file name of a memory-mapped file which is used to store the data on the hard drive (slower, requires less memory).""" -docdict[ - "preload_concatenate" -] = """ +docdict["preload_concatenate"] = """ preload : bool, str, or None (default None) Preload data into memory for data manipulation and faster indexing. If True, the data will be preloaded into memory (fast, requires @@ -3559,9 +3035,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): of the instances passed in. """ -docdict[ - "proj_epochs" -] = """ +docdict["proj_epochs"] = """ proj : bool | 'delayed' Apply SSP projection vectors. If proj is 'delayed' and reject is not None the single epochs will be projected before the rejection @@ -3575,9 +3049,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): recommended value if SSPs are not used for cleaning the data. """ -docdict[ - "proj_plot" -] = """ +docdict["proj_plot"] = """ proj : bool | 'interactive' | 'reconstruct' If true SSP projections are applied before display. If 'interactive', a check box for reversible selection of SSP projection vectors will @@ -3589,17 +3061,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Support for 'reconstruct' was added. """ -docdict[ - "proj_psd" -] = """\ +docdict["proj_psd"] = """\ proj : bool Whether to apply SSP projection vectors before spectral estimation. Default is ``False``. """ -docdict[ - "projection_set_eeg_reference" -] = """ +docdict["projection_set_eeg_reference"] = """ projection : bool If ``ref_channels='average'`` this argument specifies if the average reference should be computed as a projection (True) or not @@ -3611,16 +3079,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): must be set to ``False`` (the default in this case). """ -docdict[ - "projs" -] = """ +docdict["projs"] = """ projs : list of Projection List of computed projection vectors. """ -docdict[ - "projs_report" -] = """ +docdict["projs_report"] = """ projs : bool | None Whether to add SSP projector plots if projectors are present in the data. If ``None``, use ``projs`` from `~mne.Report` creation. @@ -3629,9 +3093,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # R -docdict[ - "random_state" -] = """ +docdict["random_state"] = """ random_state : None | int | instance of ~numpy.random.RandomState A seed for the NumPy random number generator (RNG). If ``None`` (default), the seed will be obtained from the operating system @@ -3690,24 +3152,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["rank_info"] = _rank_base + "\n The default is ``'info'``." docdict["rank_none"] = _rank_base + "\n The default is ``None``." -docdict[ - "raw_epochs" -] = """ +docdict["raw_epochs"] = """ raw : Raw object An instance of `~mne.io.Raw`. """ -docdict[ - "raw_sfreq" -] = """ +docdict["raw_sfreq"] = """ raw_sfreq : float The original Raw object sampling rate. If None, then it is set to ``info['sfreq']``. """ -docdict[ - "reduce_rank" -] = """ +docdict["reduce_rank"] = """ reduce_rank : bool If True, the rank of the denominator of the beamformer formula (i.e., during pseudo-inversion) will be reduced by one for each spatial location. @@ -3719,18 +3175,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``pick='max_power'`` with weight normalization). """ -docdict[ - "ref_channels" -] = """ +docdict["ref_channels"] = """ ref_channels : str | list of str Name of the electrode(s) which served as the reference in the recording. If a name is provided, a corresponding channel is added and its data is set to 0. This is useful for later re-referencing. """ -docdict[ - "ref_channels_set_eeg_reference" -] = """ +docdict["ref_channels_set_eeg_reference"] = """ ref_channels : list of str | str Can be: @@ -3742,16 +3194,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): the data """ -docdict[ - "reg_affine" -] = """ +docdict["reg_affine"] = """ reg_affine : ndarray of float, shape (4, 4) The affine that registers one volume to another. """ -docdict[ - "regularize_maxwell_reg" -] = """ +docdict["regularize_maxwell_reg"] = """ regularize : str | None Basis regularization type, must be ``"in"`` or None. ``"in"`` is the same algorithm as the ``-regularize in`` option in @@ -3768,18 +3216,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["reject_by_annotation_all"] = _reject_by_annotation_base -docdict[ - "reject_by_annotation_epochs" -] = """ +docdict["reject_by_annotation_epochs"] = """ reject_by_annotation : bool Whether to reject based on annotations. If ``True`` (default), epochs overlapping with segments whose description begins with ``'bad'`` are rejected. If ``False``, no rejection based on annotations is performed. """ -docdict[ - "reject_by_annotation_psd" -] = """\ +docdict["reject_by_annotation_psd"] = """\ reject_by_annotation : bool Whether to omit bad spans of data before spectral estimation. If ``True``, spans with annotations whose description begins with @@ -3817,18 +3261,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): difference will be preserved. """ -docdict[ - "reject_drop_bad" -] = f""" +docdict["reject_drop_bad"] = f""" reject : dict | str | None {_reject_common} If ``reject`` is ``None``, no rejection is performed. If ``'existing'`` (default), then the rejection parameters set at instantiation are used. """ -docdict[ - "reject_epochs" -] = f""" +docdict["reject_epochs"] = f""" reject : dict | None {_reject_common} .. note:: To constrain the time period used for estimation of signal @@ -3837,17 +3277,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): If ``reject`` is ``None`` (default), no rejection is performed. """ -docdict[ - "remove_dc" -] = """ +docdict["remove_dc"] = """ remove_dc : bool If ``True``, the mean is subtracted from each segment before computing its spectrum. """ -docdict[ - "replace_report" -] = """ +docdict["replace_report"] = """ replace : bool If ``True``, content already present that has the same ``title`` and ``section`` will be replaced. Defaults to ``False``, which will cause @@ -3855,16 +3291,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): already exists. """ -docdict[ - "res_topomap" -] = """ +docdict["res_topomap"] = """ res : int The resolution of the topomap image (number of pixels along each side). """ -docdict[ - "return_pca_vars_pctf" -] = """ +docdict["return_pca_vars_pctf"] = """ return_pca_vars : bool Whether or not to return the explained variances across the specified vertices for individual SVD components. This is only valid if @@ -3872,9 +3304,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): Default return_pca_vars=False. """ -docdict[ - "roll" -] = """ +docdict["roll"] = """ roll : float | None The roll of the camera rendering the view in degrees. """ @@ -3882,9 +3312,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # S -docdict[ - "saturated" -] = """saturated : str +docdict["saturated"] = """saturated : str Replace saturated segments of data with NaNs, can be: ``"ignore"`` @@ -3903,9 +3331,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.24 """ -docdict[ - "scalings" -] = """ +docdict["scalings"] = """ scalings : 'auto' | dict | None Scaling factors for the traces. If a dictionary where any value is ``'auto'``, the scaling factor is set to match the 99.5th @@ -3926,26 +3352,20 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): positive direction and 20 µV in the negative direction). """ -docdict[ - "scalings_df" -] = """ +docdict["scalings_df"] = """ scalings : dict | None Scaling factor applied to the channels picked. If ``None``, defaults to ``dict(eeg=1e6, mag=1e15, grad=1e13)`` — i.e., converts EEG to µV, magnetometers to fT, and gradiometers to fT/cm. """ -docdict[ - "scalings_topomap" -] = """ +docdict["scalings_topomap"] = """ scalings : dict | float | None The scalings of the channel types to be applied for plotting. If None, defaults to ``dict(eeg=1e6, grad=1e13, mag=1e15)``. """ -docdict[ - "scoring" -] = """ +docdict["scoring"] = """ scoring : callable | str | None Score function (or loss function) with signature ``score_func(y, y_pred, **kwargs)``. @@ -3955,17 +3375,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ``scoring=sklearn.metrics.roc_auc_score``). """ -docdict[ - "sdr_morph" -] = """ +docdict["sdr_morph"] = """ sdr_morph : instance of dipy.align.DiffeomorphicMap The class that applies the the symmetric diffeomorphic registration (SDR) morph. """ -docdict[ - "section_report" -] = """ +docdict["section_report"] = """ section : str | None The name of the section (or content block) to add the content to. This feature is useful for grouping multiple related content elements @@ -3977,9 +3393,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 1.1 """ -docdict[ - "seed" -] = """ +docdict["seed"] = """ seed : None | int | instance of ~numpy.random.RandomState A seed for the NumPy random number generator (RNG). If ``None`` (default), the seed will be obtained from the operating system @@ -3989,24 +3403,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): the RNG with a defined state. """ -docdict[ - "seeg" -] = """ +docdict["seeg"] = """ seeg : bool If True (default), show sEEG electrodes. """ -docdict[ - "selection" -] = """ +docdict["selection"] = """ selection : iterable | None Iterable of indices of selected epochs. If ``None``, will be automatically generated, corresponding to all non-zero events. """ -docdict[ - "sensor_colors" -] = """ +docdict["sensor_colors"] = """ sensor_colors : array-like of color | dict | None Colors to use for the sensor glyphs. Can be None (default) to use default colors. A dict should provide the colors (values) for each channel type (keys), e.g.:: @@ -4020,9 +3428,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): shape ``(n_eeg, 3)`` or ``(n_eeg, 4)``. """ -docdict[ - "sensors_topomap" -] = """ +docdict["sensors_topomap"] = """ sensors : bool | str Whether to add markers for sensor locations. If :class:`str`, should be a valid matplotlib format string (e.g., ``'r+'`` for red plusses, see the @@ -4030,9 +3436,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): default), black circles will be used. """ -docdict[ - "set_eeg_reference_see_also_notes" -] = """ +docdict["set_eeg_reference_see_also_notes"] = """ See Also -------- mne.set_bipolar_reference : Convenience function for creating bipolar @@ -4082,16 +3486,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. footbibliography:: """ -docdict[ - "show" -] = """\ +docdict["show"] = """\ show : bool Show the figure if ``True``. """ -docdict[ - "show_names_topomap" -] = """ +docdict["show_names_topomap"] = """ show_names : bool | callable If ``True``, show channel names next to each sensor marker. If callable, channel names will be formatted using the callable; e.g., to @@ -4100,18 +3500,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): non-masked sensor names will be shown. """ -docdict[ - "show_scalebars" -] = """ +docdict["show_scalebars"] = """ show_scalebars : bool Whether to show scale bars when the plot is initialized. Can be toggled after initialization by pressing :kbd:`s` while the plot window is focused. Default is ``True``. """ -docdict[ - "show_scrollbars" -] = """ +docdict["show_scrollbars"] = """ show_scrollbars : bool Whether to show scrollbars when the plot is initialized. Can be toggled after initialization by pressing :kbd:`z` ("zen mode") while the plot @@ -4120,9 +3516,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.19.0 """ -docdict[ - "show_traces" -] = """ +docdict["show_traces"] = """ show_traces : bool | str | float If True, enable interactive picking of a point on the surface of the brain and plot its time course. @@ -4136,16 +3530,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.20.0 """ -docdict[ - "size_topomap" -] = """ +docdict["size_topomap"] = """ size : float Side length of each subplot in inches. """ -docdict[ - "skip_by_annotation" -] = """ +docdict["skip_by_annotation"] = """ skip_by_annotation : str | list of str If a string (or list of str), any annotation segment that begins with the given string will not be included in filtering, and @@ -4157,9 +3547,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): To disable, provide an empty list. Only used if ``inst`` is raw. """ -docdict[ - "skip_by_annotation_maxwell" -] = """ +docdict["skip_by_annotation_maxwell"] = """ skip_by_annotation : str | list of str If a string (or list of str), any annotation segment that begins with the given string will not be included in filtering, and @@ -4171,24 +3559,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): To disable, provide an empty list. """ -docdict[ - "smooth" -] = """ +docdict["smooth"] = """ smooth : float in [0, 1) The smoothing factor to be applied. Default 0 is no smoothing. """ -docdict[ - "spatial_colors_psd" -] = """\ +docdict["spatial_colors_psd"] = """\ spatial_colors : bool Whether to color spectrum lines by channel location. Ignored if ``average=True``. """ -docdict[ - "sphere_topomap_auto" -] = f"""\ +docdict["sphere_topomap_auto"] = f"""\ sphere : float | array-like | instance of ConductorModel | None | 'auto' | 'eeglab' The sphere parameters to use for the head outline. Can be array-like of shape (4,) to give the X/Y/Z origin and radius in meters, or a single float @@ -4205,17 +3587,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionchanged:: 1.1 Added ``'eeglab'`` option. """ -docdict[ - "splash" -] = """ +docdict["splash"] = """ splash : bool If True (default), a splash screen is shown during the application startup. Only applicable to the ``qt`` backend. """ -docdict[ - "split_naming" -] = """ +docdict["split_naming"] = """ split_naming : 'neuromag' | 'bids' When splitting files, append a filename partition with the appropriate naming schema: for ``'neuromag'``, a split file ``fname.fif`` will be named @@ -4223,16 +3601,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): it will be named ``fname_split-01.fif``, ``fname_split-02.fif``, etc. """ -docdict[ - "src_eltc" -] = """ +docdict["src_eltc"] = """ src : instance of SourceSpaces The source spaces for the source time courses. """ -docdict[ - "src_volume_options" -] = """ +docdict["src_volume_options"] = """ src : instance of SourceSpaces | None The source space corresponding to the source estimate. Only necessary if the STC is a volume or mixed source estimate. @@ -4263,9 +3637,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): entry. """ -docdict[ - "st_fixed_maxwell_only" -] = """ +docdict["st_fixed_maxwell_only"] = """ st_fixed : bool If True (default), do tSSS using the median head position during the ``st_duration`` window. This is the default behavior of MaxFilter @@ -4287,9 +3659,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.12 """ -docdict[ - "standardize_names" -] = """ +docdict["standardize_names"] = """ standardize_names : bool If True, standardize MEG and EEG channel names to be ``'MEG ###'`` and ``'EEG ###'``. If False (default), native @@ -4307,48 +3677,36 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): docdict["stat_fun_clust_t"] = _stat_fun_clust_base.format("ttest_1samp_no_p") -docdict[ - "static" -] = """ +docdict["static"] = """ static : instance of SpatialImage The image to align with ("to" volume). """ -docdict[ - "stc_est_metric" -] = """ +docdict["stc_est_metric"] = """ stc_est : instance of (Vol|Mixed)SourceEstimate The source estimates containing estimated values e.g. obtained with a source imaging method. """ -docdict[ - "stc_metric" -] = """ +docdict["stc_metric"] = """ metric : float | array, shape (n_times,) The metric. float if per_sample is False, else array with the values computed for each time point. """ -docdict[ - "stc_plot_kwargs_report" -] = """ +docdict["stc_plot_kwargs_report"] = """ stc_plot_kwargs : dict Dictionary of keyword arguments to pass to :class:`mne.SourceEstimate.plot`. Only used when plotting in 3D mode. """ -docdict[ - "stc_true_metric" -] = """ +docdict["stc_true_metric"] = """ stc_true : instance of (Vol|Mixed)SourceEstimate The source estimates containing correct values. """ -docdict[ - "stcs_pctf" -] = """ +docdict["stcs_pctf"] = """ stcs : instance of SourceEstimate | list of instances of SourceEstimate The PSFs or CTFs as STC objects. All PSFs/CTFs will be returned as successive samples in STC objects, in the order they are specified @@ -4364,9 +3722,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): a VectorSourceEstimate object. """ -docdict[ - "std_err_by_event_type_returns" -] = """ +docdict["std_err_by_event_type_returns"] = """ std_err : instance of Evoked | list of Evoked The standard error over epochs. When ``by_event_type=True`` was specified, a list is returned containing a @@ -4375,9 +3731,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): dictionary. """ -docdict[ - "step_down_p_clust" -] = """ +docdict["step_down_p_clust"] = """ step_down_p : float To perform a step-down-in-jumps test, pass a p-value for clusters to exclude from each successive iteration. Default is zero, perform no @@ -4386,48 +3740,36 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): but costs computation time. """ -docdict[ - "subject" -] = """ +docdict["subject"] = """ subject : str The FreeSurfer subject name. """ -docdict[ - "subject_label" -] = """ +docdict["subject_label"] = """ subject : str | None Subject which this label belongs to. Should only be specified if it is not specified in the label. """ -docdict[ - "subject_none" -] = """ +docdict["subject_none"] = """ subject : str | None The FreeSurfer subject name. """ -docdict[ - "subject_optional" -] = """ +docdict["subject_optional"] = """ subject : str The FreeSurfer subject name. While not necessary, it is safer to set the subject parameter to avoid analysis errors. """ -docdict[ - "subjects_dir" -] = """ +docdict["subjects_dir"] = """ subjects_dir : path-like | None The path to the directory containing the FreeSurfer subjects reconstructions. If ``None``, defaults to the ``SUBJECTS_DIR`` environment variable. """ -docdict[ - "surface" -] = """surface : str +docdict["surface"] = """surface : str The surface along which to do the computations, defaults to ``'white'`` (the gray-white matter boundary). """ @@ -4435,9 +3777,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # T -docdict[ - "t_power_clust" -] = """ +docdict["t_power_clust"] = """ t_power : float Power to raise the statistical values (usually t-values) by before summing (sign will be retained). Note that ``t_power=0`` will give a @@ -4445,24 +3785,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): by its statistical score. """ -docdict[ - "t_window_chpi_t" -] = """ +docdict["t_window_chpi_t"] = """ t_window : float Time window to use to estimate the amplitudes, default is 0.2 (200 ms). """ -docdict[ - "tags_report" -] = """ +docdict["tags_report"] = """ tags : array-like of str | str Tags to add for later interactive filtering. Must not contain spaces. """ -docdict[ - "tail_clust" -] = """ +docdict["tail_clust"] = """ tail : int If tail is 1, the statistic is thresholded above threshold. If tail is -1, the statistic is thresholded below threshold. @@ -4470,9 +3804,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): the distribution. """ -docdict[ - "temporal_window_tfr_intro" -] = """ +docdict["temporal_window_tfr_intro"] = """ In spectrotemporal analysis (as with traditional fourier methods), the temporal and spectral resolution are interrelated: longer temporal windows allow more precise frequency estimates; shorter temporal windows "smear" @@ -4492,9 +3824,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): multitapers and wavelets `_. """ # noqa: E501 -docdict[ - "temporal_window_tfr_morlet_notes" -] = r""" +docdict["temporal_window_tfr_morlet_notes"] = r""" In MNE-Python, the length of the Morlet wavelet is affected by the arguments ``freqs`` and ``n_cycles``, which define the frequencies of interest and the number of cycles, respectively. For the time-frequency representation, @@ -4512,9 +3842,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): For more information on the Morlet wavelet, see :func:`mne.time_frequency.morlet`. """ -docdict[ - "temporal_window_tfr_multitaper_notes" -] = r""" +docdict["temporal_window_tfr_multitaper_notes"] = r""" In MNE-Python, the multitaper temporal window length is defined by the arguments ``freqs`` and ``n_cycles``, respectively defining the frequencies of interest and the number of cycles: :math:`T = \frac{\mathtt{n\_cycles}}{\mathtt{freqs}}` @@ -4539,26 +3867,16 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): defaulting to "auto" if it's not found.\ """ -docdict[ - "theme_3d" -] = """ +docdict["theme_3d"] = """ {theme} -""".format( - theme=_theme.format(config_option="MNE_3D_OPTION_THEME") -) +""".format(theme=_theme.format(config_option="MNE_3D_OPTION_THEME")) -docdict[ - "theme_pg" -] = """ +docdict["theme_pg"] = """ {theme} Only supported by the ``'qt'`` backend. -""".format( - theme=_theme.format(config_option="MNE_BROWSER_THEME") -) +""".format(theme=_theme.format(config_option="MNE_BROWSER_THEME")) -docdict[ - "thresh" -] = """ +docdict["thresh"] = """ thresh : None or float Not supported yet. If not None, values below thresh will not be visible. @@ -4582,9 +3900,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): f_test = ("an F-threshold", "an F-statistic") docdict["threshold_clust_f"] = _threshold_clust_base.format(*f_test) -docdict[ - "threshold_clust_f_notes" -] = """ +docdict["threshold_clust_f_notes"] = """ For computing a ``threshold`` based on a p-value, use the conversion from :meth:`scipy.stats.rv_continuous.ppf`:: @@ -4597,9 +3913,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): t_test = ("a t-threshold", "a t-statistic") docdict["threshold_clust_t"] = _threshold_clust_base.format(*t_test) -docdict[ - "threshold_clust_t_notes" -] = """ +docdict["threshold_clust_t_notes"] = """ For computing a ``threshold`` based on a p-value, use the conversion from :meth:`scipy.stats.rv_continuous.ppf`:: @@ -4611,9 +3925,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): For testing the lower tail (``tail=-1``), don't subtract ``pval`` from 1. """ -docdict[ - "time_bandwidth_tfr" -] = """ +docdict["time_bandwidth_tfr"] = """ time_bandwidth : float ``≥ 2.0`` Product between the temporal window length (in seconds) and the *full* frequency bandwidth (in Hz). This product can be seen as the surface of the @@ -4621,9 +3933,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): (thus the frequency resolution) and the number of good tapers. See notes for additional information.""" -docdict[ - "time_bandwidth_tfr_notes" -] = r""" +docdict["time_bandwidth_tfr_notes"] = r""" In MNE-Python's multitaper functions, the frequency bandwidth is additionally affected by the parameter ``time_bandwidth``. The ``n_cycles`` parameter determines the temporal window length based on the @@ -4659,9 +3969,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): example above, the half-frequency bandwidth is 2 Hz. """ -docdict[ - "time_format" -] = """ +docdict["time_format"] = """ time_format : 'float' | 'clock' Style of time labels on the horizontal axis. If ``'float'``, labels will be number of seconds from the start of the recording. If ``'clock'``, @@ -4689,9 +3997,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ) docdict["time_format_df_raw"] = _time_format_df_base.format(_raw_tf) -docdict[ - "time_label" -] = """ +docdict["time_label"] = """ time_label : str | callable | None Format of the time label (a format string, a function that maps floating point time values to strings, or None for no label). The @@ -4699,69 +4005,51 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): is more than one time point. """ -docdict[ - "time_unit" -] = """\ +docdict["time_unit"] = """\ time_unit : str The units for the time axis, can be "s" (default) or "ms". """ -docdict[ - "time_viewer_brain_screenshot" -] = """ +docdict["time_viewer_brain_screenshot"] = """ time_viewer : bool If True, include time viewer traces. Only used if ``time_viewer=True`` and ``separate_canvas=False``. """ -docdict[ - "title_none" -] = """ +docdict["title_none"] = """ title : str | None The title of the generated figure. If ``None`` (default), no title is displayed. """ -docdict[ - "tmax_raw" -] = """ +docdict["tmax_raw"] = """ tmax : float End time of the raw data to use in seconds (cannot exceed data duration). """ -docdict[ - "tmin" -] = """ +docdict["tmin"] = """ tmin : scalar Time point of the first sample in data. """ -docdict[ - "tmin_epochs" -] = """ +docdict["tmin_epochs"] = """ tmin : float Start time before event. If nothing provided, defaults to 0. """ -docdict[ - "tmin_raw" -] = """ +docdict["tmin_raw"] = """ tmin : float Start time of the raw data to use in seconds (must be >= 0). """ -docdict[ - "tmin_tmax_psd" -] = """\ +docdict["tmin_tmax_psd"] = """\ tmin, tmax : float | None First and last times to include, in seconds. ``None`` uses the first or last time present in the data. Default is ``tmin=None, tmax=None`` (all times). """ -docdict[ - "tol_kind_rank" -] = """ +docdict["tol_kind_rank"] = """ tol_kind : str Can be: "absolute" (default) or "relative". Only used if ``tol`` is a float, because when ``tol`` is a string the mode is implicitly relative. @@ -4780,9 +4068,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 0.21.0 """ -docdict[ - "tol_rank" -] = """ +docdict["tol_rank"] = """ tol : float | 'auto' Tolerance for singular values to consider non-zero in calculating the rank. The singular values are calculated @@ -4791,9 +4077,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): same thresholding as :func:`scipy.linalg.orth`. """ -docdict[ - "topomap_kwargs" -] = """ +docdict["topomap_kwargs"] = """ topomap_kwargs : dict | None Keyword arguments to pass to the topomap-generating functions. """ @@ -4803,26 +4087,18 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): during coregistration. Can also be ``'fsaverage'`` to use the built-in fsaverage transformation.""" -docdict[ - "trans" -] = f""" +docdict["trans"] = f""" trans : path-like | dict | instance of Transform | ``"fsaverage"`` | None {_trans_base} If trans is None, an identity matrix is assumed. """ -docdict[ - "trans_not_none" -] = """ +docdict["trans_not_none"] = """ trans : str | dict | instance of Transform %s -""" % ( - _trans_base, -) +""" % (_trans_base,) -docdict[ - "transparent" -] = """ +docdict["transparent"] = """ transparent : bool | None If True: use a linear transparency between fmin and fmid and make values below fmin fully transparent (symmetrically for @@ -4830,17 +4106,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): type. """ -docdict[ - "tstart_ecg" -] = """ +docdict["tstart_ecg"] = """ tstart : float Start ECG detection after ``tstart`` seconds. Useful when the beginning of the run is noisy. """ -docdict[ - "tstep" -] = """ +docdict["tstep"] = """ tstep : scalar Time step between successive samples in data. """ @@ -4848,18 +4120,14 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # U -docdict[ - "ui_event_name_source" -] = """ +docdict["ui_event_name_source"] = """ name : str The name of the event (same as its class name but in snake_case). source : matplotlib.figure.Figure | Figure3D The figure that published the event. """ -docdict[ - "uint16_codec" -] = """ +docdict["uint16_codec"] = """ uint16_codec : str | None If your set file contains non-ascii characters, sometimes reading it may fail and give rise to error message stating that "buffer is @@ -4868,9 +4136,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): can therefore help you solve this problem. """ -docdict[ - "units" -] = """ +docdict["units"] = """ units : str | dict | None Specify the unit(s) that the data should be returned in. If ``None`` (default), the data is returned in the @@ -4889,9 +4155,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): channel-type-specific default unit. """ -docdict[ - "units_edf_bdf_io" -] = """ +docdict["units_edf_bdf_io"] = """ units : dict | str The units of the channels as stored in the file. This argument is useful only if the units are missing from the original file. @@ -4910,17 +4174,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): "dict | ", "and ``scalings=None`` the unit is automatically determined, otherwise " ) -docdict[ - "use_cps" -] = """ +docdict["use_cps"] = """ use_cps : bool Whether to use cortical patch statistics to define normal orientations for surfaces (default True). """ -docdict[ - "use_cps_restricted" -] = """ +docdict["use_cps_restricted"] = """ use_cps : bool Whether to use cortical patch statistics to define normal orientations for surfaces (default True). @@ -4929,9 +4189,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): not in surface orientation, and ``pick_ori='normal'``. """ -docdict[ - "use_opengl" -] = """ +docdict["use_opengl"] = """ use_opengl : bool | None Whether to use OpenGL when rendering the plot (requires ``pyopengl``). May increase performance, but effect is dependent on system CPU and @@ -4946,9 +4204,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # V -docdict[ - "vector_pctf" -] = """ +docdict["vector_pctf"] = """ vector : bool Whether to return PSF/CTF as vector source estimate (3 values per location) or source estimate object (1 intensity value per location). @@ -4958,9 +4214,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): .. versionadded:: 1.2 """ -docdict[ - "verbose" -] = """ +docdict["verbose"] = """ verbose : bool | str | int | None Control verbosity of the logging output. If ``None``, use the default verbosity level. See the :ref:`logging documentation ` and @@ -4968,17 +4222,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): argument. """ -docdict[ - "vertices_volume" -] = """ +docdict["vertices_volume"] = """ vertices : list of array of int The indices of the dipoles in the source space. Should be a single array of shape (n_dipoles,) unless there are subvolumes. """ -docdict[ - "view" -] = """ +docdict["view"] = """ view : str | None The name of the view to show (e.g. "lateral"). Other arguments take precedence and modify the camera starting from the ``view``. @@ -4986,17 +4236,13 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): string shortcut options. """ -docdict[ - "view_layout" -] = """ +docdict["view_layout"] = """ view_layout : str Can be "vertical" (default) or "horizontal". When using "horizontal" mode, the PyVista backend must be used and hemi cannot be "split". """ -docdict[ - "views" -] = """ +docdict["views"] = """ views : str | list View to use. Using multiple views (list) is not supported for mpl backend. See :meth:`Brain.show_view ` for @@ -5032,9 +4278,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): ) docdict["vlim_plot_topomap_psd"] = _vlim_joint.format("topomap", _vlim_callable, "") -docdict[ - "vmin_vmax_topomap" -] = """ +docdict["vmin_vmax_topomap"] = """ vmin, vmax : float | callable | None Lower and upper bounds of the colormap, in the same units as the data. If ``vmin`` and ``vmax`` are both ``None``, they are set at ± the @@ -5048,9 +4292,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # W -docdict[ - "weight_norm" -] = """ +docdict["weight_norm"] = """ weight_norm : str | None Can be: @@ -5082,16 +4324,12 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): solution. """ -docdict[ - "window_psd" -] = """\ +docdict["window_psd"] = """\ window : str | float | tuple Windowing function to use. See :func:`scipy.signal.get_window`. """ -docdict[ - "window_resample" -] = """ +docdict["window_resample"] = """ window : str | tuple Frequency-domain window to use in resampling. See :func:`scipy.signal.resample`. @@ -5100,9 +4338,7 @@ def _reflow_param_docstring(docstring, has_first_line=True, width=75): # %% # X -docdict[ - "xscale_plot_psd" -] = """\ +docdict["xscale_plot_psd"] = """\ xscale : 'linear' | 'log' Scale of the frequency axis. Default is ``'linear'``. """ @@ -5505,7 +4741,7 @@ def open_docs(kind=None, version=None): class _decorator: """Inject code or modify the docstring of a class, method, or function.""" - def __init__(self, extra): # noqa: D102 + def __init__(self, extra): self.kind = self.__class__.__name__ self.extra = extra self.msg = f"NOTE: {{}}() is a {self.kind} {{}}. {self.extra}." @@ -5625,7 +4861,7 @@ class legacy(_decorator): and in a sphinx warning box in the docstring. """ - def __init__(self, alt, extra=""): # noqa: D102 + def __init__(self, alt, extra=""): period = ". " if len(extra) else "" extra = f"New code should use {alt}{period}{extra}" super().__init__(extra=extra) diff --git a/mne/utils/progressbar.py b/mne/utils/progressbar.py index 94f595dd441..14429cb9033 100644 --- a/mne/utils/progressbar.py +++ b/mne/utils/progressbar.py @@ -55,7 +55,7 @@ def __init__( *, which_tqdm=None, **kwargs, - ): # noqa: D102 + ): # The following mimics this, but with configurable module to use # from ..externals.tqdm import auto import tqdm diff --git a/mne/viz/_3d.py b/mne/viz/_3d.py index 5f68fd0a46e..b67b9f49096 100644 --- a/mne/viz/_3d.py +++ b/mne/viz/_3d.py @@ -2187,8 +2187,7 @@ def link_brains(brains, time=True, camera=False, colorbar=True, picking=False): if _get_3d_backend() != "pyvistaqt": raise NotImplementedError( - "Expected 3d backend is pyvistaqt but" - " {} was given.".format(_get_3d_backend()) + f"Expected 3d backend is pyvistaqt but {_get_3d_backend()} was given." ) from ._brain import Brain, _LinkViewer diff --git a/mne/viz/backends/_utils.py b/mne/viz/backends/_utils.py index d613a909f67..e9e4ea439aa 100644 --- a/mne/viz/backends/_utils.py +++ b/mne/viz/backends/_utils.py @@ -73,8 +73,7 @@ def _check_color(color): ) else: raise TypeError( - "Expected type is `str` or iterable but " - "{} was given.".format(type(color)) + f"Expected type is `str` or iterable but {type(color)} was given." ) return color @@ -327,9 +326,7 @@ def _qt_get_stylesheet(theme): height: 16px; image: url("%(icons_path)s/toolbar_move_vertical@2x.png"); } -""" % dict( - icons_path=icons_path - ) +""" % dict(icons_path=icons_path) else: # Here we are on non-macOS (or on macOS but our sys theme does not # match the requested theme) diff --git a/mne/viz/epochs.py b/mne/viz/epochs.py index 20dbeed142c..c830570d457 100644 --- a/mne/viz/epochs.py +++ b/mne/viz/epochs.py @@ -468,8 +468,7 @@ def _validate_fig_and_axes(fig, axes, group_by, evoked, colorbar, clear=False): # `plot_image`, be forgiving of presence/absence of sensor inset axis. if len(fig.axes) not in (n_axes, n_axes + 1): raise ValueError( - '{}"fig" must contain {} axes, got {}.' - "".format(prefix, n_axes, len(fig.axes)) + f'{prefix}"fig" must contain {n_axes} axes, got {len(fig.axes)}.' ) if len(list(group_by)) != 1: raise ValueError( @@ -498,8 +497,7 @@ def _validate_fig_and_axes(fig, axes, group_by, evoked, colorbar, clear=False): if isinstance(axes, list): if len(axes) != n_axes: raise ValueError( - '{}"axes" must be length {}, got {}.' - "".format(prefix, n_axes, len(axes)) + f'{prefix}"axes" must be length {n_axes}, got {len(axes)}.' ) # for list of axes to work, must be only one group if len(list(group_by)) != 1: diff --git a/mne/viz/evoked.py b/mne/viz/evoked.py index ccbe48eabd4..3db8d745368 100644 --- a/mne/viz/evoked.py +++ b/mne/viz/evoked.py @@ -2475,8 +2475,7 @@ def _draw_axes_pce( ybounds = _trim_ticks(ax.get_yticks(), ymin, ymax)[[0, -1]] else: raise ValueError( - '"truncate_yaxis" must be bool or ' - '"auto", got {}'.format(truncate_yaxis) + f'"truncate_yaxis" must be bool or "auto", got {truncate_yaxis}' ) _setup_ax_spines( ax, diff --git a/mne/viz/topomap.py b/mne/viz/topomap.py index f78d035e0ad..4c66d58b80e 100644 --- a/mne/viz/topomap.py +++ b/mne/viz/topomap.py @@ -1218,9 +1218,8 @@ def _plot_topomap( raise ValueError("Multiple channel types in Info structure. " + info_help) elif len(pos["chs"]) != data.shape[0]: raise ValueError( - "Number of channels in the Info object (%s) and " - "the data array (%s) do not match. " % (len(pos["chs"]), data.shape[0]) - + info_help + f"Number of channels in the Info object ({len(pos['chs'])}) and the " + f"data array ({data.shape[0]}) do not match." + info_help ) else: ch_type = ch_type.pop() diff --git a/mne/viz/utils.py b/mne/viz/utils.py index 15a43916dc4..dd8323a2f85 100644 --- a/mne/viz/utils.py +++ b/mne/viz/utils.py @@ -457,8 +457,7 @@ def _prepare_trellis( naxes = ncols * nrows if naxes < n_cells: raise ValueError( - "Cannot plot {} axes in a {} by {} " - "figure.".format(n_cells, nrows, ncols) + f"Cannot plot {n_cells} axes in a {nrows} by {ncols} figure." ) width = size * ncols diff --git a/pyproject.toml b/pyproject.toml index 1145bdafcde..d3caea4706f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,7 +117,6 @@ test = [ "twine", "wheel", "pre-commit", - "black", ] # Dependencies for being able to run additional tests (rare/CIs/advanced devs) @@ -264,9 +263,6 @@ addopts = """--durations=20 --doctest-modules -ra --cov-report= --tb=short \ --color=yes --capture=sys""" junit_family = "xunit2" -[tool.black] -exclude = "(dist/)|(build/)|(.*\\.ipynb)" - [tool.bandit.assert_used] skips = ["*/test_*.py"] # assert statements are good practice with pytest diff --git a/tutorials/epochs/20_visualize_epochs.py b/tutorials/epochs/20_visualize_epochs.py index 5fc1a454700..69864d19e26 100644 --- a/tutorials/epochs/20_visualize_epochs.py +++ b/tutorials/epochs/20_visualize_epochs.py @@ -245,7 +245,9 @@ # therefore mask smaller signal fluctuations of interest. reject_criteria = dict( - mag=3000e-15, grad=3000e-13, eeg=150e-6 # 3000 fT # 3000 fT/cm + mag=3000e-15, # 3000 fT + grad=3000e-13, # 3000 fT/cm + eeg=150e-6, ) # 150 µV epochs.drop_bad(reject=reject_criteria) diff --git a/tutorials/inverse/20_dipole_fit.py b/tutorials/inverse/20_dipole_fit.py index f12e5968546..bf40d55e4ea 100644 --- a/tutorials/inverse/20_dipole_fit.py +++ b/tutorials/inverse/20_dipole_fit.py @@ -117,8 +117,7 @@ plot_params["colorbar"] = True diff.plot_topomap(time_format="Difference", axes=axes[2:], **plot_params) fig.suptitle( - "Comparison of measured and predicted fields " - "at {:.0f} ms".format(best_time * 1000.0), + f"Comparison of measured and predicted fields at {best_time * 1000:.0f} ms", fontsize=16, ) diff --git a/tutorials/raw/10_raw_overview.py b/tutorials/raw/10_raw_overview.py index 31dfbf12325..7b777046afc 100644 --- a/tutorials/raw/10_raw_overview.py +++ b/tutorials/raw/10_raw_overview.py @@ -142,8 +142,8 @@ ch_names = raw.ch_names n_chan = len(ch_names) # note: there is no raw.n_channels attribute print( - "the (cropped) sample data object has {} time samples and {} channels." - "".format(n_time_samps, n_chan) + f"the (cropped) sample data object has {n_time_samps} time samples and " + f"{n_chan} channels." ) print("The last time sample is at {} seconds.".format(time_secs[-1])) print("The first few channel names are {}.".format(", ".join(ch_names[:3]))) diff --git a/tutorials/stats-source-space/60_cluster_rmANOVA_spatiotemporal.py b/tutorials/stats-source-space/60_cluster_rmANOVA_spatiotemporal.py index 0951280e6d6..24c0adc9d35 100644 --- a/tutorials/stats-source-space/60_cluster_rmANOVA_spatiotemporal.py +++ b/tutorials/stats-source-space/60_cluster_rmANOVA_spatiotemporal.py @@ -285,9 +285,7 @@ def stat_fun(*args): inds_t, inds_v = [ (clusters[cluster_ind]) for ii, cluster_ind in enumerate(good_cluster_inds) -][ - 0 -] # first cluster +][0] # first cluster times = np.arange(X[0].shape[1]) * tstep * 1e3