From bbc4bd25b7210fb6f579daffeb46df50eb2ea242 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:07:35 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.2](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.9.2) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d2d3ce4a8..c8f7a4888 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,6 +1,6 @@ repos: - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.8.6 + rev: v0.9.2 hooks: - id: ruff name: ruff mne_bids/ From 5bec6b54f9f597fdcb8138b052f25b327c3f14d3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 20 Jan 2025 22:07:42 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- examples/mark_bad_channels.py | 8 +++---- .../commands/mne_bids_calibration_to_bids.py | 4 +--- mne_bids/commands/mne_bids_inspect.py | 4 +--- mne_bids/commands/mne_bids_mark_channels.py | 2 +- mne_bids/config.py | 3 +-- mne_bids/copyfiles.py | 10 ++++---- mne_bids/dig.py | 4 ++-- mne_bids/path.py | 23 +++++++++---------- mne_bids/read.py | 20 ++++++++-------- mne_bids/report/_report.py | 2 +- mne_bids/sidecar_updates.py | 6 ++--- mne_bids/tests/test_path.py | 23 ++++++------------- mne_bids/tests/test_utils.py | 4 ++-- mne_bids/tests/test_write.py | 10 +++----- mne_bids/utils.py | 4 ++-- mne_bids/write.py | 23 ++++++++----------- 16 files changed, 63 insertions(+), 87 deletions(-) diff --git a/examples/mark_bad_channels.py b/examples/mark_bad_channels.py index 39ffee7fe..e23b2f54c 100644 --- a/examples/mark_bad_channels.py +++ b/examples/mark_bad_channels.py @@ -118,7 +118,7 @@ raw = read_raw_bids(bids_path=bids_path, verbose=False) print( f"The following channels are currently marked as bad:\n" - f' {", ".join(raw.info["bads"])}\n' + f" {', '.join(raw.info['bads'])}\n" ) # %% @@ -137,7 +137,7 @@ raw = read_raw_bids(bids_path=bids_path, verbose=False) print( f"After marking MEG 0112 and MEG 0131 as bad, the following channels " - f'are now marked as bad:\n {", ".join(raw.info["bads"])}\n' + f"are now marked as bad:\n {', '.join(raw.info['bads'])}\n" ) # %% @@ -159,7 +159,7 @@ print( f"After marking MEG 0112 and MEG 0131 as bad and passing " f"`overwrite=True`, the following channels " - f'are now marked as bad:\n {", ".join(raw.info["bads"])}\n' + f"are now marked as bad:\n {', '.join(raw.info['bads'])}\n" ) # %% @@ -172,5 +172,5 @@ raw = read_raw_bids(bids_path=bids_path, verbose=False) print( f"After passing `ch_names=[]` and `overwrite=True`, the following " - f'channels are now marked as bad:\n {", ".join(raw.info["bads"])}\n' + f"channels are now marked as bad:\n {', '.join(raw.info['bads'])}\n" ) diff --git a/mne_bids/commands/mne_bids_calibration_to_bids.py b/mne_bids/commands/mne_bids_calibration_to_bids.py index d67c02f38..81aa68d23 100644 --- a/mne_bids/commands/mne_bids_calibration_to_bids.py +++ b/mne_bids/commands/mne_bids_calibration_to_bids.py @@ -44,9 +44,7 @@ def run(): opt, args = parser.parse_args() if args: parser.print_help() - parser.error( - f"Please do not specify arguments without flags. " f"Got: {args}.\n" - ) + parser.error(f"Please do not specify arguments without flags. Got: {args}.\n") if opt.bids_root is None: parser.print_help() diff --git a/mne_bids/commands/mne_bids_inspect.py b/mne_bids/commands/mne_bids_inspect.py index 8a0e98d2f..f94a070cf 100644 --- a/mne_bids/commands/mne_bids_inspect.py +++ b/mne_bids/commands/mne_bids_inspect.py @@ -72,9 +72,7 @@ def run(): opt, args = parser.parse_args() if args: parser.print_help() - parser.error( - f"Please do not specify arguments without flags. " f"Got: {args}.\n" - ) + parser.error(f"Please do not specify arguments without flags. Got: {args}.\n") if opt.bids_root is None: parser.print_help() diff --git a/mne_bids/commands/mne_bids_mark_channels.py b/mne_bids/commands/mne_bids_mark_channels.py index 11a3777b9..13f425a4f 100644 --- a/mne_bids/commands/mne_bids_mark_channels.py +++ b/mne_bids/commands/mne_bids_mark_channels.py @@ -126,7 +126,7 @@ def run(): return # XXX should be return with an error code? logger.info( - f'Marking channels {", ".join(ch_names)} as bad in ' + f"Marking channels {', '.join(ch_names)} as bad in " f"{len(bids_paths)} recording(s) …" ) for bids_path in bids_paths: diff --git a/mne_bids/config.py b/mne_bids/config.py index 7b6a38e51..103fc1dbb 100644 --- a/mne_bids/config.py +++ b/mne_bids/config.py @@ -530,8 +530,7 @@ def _map_options(what, key, fro, to): mapped_option = mapping_mne_bids.get(key, None) else: raise RuntimeError( - f"fro value {fro} and to value {to} are not " - "accepted. Use 'mne', or 'bids'." + f"fro value {fro} and to value {to} are not accepted. Use 'mne', or 'bids'." ) return mapped_option diff --git a/mne_bids/copyfiles.py b/mne_bids/copyfiles.py index 84a2078d4..48deb6a1b 100644 --- a/mne_bids/copyfiles.py +++ b/mne_bids/copyfiles.py @@ -82,7 +82,7 @@ def _get_brainvision_paths(vhdr_path): """ fname, ext = _parse_ext(vhdr_path) if ext != ".vhdr": - raise ValueError(f'Expecting file ending in ".vhdr",' f" but got {ext}") + raise ValueError(f'Expecting file ending in ".vhdr", but got {ext}') # Header file seems fine # extract encoding from brainvision header file, or default to utf-8 @@ -96,14 +96,14 @@ def _get_brainvision_paths(vhdr_path): eeg_file_match = re.search(r"DataFile=(.*\.(eeg|dat))", " ".join(lines)) if not eeg_file_match: - raise ValueError("Could not find a .eeg or .dat file link in" f" {vhdr_path}") + raise ValueError(f"Could not find a .eeg or .dat file link in {vhdr_path}") else: eeg_file = eeg_file_match.groups()[0] # Try to find marker file .vmrk vmrk_file_match = re.search(r"MarkerFile=(.*\.vmrk)", " ".join(lines)) if not vmrk_file_match: - raise ValueError("Could not find a .vmrk file link in" f" {vhdr_path}") + raise ValueError(f"Could not find a .vmrk file link in {vhdr_path}") else: vmrk_file = vmrk_file_match.groups()[0] @@ -275,7 +275,7 @@ def _anonymize_brainvision(vhdr_file, date): # Go through VHDR pattern = re.compile(r"^Impedance \[kOhm\] at \d\d:\d\d:\d\d :$") - replace = f'at {date.strftime("%H:%M:%S")} :' + replace = f"at {date.strftime('%H:%M:%S')} :" _replace_file(vhdr_file, pattern, replace) @@ -544,7 +544,7 @@ def copyfile_eeglab(src, dest): fname_dest, ext_dest = _parse_ext(dest) if ext_src != ext_dest: raise ValueError( - f"Need to move data with same extension" f" but got {ext_src}, {ext_dest}" + f"Need to move data with same extension but got {ext_src}, {ext_dest}" ) # Load the EEG struct diff --git a/mne_bids/dig.py b/mne_bids/dig.py index 7a690b13e..000636c84 100644 --- a/mne_bids/dig.py +++ b/mne_bids/dig.py @@ -45,7 +45,7 @@ def _handle_electrodes_reading(electrodes_fname, coord_frame, coord_unit): Handle xyz coordinates and coordinate frame of each channel. """ - logger.info("Reading electrode " f"coords from {electrodes_fname}.") + logger.info(f"Reading electrode coords from {electrodes_fname}.") electrodes_dict = _from_tsv(electrodes_fname) ch_names_tsv = electrodes_dict["name"] @@ -142,7 +142,7 @@ def _write_electrodes_tsv(raw, fname, datatype, overwrite=False): x, y, z, names = list(), list(), list(), list() for ch in raw.info["chs"]: if ch["kind"] == FIFF.FIFFV_STIM_CH: - logger.debug(f"Not writing stim chan {ch['ch_name']} " f"to electrodes.tsv") + logger.debug(f"Not writing stim chan {ch['ch_name']} to electrodes.tsv") continue elif np.isnan(ch["loc"][:3]).any() or np.allclose(ch["loc"][:3], 0): x.append("n/a") diff --git a/mne_bids/path.py b/mne_bids/path.py index a824ba50a..5c964feeb 100644 --- a/mne_bids/path.py +++ b/mne_bids/path.py @@ -905,9 +905,9 @@ def fpath(self): msg = ( "Found more than one matching data file for the " "requested recording. While searching:\n" - f'{indent(repr(self), " ")}\n' + f"{indent(repr(self), ' ')}\n" f"Found {len(matching_paths)} paths:\n" - f'{indent(matching_paths_str, " ")}\n' + f"{indent(matching_paths_str, ' ')}\n" "Cannot proceed due to the " "ambiguity. This is likely a problem with your " "BIDS dataset. Please run the BIDS validator on " @@ -1005,7 +1005,7 @@ def update(self, *, check=None, **kwargs): if key not in ENTITY_VALUE_TYPE: raise ValueError( - f"Key must be one of " f"{ALLOWED_PATH_ENTITIES}, got {key}" + f"Key must be one of {ALLOWED_PATH_ENTITIES}, got {key}" ) if ENTITY_VALUE_TYPE[key] == "label": @@ -1152,7 +1152,7 @@ def _check(self): allowed_spaces_for_dtype = ALLOWED_SPACES.get(datatype, None) if allowed_spaces_for_dtype is None: raise ValueError( - f"space entity is not valid for datatype " f"{self.datatype}" + f"space entity is not valid for datatype {self.datatype}" ) elif space not in allowed_spaces_for_dtype: raise ValueError( @@ -1462,7 +1462,9 @@ def _truncate_tsv_line(line, lim=10): """Truncate a line to the specified number of characters.""" return "".join( [ - str(val) + (lim - len(val)) * " " if len(val) < lim else f"{val[:lim - 1]} " + str(val) + (lim - len(val)) * " " + if len(val) < lim + else f"{val[: lim - 1]} " for val in line.split("\t") ] ) @@ -1762,7 +1764,7 @@ def get_entities_from_fname(fname, on_error="raise", verbose=None): if on_error in ("raise", "warn"): if key not in fname_vals: - msg = f'Unexpected entity "{key}" found in ' f'filename "{fname}"' + msg = f'Unexpected entity "{key}" found in filename "{fname}"' if on_error == "raise": raise KeyError(msg) elif on_error == "warn": @@ -1864,10 +1866,7 @@ def _find_matching_sidecar(bids_path, suffix=None, extension=None, on_error="rai # If this was expected, simply return None, otherwise, raise an exception. msg = None if len(best_candidates) == 0: - msg = ( - f"Did not find any {search_suffix} " - f"associated with {bids_path.basename}." - ) + msg = f"Did not find any {search_suffix} associated with {bids_path.basename}." elif len(best_candidates) > 1: # More than one candidates were tied for best match msg = ( @@ -2085,7 +2084,7 @@ def get_entity_vals( if entity_key not in entities: raise ValueError( - f'`key` must be one of: {", ".join(entities)}. ' f"Got: {entity_key}" + f"`key` must be one of: {', '.join(entities)}. Got: {entity_key}" ) ignore_subjects = _ensure_tuple(ignore_subjects) @@ -2530,7 +2529,7 @@ def _return_root_paths(root, datatype=None, ignore_json=True, ignore_nosub=False if datatype is not None: datatype = _ensure_tuple(datatype) - search_str = f'*/{"|".join(datatype)}/*' + search_str = f"*/{'|'.join(datatype)}/*" else: search_str = "*.*" diff --git a/mne_bids/read.py b/mne_bids/read.py index 149ca3517..65984bdc0 100644 --- a/mne_bids/read.py +++ b/mne_bids/read.py @@ -126,7 +126,7 @@ def _read_events(events, event_id, raw, bids_path=None): # retrieve events if isinstance(events, np.ndarray): if events.ndim != 2: - raise ValueError("Events must have two dimensions, " f"found {events.ndim}") + raise ValueError(f"Events must have two dimensions, found {events.ndim}") if events.shape[1] != 3: raise ValueError( "Events must have second dimension of length 3, " @@ -164,7 +164,7 @@ def _read_events(events, event_id, raw, bids_path=None): f"The provided raw data contains annotations, but " f'"event_id" does not contain entries for all annotation ' f"descriptions. The following entries are missing: " - f'{", ".join(desc_without_id)}' + f"{', '.join(desc_without_id)}" ) # If we have events, convert them to Annotations so they can be easily @@ -174,7 +174,7 @@ def _read_events(events, event_id, raw, bids_path=None): if ids_without_desc: raise ValueError( f"No description was specified for the following event(s): " - f'{", ".join([str(x) for x in sorted(ids_without_desc)])}. ' + f"{', '.join([str(x) for x in sorted(ids_without_desc)])}. " f"Please add them to the event_id dictionary, or drop them " f"from the events array." ) @@ -409,9 +409,7 @@ def _handle_scans_reading(scans_fname, raw, bids_path): # Convert time offset to UTC acq_time = acq_time.astimezone(timezone.utc) - logger.debug( - f"Loaded {scans_fname} scans file to set " f"acq_time as {acq_time}." - ) + logger.debug(f"Loaded {scans_fname} scans file to set acq_time as {acq_time}.") # First set measurement date to None and then call call anonymize() to # remove any traces of the measurement date we wish # to replace – it might lurk out in more places than just @@ -728,7 +726,7 @@ def _handle_channels_reading(channels_fname, raw): if ch_diff: warn( f"Cannot set channel type for the following channels, as they " - f'are missing in the raw data: {", ".join(sorted(ch_diff))}' + f"are missing in the raw data: {', '.join(sorted(ch_diff))}" ) raw.set_channel_types( channel_type_bids_mne_map_available_channels, on_unit_change="ignore" @@ -744,7 +742,7 @@ def _handle_channels_reading(channels_fname, raw): warn( f'Cannot set "bad" status for the following channels, as ' f"they are missing in the raw data: " - f'{", ".join(sorted(ch_diff))}' + f"{', '.join(sorted(ch_diff))}" ) raw.info["bads"] = bads_avail @@ -875,7 +873,7 @@ def read_raw_bids( and raw_path.is_symlink() ): target_path = raw_path.resolve() - logger.info(f"Resolving symbolic link: " f"{raw_path} -> {target_path}") + logger.info(f"Resolving symbolic link: {raw_path} -> {target_path}") raw_path = target_path config_path = None @@ -1124,7 +1122,7 @@ def get_head_mri_trans( if t1w_json_path is None or not t1w_json_path.exists(): raise FileNotFoundError( - f"Did not find T1w JSON sidecar file, tried location: " f"{t1w_json_path}" + f"Did not find T1w JSON sidecar file, tried location: {t1w_json_path}" ) for extension in (".nii", ".nii.gz"): t1w_path_candidate = t1w_json_path.with_suffix(extension) @@ -1135,7 +1133,7 @@ def get_head_mri_trans( if not t1w_bids_path.fpath.exists(): raise FileNotFoundError( f"Did not find T1w recording file, tried location: " - f'{t1w_path_candidate.name.replace(".nii.gz", "")}[.nii, .nii.gz]' + f"{t1w_path_candidate.name.replace('.nii.gz', '')}[.nii, .nii.gz]" ) # Get MRI landmarks from the JSON sidecar diff --git a/mne_bids/report/_report.py b/mne_bids/report/_report.py index 6f91326a1..24def9dcc 100644 --- a/mne_bids/report/_report.py +++ b/mne_bids/report/_report.py @@ -260,7 +260,7 @@ def _summarize_scans(root, session=None): if session is None: search_str = "*_scans.tsv" else: - search_str = f"*ses-{session}" f"*_scans.tsv" + search_str = f"*ses-{session}*_scans.tsv" scans_fpaths = list(root.rglob(search_str)) if len(scans_fpaths) == 0: warn( diff --git a/mne_bids/sidecar_updates.py b/mne_bids/sidecar_updates.py index 54840e16e..c8c622e8a 100644 --- a/mne_bids/sidecar_updates.py +++ b/mne_bids/sidecar_updates.py @@ -97,7 +97,7 @@ def update_sidecar_json(bids_path, entries, verbose=None): # get the file path fpath = bids_path.fpath if not fpath.exists(): - raise RuntimeError(f"Sidecar file does not " f"exist for {fpath}.") + raise RuntimeError(f"Sidecar file does not exist for {fpath}.") # sidecar update either from file, or as dictionary if isinstance(entries, dict): @@ -255,7 +255,7 @@ def update_anat_landmarks( raise ValueError( f"Could not find an MRI scan. Please check the provided " f"bids_path. Tried the following filenames: " - f'{", ".join([p.name for p in tried_paths])}' + f"{', '.join([p.name for p in tried_paths])}" ) if not isinstance(landmarks, DigMontage): # it's pathlike @@ -303,7 +303,7 @@ def update_anat_landmarks( f"The provided DigMontage did not contain all required cardinal " f"points (nasion and left and right pre-auricular points). The " f"following points are missing: " - f'{", ".join(missing_points)}' + f"{', '.join(missing_points)}" ) bids_path_json = bids_path.copy().update(extension=".json") diff --git a/mne_bids/tests/test_path.py b/mne_bids/tests/test_path.py index e617bf5fb..c2913d56e 100644 --- a/mne_bids/tests/test_path.py +++ b/mne_bids/tests/test_path.py @@ -177,12 +177,9 @@ def test_search_folder_for_text(capsys): captured = capsys.readouterr() assert "sub-01_ses-eeg_task-rest_eeg.json" in captured.out assert ( - ( - " 1 name type units low_cutof high_cuto descripti sampling_ status status_de\n" # noqa: E501 - " 2 Fp1 EEG µV 0.0159154 1000.0 ElectroEn 5000.0 good n/a" # noqa: E501 - ) - in captured.out - ) + " 1 name type units low_cutof high_cuto descripti sampling_ status status_de\n" # noqa: E501 + " 2 Fp1 EEG µV 0.0159154 1000.0 ElectroEn 5000.0 good n/a" # noqa: E501 + ) in captured.out # test if pathlib.Path object search_folder_for_text("n/a", Path(test_dir)) @@ -190,12 +187,9 @@ def test_search_folder_for_text(capsys): out = search_folder_for_text("n/a", test_dir, line_numbers=False, return_str=True) assert "sub-01_ses-eeg_task-rest_eeg.json" in out assert ( - ( - " name type units low_cutof high_cuto descripti sampling_ status status_de\n" # noqa: E501 - " Fp1 EEG µV 0.0159154 1000.0 ElectroEn 5000.0 good n/a" # noqa: E501 - ) - in out - ) + " name type units low_cutof high_cuto descripti sampling_ status status_de\n" # noqa: E501 + " Fp1 EEG µV 0.0159154 1000.0 ElectroEn 5000.0 good n/a" # noqa: E501 + ) in out def test_print_dir_tree(capsys): @@ -420,10 +414,7 @@ def test_get_entities_from_fname(fname): "fname", [ "sub-01_ses-02_task-test_run-3_split-01_meg.fif", - ( - "/bids_root/sub-01/ses-02/meg/" - "sub-01_ses-02_task-test_run-3_split-01_meg.fif" - ), + ("/bids_root/sub-01/ses-02/meg/sub-01_ses-02_task-test_run-3_split-01_meg.fif"), "sub-01_ses-02_task-test_run-3_split-01_foo-tfr_meg.fif", ], ) diff --git a/mne_bids/tests/test_utils.py b/mne_bids/tests/test_utils.py index d23b53684..8bf433be6 100644 --- a/mne_bids/tests/test_utils.py +++ b/mne_bids/tests/test_utils.py @@ -183,7 +183,7 @@ def test_check_datatype(): # check behavior for unsupported data types for datatype in (None, "anat"): with pytest.raises( - ValueError, match=f"The specified datatype " f"{datatype} is currently not" + ValueError, match=f"The specified datatype {datatype} is currently not" ): _check_datatype(raw_eeg, datatype) # check behavior for matching data type @@ -199,6 +199,6 @@ def test_check_datatype(): (raw_eeg, "ieeg"), ]: with pytest.raises( - ValueError, match=f"The specified datatype " f"{datatype} was not found" + ValueError, match=f"The specified datatype {datatype} was not found" ): _check_datatype(raw, datatype) diff --git a/mne_bids/tests/test_write.py b/mne_bids/tests/test_write.py index f57abb6df..1440e3043 100644 --- a/mne_bids/tests/test_write.py +++ b/mne_bids/tests/test_write.py @@ -87,10 +87,8 @@ maxshield="ignore:.*Internal Active Shielding:RuntimeWarning:mne", edfblocks="ignore:.*EDF format requires equal-length data " "blocks:RuntimeWarning:mne", - brainvision_unit="ignore:Encountered unsupported " - "non-voltage units*.:UserWarning", - cnt_warning1="ignore:.*Could not parse meas date from the header. " - "Setting to None.", + brainvision_unit="ignore:Encountered unsupported non-voltage units*.:UserWarning", + cnt_warning1="ignore:.*Could not parse meas date from the header. Setting to None.", cnt_warning2="ignore:.*Could not define the number of bytes automatically." " Defaulting to 2.", cnt_warning3="ignore:.*Coordinate frame could not be inferred.*", @@ -3561,9 +3559,7 @@ def test_convert_raw_errors(dir_name, fname, reader, tmp_path): # the datatype inside the file (e.g. EEG -> 'FIF' or MEG -> 'BrainVision') with pytest.raises( ValueError, - match='The input "format" .* is not an ' - "accepted input format for " - ".* datatype.", + match='The input "format" .* is not an accepted input format for .* datatype.', ): if dir_name == "CTF": new_format = "BrainVision" diff --git a/mne_bids/utils.py b/mne_bids/utils.py index da0f7066e..8a3f7d405 100644 --- a/mne_bids/utils.py +++ b/mne_bids/utils.py @@ -270,7 +270,7 @@ def _check_key_val(key, val): """Perform checks on a value to make sure it adheres to the spec.""" if any(ii in val for ii in ["-", "_", "/"]): raise ValueError( - "Unallowed `-`, `_`, or `/` found in key/value pair" f" {key}: {val}" + f"Unallowed `-`, `_`, or `/` found in key/value pair {key}: {val}" ) return key, val @@ -520,7 +520,7 @@ def _import_nibabel(why="work with MRI data"): import nibabel except ImportError as exc: raise exc.__class__( - f"nibabel is required to {why} but could not be imported, " f"got: {exc}" + f"nibabel is required to {why} but could not be imported, got: {exc}" ) from None else: return nibabel diff --git a/mne_bids/write.py b/mne_bids/write.py index 80c25ceea..fce8cd75f 100644 --- a/mne_bids/write.py +++ b/mne_bids/write.py @@ -367,8 +367,7 @@ def _events_json(fname, extra_columns=None, has_trial_type=True, overwrite=False }, "sample": { "Description": ( - "The event onset time in number of sampling points." - "First sample is 0." + "The event onset time in number of sampling points.First sample is 0." ), }, "value": { @@ -1175,8 +1174,7 @@ def _write_raw_brainvision(raw, bids_fname, events, overwrite): # ensuring that int16 can represent the data in original units. if raw.orig_format != "single": warn( - f'Encountered data in "{raw.orig_format}" format. ' - "Converting to float32.", + f'Encountered data in "{raw.orig_format}" format. Converting to float32.', RuntimeWarning, ) @@ -1732,13 +1730,12 @@ def write_raw_bids( if events is not None and event_id is None and event_metadata is None: raise ValueError( - "You passed events, but no event_id dictionary " "or event_metadata." + "You passed events, but no event_id dictionary or event_metadata." ) if event_metadata is not None and extra_columns_descriptions is None: raise ValueError( - "You passed event_metadata, but no " - "extra_columns_descriptions dictionary." + "You passed event_metadata, but no extra_columns_descriptions dictionary." ) if event_metadata is not None: @@ -1918,7 +1915,7 @@ def write_raw_bids( if associated_er_path is not None: if not associated_er_path.exists(): raise FileNotFoundError( - f"Empty-room data file not found: " f"{associated_er_path}" + f"Empty-room data file not found: {associated_er_path}" ) # Turn it into a path relative to the BIDS root @@ -2262,7 +2259,7 @@ def write_raw_bids( keep_source=keep_source, overwrite=overwrite, ) - logger.info(f"Wrote {scans_path.fpath} entry with " f"{scan_relative_fpath}.") + logger.info(f"Wrote {scans_path.fpath} entry with {scan_relative_fpath}.") return bids_path @@ -3016,7 +3013,7 @@ def anonymize_dataset( if "emptyroom" in subject_mapping and subject_mapping["emptyroom"] != "emptyroom": warn( f'You requested to change the "emptyroom" subject ID ' - f'(to {subject_mapping["emptyroom"]}). It is not ' + f"(to {subject_mapping['emptyroom']}). It is not " f"recommended to do this!" ) @@ -3100,7 +3097,7 @@ def anonymize_dataset( if subjects_missing_mapping_keys: raise IndexError( f"The subject_mapping dictionary does not contain an entry for " - f'subject ID: {", ".join(subjects_missing_mapping_keys)}' + f"subject ID: {', '.join(subjects_missing_mapping_keys)}" ) _, unique_vals_idx, counts = np.unique( @@ -3111,11 +3108,11 @@ def anonymize_dataset( keys = np.array(list(subject_mapping.values()))[non_unique_vals_idx] raise ValueError( f"The subject_mapping dictionary contains duplicated anonymized " - f'subjet IDs: {", ".join(keys)}' + f"subjet IDs: {', '.join(keys)}" ) # Produce some logging output - msg = f"\n" f" Input: {bids_root_in}\n" f" Output: {bids_root_out}\n" f"\n" + msg = f"\n Input: {bids_root_in}\n Output: {bids_root_out}\n\n" if daysback is None: msg += "Not shifting recording dates (found anatomical scans only).\n" else: