diff --git a/examples/general/plot_22_quality.py b/examples/general/plot_22_quality.py index 0b98eaf82..2a5b8cf41 100644 --- a/examples/general/plot_22_quality.py +++ b/examples/general/plot_22_quality.py @@ -170,7 +170,7 @@ scores, times, threshold=0.7, - title="Scalp Coupling Index " "Quality Evaluation", + title="Scalp Coupling Index Quality Evaluation", ) # %% diff --git a/mne_nirs/channels/_channels.py b/mne_nirs/channels/_channels.py index c7cf5ca40..5c71f20ad 100644 --- a/mne_nirs/channels/_channels.py +++ b/mne_nirs/channels/_channels.py @@ -95,7 +95,7 @@ def drop_sources(raw, sources): all_str = all([isinstance(src, int) for src in sources]) except TypeError: raise ValueError( - "'ch_names' must be iterable, got " f"type {type(sources)} ({sources})." + f"'ch_names' must be iterable, got type {type(sources)} ({sources})." ) if not all_str: @@ -139,7 +139,7 @@ def drop_detectors(raw, detectors): all_str = all([isinstance(det, int) for det in detectors]) except TypeError: raise ValueError( - "'ch_names' must be iterable, got " f"type {type(detectors)} ({detectors})." + f"'ch_names' must be iterable, got type {type(detectors)} ({detectors})." ) if not all_str: @@ -183,7 +183,7 @@ def pick_sources(raw, sources): all_str = all([isinstance(src, int) for src in sources]) except TypeError: raise ValueError( - "'ch_names' must be iterable, got " f"type {type(sources)} ({sources})." + f"'ch_names' must be iterable, got type {type(sources)} ({sources})." ) if not all_str: @@ -227,7 +227,7 @@ def pick_detectors(raw, detectors): all_str = all([isinstance(det, int) for det in detectors]) except TypeError: raise ValueError( - "'ch_names' must be iterable, got " f"type {type(detectors)} ({detectors})." + f"'ch_names' must be iterable, got type {type(detectors)} ({detectors})." ) if not all_str: diff --git a/mne_nirs/channels/_roi.py b/mne_nirs/channels/_roi.py index 8c9b16f60..20b72fc31 100644 --- a/mne_nirs/channels/_roi.py +++ b/mne_nirs/channels/_roi.py @@ -45,7 +45,7 @@ def picks_pair_to_idx(raw, sd_pairs, on_missing="error"): pair_name = "S" + str(pair[0]) + "_D" + str(pair[1]) + " " pair_picks = np.where([pair_name in ch for ch in ch_names])[0] if len(pair_picks) == 0: - msg = "No matching channels found for source %s " "detector %s" % ( + msg = "No matching channels found for source %s detector %s" % ( pair[0], pair[1], ) diff --git a/mne_nirs/datasets/audio_or_visual_speech/_audio_or_visual_speech.py b/mne_nirs/datasets/audio_or_visual_speech/_audio_or_visual_speech.py index d801376c9..04c05d2b8 100644 --- a/mne_nirs/datasets/audio_or_visual_speech/_audio_or_visual_speech.py +++ b/mne_nirs/datasets/audio_or_visual_speech/_audio_or_visual_speech.py @@ -56,8 +56,7 @@ def data_path( .. footbibliography:: """ dataset_params = dict( - archive_name="2021-fNIRS-Audio-visual-speech-" - "Broad-vs-restricted-regions.zip", + archive_name="2021-fNIRS-Audio-visual-speech-Broad-vs-restricted-regions.zip", hash="md5:16cac6565880dae6aed9b69100399d0b", url="https://osf.io/xwerv/download?version=1", folder_name="fNIRS-audio-visual-speech", @@ -77,7 +76,7 @@ def data_path( # Do some wrangling to deal with nested directories bad_name = os.path.join( - dpath, "2021-fNIRS-Audio-visual-speech-" "Broad-vs-restricted-regions" + dpath, "2021-fNIRS-Audio-visual-speech-Broad-vs-restricted-regions" ) if os.path.isdir(bad_name): os.rename(bad_name, dpath + ".true") diff --git a/mne_nirs/datasets/block_speech_noise/_block_speech_noise.py b/mne_nirs/datasets/block_speech_noise/_block_speech_noise.py index e711eaf34..5bc0d70ff 100644 --- a/mne_nirs/datasets/block_speech_noise/_block_speech_noise.py +++ b/mne_nirs/datasets/block_speech_noise/_block_speech_noise.py @@ -75,7 +75,7 @@ def data_path( dpath = str(dpath) # Do some wrangling to deal with nested directories - bad_name = os.path.join(dpath, "2021-fNIRS-Analysis-Methods-" "Passive-Auditory") + bad_name = os.path.join(dpath, "2021-fNIRS-Analysis-Methods-Passive-Auditory") if os.path.isdir(bad_name): os.rename(bad_name, dpath + ".true") shutil.rmtree(dpath) diff --git a/mne_nirs/io/snirf/_snirf.py b/mne_nirs/io/snirf/_snirf.py index 66e60074d..28c0f6499 100644 --- a/mne_nirs/io/snirf/_snirf.py +++ b/mne_nirs/io/snirf/_snirf.py @@ -46,17 +46,17 @@ def write_raw_snirf(raw, fname, add_montage=False): """ supported_types = ["fnirs_cw_amplitude", "fnirs_od", "hbo", "hbr"] picks = _picks_to_idx(raw.info, supported_types, exclude=[]) - assert len(picks) == len( - raw.ch_names - ), "Data must only be of type fnirs_cw_amplitude, fnirs_od, hbo or hbr" + assert len(picks) == len(raw.ch_names), ( + "Data must only be of type fnirs_cw_amplitude, fnirs_od, hbo or hbr" + ) if ("fnirs_cw_amplitude" in raw) or ("fnirs_od" in raw): - assert ( - len(np.unique(raw.info.get_channel_types())) == 1 - ), "All channels must be of the same type" + assert len(np.unique(raw.info.get_channel_types())) == 1, ( + "All channels must be of the same type" + ) elif ("hbo" in raw) or ("hbr" in raw): - assert ( - len(np.unique(raw.info.get_channel_types())) <= 2 - ), "Channels must be of type hbo and hbr" + assert len(np.unique(raw.info.get_channel_types())) <= 2, ( + "Channels must be of type hbo and hbr" + ) with h5py.File(fname, "w") as f: nirs = f.create_group("/nirs") diff --git a/mne_nirs/preprocessing/_mayer.py b/mne_nirs/preprocessing/_mayer.py index 7ca3c0ad4..10d191260 100644 --- a/mne_nirs/preprocessing/_mayer.py +++ b/mne_nirs/preprocessing/_mayer.py @@ -88,7 +88,7 @@ def quantify_mayer_fooof( # or raw data, I just haven't tried this. Let me know if this works # for you and we can ease this restriction. raise RuntimeError( - "Mayer wave estimation should be run on " "haemoglobin concentration data." + "Mayer wave estimation should be run on haemoglobin concentration data." ) df = pd.DataFrame() diff --git a/mne_nirs/signal_enhancement/_negative_correlation.py b/mne_nirs/signal_enhancement/_negative_correlation.py index 0a0143f7c..1184a8b01 100644 --- a/mne_nirs/signal_enhancement/_negative_correlation.py +++ b/mne_nirs/signal_enhancement/_negative_correlation.py @@ -43,7 +43,7 @@ def enhance_negative_correlation(raw): if (not len(hbo_channels)) & (not len(hbr_channels)): raise RuntimeError( - "enhance_negative_correlation should " "be run on haemoglobin data." + "enhance_negative_correlation should be run on haemoglobin data." ) if len(hbo_channels) != len(hbr_channels): diff --git a/mne_nirs/simulation/_simulation.py b/mne_nirs/simulation/_simulation.py index a2bc65d6f..e4f79f72b 100644 --- a/mne_nirs/simulation/_simulation.py +++ b/mne_nirs/simulation/_simulation.py @@ -70,10 +70,10 @@ def simulate_nirs_raw( frame_times = np.arange(sig_dur * sfreq) / sfreq assert len(amplitude) == len(annot_desc), ( - "Same number of amplitudes as " "annotations required." + "Same number of amplitudes as annotations required." ) assert len(amplitude) == len(stim_dur), ( - "Same number of amplitudes as " "durations required." + "Same number of amplitudes as durations required." ) onset = 0.0 diff --git a/mne_nirs/statistics/_glm_level_first.py b/mne_nirs/statistics/_glm_level_first.py index 151d7f52f..b666489c0 100644 --- a/mne_nirs/statistics/_glm_level_first.py +++ b/mne_nirs/statistics/_glm_level_first.py @@ -116,7 +116,7 @@ def save(self, fname, overwrite=False): fname = str(fname) if not fname.endswith("glm.h5"): raise OSError( - "The filename must end with glm.h5, " f"instead received {fname}" + f"The filename must end with glm.h5, instead received {fname}" ) write_hdf5(fname, self._get_state(), overwrite=overwrite, title="mnepython") @@ -240,7 +240,7 @@ def data(self, data): raise TypeError("Data names and channel names do not match") for d in data: if type(data[d]) is not nilearn.glm.regression.RegressionResults: - raise TypeError("Dictionary items must be" " nilearn RegressionResults") + raise TypeError("Dictionary items must be nilearn RegressionResults") self._data = data @@ -430,11 +430,11 @@ def to_dataframe_region_of_interest( if isinstance(weighted, dict): if weighted.keys() != group_by.keys(): - raise KeyError("Keys of group_by and weighted " "must be the same") + raise KeyError("Keys of group_by and weighted must be the same") for key in weighted.keys(): if len(weighted[key]) != len(group_by[key]): raise ValueError( - "The length of the keys for group_by " "and weighted must match" + "The length of the keys for group_by and weighted must match" ) if (np.array(weighted[key]) < 0).any(): raise ValueError("Weights must be positive values") @@ -567,8 +567,8 @@ def surface_projection( df_use = df.query("Condition in @condition") if len(df_use) == 0: raise KeyError( - f'condition={repr(condition)} not found in conditions: ' - f'{sorted(set(df["Condition"]))}' + f"condition={repr(condition)} not found in conditions: " + f"{sorted(set(df['Condition']))}" ) df = df_use df = df.query("Chroma in @chroma").copy() @@ -639,7 +639,7 @@ def data(self, data): raise TypeError("Data must be a nilearn glm contrast type") if data.effect.size != len(self.info.ch_names): raise TypeError( - "Data results must be the same length " "as the number of channels" + "Data results must be the same length as the number of channels" ) self._data = data @@ -853,9 +853,7 @@ def _state_to_glm(glm): glm["data"][channel]["model"]["design"], ) else: - raise OSError( - "Unknown model type " f"{glm['data'][channel]['modelname']}" - ) + raise OSError(f"Unknown model type {glm['data'][channel]['modelname']}") for key in glm["data"][channel]["model"]: model.__setattr__(key, glm["data"][channel]["model"][key]) diff --git a/mne_nirs/tests/test_examples.py b/mne_nirs/tests/test_examples.py index 5f1e20a05..4abf268ba 100644 --- a/mne_nirs/tests/test_examples.py +++ b/mne_nirs/tests/test_examples.py @@ -14,7 +14,7 @@ def examples_path(): if not os.path.isdir("BIDS-NIRS-Tapping"): os.system( - "git clone --depth 1 " "https://github.com/rob-luke/BIDS-NIRS-Tapping.git" + "git clone --depth 1 https://github.com/rob-luke/BIDS-NIRS-Tapping.git" ) if os.path.isdir("examples"): diff --git a/mne_nirs/visualisation/_plot_3d_montage.py b/mne_nirs/visualisation/_plot_3d_montage.py index 4a8ab9870..34a1282c8 100644 --- a/mne_nirs/visualisation/_plot_3d_montage.py +++ b/mne_nirs/visualisation/_plot_3d_montage.py @@ -138,14 +138,11 @@ def plot_3d_montage( if bad: src_det_names = None logger.info( - "Could not automatically map source/detector names to " - "10-20 locations." + "Could not automatically map source/detector names to 10-20 locations." ) else: src_det_names = locs - logger.info( - "Source-detector names automatically mapped to 10-20 " "locations" - ) + logger.info("Source-detector names automatically mapped to 10-20 locations") head_mri_t = _get_trans(trans, "head", "mri")[0] del trans diff --git a/mne_nirs/visualisation/_plot_GLM_surface_projection.py b/mne_nirs/visualisation/_plot_GLM_surface_projection.py index 86cbb856c..fe8aa3f7b 100644 --- a/mne_nirs/visualisation/_plot_GLM_surface_projection.py +++ b/mne_nirs/visualisation/_plot_GLM_surface_projection.py @@ -101,9 +101,9 @@ def plot_glm_surface_projection( info = deepcopy(inst if isinstance(inst, Info) else inst.info) if not (info.ch_names == list(statsmodel_df["ch_name"].values)): raise RuntimeError( - 'MNE data structure does not match dataframe ' - f'results.\nMNE = {info.ch_names}.\n' - f'GLM = {list(statsmodel_df["ch_name"].values)}' + "MNE data structure does not match dataframe " + f"results.\nMNE = {info.ch_names}.\n" + f"GLM = {list(statsmodel_df['ch_name'].values)}" ) ea = EvokedArray(np.tile(statsmodel_df[value].values.T, (1, 1)).T, info.copy()) diff --git a/mne_nirs/visualisation/_plot_GLM_topo.py b/mne_nirs/visualisation/_plot_GLM_topo.py index a6709220c..066290c05 100644 --- a/mne_nirs/visualisation/_plot_GLM_topo.py +++ b/mne_nirs/visualisation/_plot_GLM_topo.py @@ -275,9 +275,9 @@ def plot_glm_group_topo( assert len(np.unique(statsmodel_df["Chroma"])) == 1, "Only one Chroma allowed" if "Condition" in statsmodel_df.columns: - assert ( - len(np.unique(statsmodel_df["Condition"])) == 1 - ), "Only one condition allowed" + assert len(np.unique(statsmodel_df["Condition"])) == 1, ( + "Only one condition allowed" + ) c = np.unique(statsmodel_df["Condition"])[0] else: c = "Contrast"