From 9489b088f35272a4c52acfcd76b1c3c6a3773413 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 12 Sep 2024 16:30:25 -0400 Subject: [PATCH 1/4] MAINT: Overwrite when possible --- mnefun/_ssp.py | 21 ++++++++------------- mnefun/_utils.py | 6 ++++++ 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/mnefun/_ssp.py b/mnefun/_ssp.py index 0ec4cca..16f465b 100644 --- a/mnefun/_ssp.py +++ b/mnefun/_ssp.py @@ -21,7 +21,8 @@ from ._epoching import _raise_bad_epochs from ._paths import get_raw_fnames, get_bad_fname from ._utils import (get_args, _fix_raw_eog_cals, _handle_dict, _safe_remove, - _get_baseline, _restrict_reject_flat, _get_epo_kwargs) + _get_baseline, _restrict_reject_flat, _get_epo_kwargs, + _overwrite) def _get_fir_kwargs(fir_design): @@ -167,7 +168,7 @@ def _compute_erm_proj(p, subj, projs, kind, bad_file, remove_existing=False, # When doing eSSS it's a bit weird to put this in pca_dir but why not pca_dir = _get_pca_dir(p, subj) cont_proj = op.join(pca_dir, 'preproc_cont-proj.fif') - write_proj(cont_proj, pr) + _overwrite(write_proj, cont_proj, pr) return pr @@ -388,10 +389,7 @@ def do_preprocessing_combined(p, subjects, run_indices): print(' obtained %d epochs from %d events.' % (len(ecg_epochs), len(ecg_events))) if len(ecg_epochs) >= 20: - kwargs = dict() - if "overwrite" in get_args(write_events): - kwargs["overwrite"] = True - write_events(ecg_eve, ecg_epochs.events, **kwargs) + _overwrite(write_events, ecg_eve, ecg_epochs.events) ecg_epochs.save(ecg_epo, **_get_epo_kwargs()) desc_prefix = 'ECG-%s-%s' % tuple(ecg_t_lims) pr = compute_proj_wrap( @@ -399,10 +397,7 @@ def do_preprocessing_combined(p, subjects, run_indices): n_mag=proj_nums[0][1], n_eeg=proj_nums[0][2], desc_prefix=desc_prefix, **proj_kwargs) assert len(pr) == np.sum(proj_nums[0][::p_sl]) - kwargs = dict() - if "overwrite" in get_args(write_events): - kwargs["overwrite"] = True - write_proj(ecg_proj, pr, **kwargs) + _overwrite(write_proj, ecg_proj, pr) projs.extend(pr) else: _raise_bad_epochs(raw, ecg_epochs, ecg_events, 'ECG', @@ -421,7 +416,7 @@ def do_preprocessing_combined(p, subjects, run_indices): del proj_nums # save the projectors - write_proj(all_proj, projs) + _overwrite(write_proj, all_proj, projs) # # Look at raw_orig for trial DQs now, it will be quick @@ -500,7 +495,7 @@ def _compute_add_eog(p, subj, raw_orig, projs, eog_nums, kind, pca_dir, len(eog_events))) del eog_events if len(eog_epochs) >= 5: - write_events(eog_eve, eog_epochs.events) + _overwrite(write_events, eog_eve, eog_epochs.events) eog_epochs.save(eog_epo, **_get_epo_kwargs()) desc_prefix = f'{kind}-%s-%s' % tuple(eog_t_lims) pr = compute_proj_wrap( @@ -508,7 +503,7 @@ def _compute_add_eog(p, subj, raw_orig, projs, eog_nums, kind, pca_dir, n_mag=eog_nums[1], n_eeg=eog_nums[2], desc_prefix=desc_prefix, **proj_kwargs) assert len(pr) == np.sum(eog_nums[::p_sl]) - write_proj(eog_proj, pr) + _overwrite(write_proj, eog_proj, pr) projs.extend(pr) else: warnings.warn('Only %d usable EOG events!' % len(eog_epochs)) diff --git a/mnefun/_utils.py b/mnefun/_utils.py index 8222f6e..053709a 100644 --- a/mnefun/_utils.py +++ b/mnefun/_utils.py @@ -463,3 +463,9 @@ def convert_ANTS_surrogate(subject, trans, subjects_dir): def get_args(obj): """Wrapper.""" return inspect.signature(obj).parameters + + +def _overwrite(func, *args, **kwargs): + if "overwrite" in get_args(func): + kwargs["overwrite"] = True + return func(*args, **kwargs) From 414e98550660879b5d971d5f92ef5fbeef26d50e Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 20 Sep 2024 10:43:40 -0400 Subject: [PATCH 2/4] MAINT: Fixes --- examples/funloc/analysis_fun.py | 8 ++-- examples/funloc/score.py | 2 +- mnefun/_cov.py | 6 +-- mnefun/_fix.py | 8 ++++ mnefun/_inverse.py | 3 +- mnefun/_report.py | 70 ++++++++++++++------------------- mnefun/_viz.py | 7 +--- 7 files changed, 50 insertions(+), 54 deletions(-) diff --git a/examples/funloc/analysis_fun.py b/examples/funloc/analysis_fun.py index 8168d00..98e5a88 100644 --- a/examples/funloc/analysis_fun.py +++ b/examples/funloc/analysis_fun.py @@ -37,10 +37,10 @@ params.subject_indices = [0, 1] # Set what processing steps will execute -default = False +default = False # except for first and last steps which have other defaults mnefun.do_processing( params, - fetch_raw=default, # Fetch raw recording files from acquisition machine + fetch_raw=False, # Fetch raw recording files from acquisition machine do_score=default, # Do scoring to slice data into trials # Before running SSS, make SUBJ/raw_fif/SUBJ_prebad.txt file with @@ -56,9 +56,9 @@ write_epochs=default, # Write epochs to disk gen_covs=default, # Generate covariances - # Make SUBJ/trans/SUBJ-trans.fif using mne_analyze; needed for fwd calc. + # Make SUBJ/trans/SUBJ-trans.fif using mne coreg; needed for fwd calc. gen_fwd=default, # Generate forward solutions (and source space) gen_inv=default, # Generate inverses gen_report=default, # Write mne report html of results to disk - print_status=default, # Print completeness status update + print_status=True, # Print completeness status update ) diff --git a/examples/funloc/score.py b/examples/funloc/score.py index 842e218..a237adb 100644 --- a/examples/funloc/score.py +++ b/examples/funloc/score.py @@ -50,7 +50,7 @@ def score(p, subjects): events[ii, 2] = _expyfun_dict[events[ii, 2]] fname_out = op.join(out_dir, 'ALL_' + (run_name % subj) + '-eve.lst') - mne.write_events(fname_out, events) + mne.write_events(fname_out, events, overwrite=True) # get subject performance devs = (events[:, 2] >= 20) diff --git a/mnefun/_cov.py b/mnefun/_cov.py index 1ac86aa..55535ac 100644 --- a/mnefun/_cov.py +++ b/mnefun/_cov.py @@ -16,7 +16,7 @@ from ._epoching import _concat_resamp_raws from ._paths import get_epochs_evokeds_fnames, get_raw_fnames, safe_inserter from ._scoring import _read_events -from ._utils import (get_args, _get_baseline, _restrict_reject_flat, +from ._utils import (get_args, _get_baseline, _restrict_reject_flat, _overwrite, _handle_dict, _handle_decim, _check_reject_annot_regex) @@ -119,7 +119,7 @@ def gen_covariances(p, subjects, run_indices, decim): del use_flat['eeg'] cov = compute_raw_covariance(raw, reject=use_reject, flat=use_flat, method=p.cov_method, **kwargs_erm) - write_cov(empty_cov_name, cov) + _overwrite(write_cov, empty_cov_name, cov) # Make evoked covariances for ii, (inv_name, inv_run) in enumerate(zip(p.inv_names, p.inv_runs)): @@ -187,5 +187,5 @@ def gen_covariances(p, subjects, run_indices, decim): epochs2.copy().crop(*baseline).plot() raise RuntimeError('Error computing rank') - write_cov(cov_name, cov) + _overwrite(write_cov, cov_name, cov) print() diff --git a/mnefun/_fix.py b/mnefun/_fix.py index 103d2c4..916d87c 100644 --- a/mnefun/_fix.py +++ b/mnefun/_fix.py @@ -3,6 +3,7 @@ # Distributed under the (new) BSD License. See LICENSE.txt for more info. from os import path as op +import datetime import glob import numpy as np import re @@ -114,6 +115,13 @@ def fix_eeg_channels(raw_files, anon=None, verbose=True): if need_reorder: raw._data[picks, :] = raw._data[picks, :][order] if need_anon and raw.info['subject_info'] is not None: + anon = anon.copy() + if ( + isinstance(raw.info["subject_info"].get("birthday"), datetime.date) + and isinstance(anon.get("birthday"), tuple) + ): + anon["birthday"] = datetime.date(*anon["birthday"]) + anon['birthday'] = raw.info["subject_info"]["birthday"] raw.info['subject_info'].update(anon) raw.info['description'] = write_key + anon_key if isinstance(raw_file, str): diff --git a/mnefun/_inverse.py b/mnefun/_inverse.py index 7fa8c61..b27b272 100644 --- a/mnefun/_inverse.py +++ b/mnefun/_inverse.py @@ -16,6 +16,7 @@ from ._cov import _compute_rank from ._paths import (get_epochs_evokeds_fnames, safe_inserter, get_cov_fwd_inv_fnames) +from ._utils import _overwrite try: from mne import spatial_src_adjacency @@ -121,7 +122,7 @@ def gen_inverses(p, subjects, run_indices): inv = make_inverse_operator( epochs.info, fwd_restricted, cov, rank=rank, **kwargs) - write_inverse_operator(inv_name, inv) + _overwrite(write_inverse_operator, inv_name, inv) if p.disp_files: print() diff --git a/mnefun/_report.py b/mnefun/_report.py index ebb97b0..67d499d 100644 --- a/mnefun/_report.py +++ b/mnefun/_report.py @@ -53,6 +53,7 @@ def report_context(): with plt.style.context(style): yield except Exception: + plt.close("all") matplotlib.use(old_backend, force=True) plt.interactive(is_interactive) raise @@ -129,7 +130,6 @@ def _report_good_hpi(report, fnames, p=None, subj=None, img_form='webp'): break fig = plot_good_coils(fit_data, show=False) fig.set_size_inches(10, 2) - fig.tight_layout() figs.append(fig) captions.append('%s: %s' % (section, op.basename(fname))) _add_figs_to_section( @@ -151,8 +151,6 @@ def _report_chpi_snr(report, fnames, p=None, subj=None, img_form='webp'): fig = plot_chpi_snr_raw(raw, t_window, show=False, verbose=False) fig.set_size_inches(10, 5) - fig.subplots_adjust(0.1, 0.1, 0.8, 0.95, - wspace=0, hspace=0.5) figs.append(fig) captions.append('%s: %s' % (section, op.basename(fname))) _add_figs_to_section( @@ -162,6 +160,7 @@ def _report_chpi_snr(report, fnames, p=None, subj=None, img_form='webp'): def _report_head_movement(report, fnames, p=None, subj=None, run_indices=None, img_form='webp'): + import matplotlib.pyplot as plt section = 'Head movement' print((' %s ... ' % section).ljust(LJUST), end='') t0 = time.time() @@ -171,8 +170,9 @@ def _report_head_movement(report, fnames, p=None, subj=None, run_indices=None, fname, raw = _check_fname_raw(fname, p, subj) _, pos, _ = _get_fit_data(raw, p, prefix=' ') trans_to = _load_trans_to(p, subj, run_indices, raw) + axes = plt.subplots(3, 2, sharex=True, layout="constrained")[1] fig = plot_head_positions(pos=pos, destination=trans_to, - info=raw.info, show=False) + info=raw.info, show=False, axes=axes) for ax in fig.axes[::2]: """ # tighten to the sensor limits @@ -198,7 +198,6 @@ def _report_head_movement(report, fnames, p=None, subj=None, run_indices=None, assert (mx >= coord).all() ax.set_ylim(mn, mx) fig.set_size_inches(10, 6) - fig.tight_layout() figs.append(fig) captions.append('%s: %s' % (section, op.basename(fname))) del trans_to @@ -220,7 +219,6 @@ def _report_events(report, fnames, p=None, subj=None, img_form='webp'): if len(events) > 0: fig = plot_events(events, raw.info['sfreq'], raw.first_samp) fig.set_size_inches(10, 4) - fig.subplots_adjust(0.1, 0.1, 0.9, 0.99, wspace=0, hspace=0) figs.append(fig) captions.append('%s: %s' % (section, op.basename(fname))) if len(figs): @@ -254,7 +252,7 @@ def _report_raw_segments(report, raw, lowpass=None, img_form='webp'): np.ones_like(new_events)]).T with mne.utils.use_log_level('error'): fig = raw_plot.plot(group_by='selection', butterfly=True, - events=new_events, lowpass=lowpass) + events=new_events, lowpass=lowpass, show=False) fig.axes[0].lines[-1].set_zorder(10) # events fig.axes[0].set(xticks=np.arange(0, len(times)) + 0.5) xticklabels = ['%0.1f' % t for t in times] @@ -265,15 +263,17 @@ def _report_raw_segments(report, raw, lowpass=None, img_form='webp'): fig.delaxes(fig.axes[-1]) fig.set(figheight=(fig.axes[0].get_yticks() != 0).sum(), figwidth=12) - fig.subplots_adjust(0.025, 0.0, 1, 1, 0, 0) _add_figs_to_section(report, fig, section, section, image_format=img_form) print('%5.1f sec' % ((time.time() - t0),)) def _gen_psd_plot(raw, fmax, n_fft, ax): + n_fft = min(n_fft, len(raw.times)) if hasattr(raw, 'compute_psd'): - plot = raw.compute_psd(fmax=fmax, n_fft=n_fft).plot(show=False, - axes=ax) + with warnings.catch_warnings(record=True): + plot = raw.compute_psd(fmax=fmax, n_fft=n_fft).plot( + show=False, axes=ax, + ) else: plot = raw.plot_psd(fmax=fmax, n_fft=n_fft, show=False, ax=ax) return plot @@ -294,7 +294,7 @@ def _report_raw_psd(report, raw, raw_pca=None, raw_erm=None, raw_erm_pca=None, n_fft = min(8192, len(raw.times)) fmax = raw.info['lowpass'] n_ax = sum(key in raw for key in ('mag', 'grad', 'eeg')) - _, ax = plt.subplots(n_ax, figsize=(10, 8)) + _, ax = plt.subplots(n_ax, figsize=(10, 8), layout="constrained") figs = [_gen_psd_plot(raw, fmax=fmax, n_fft=n_fft, ax=ax)] captions = ['%s: Raw' % section] fmax = lp_cut + 2 * lp_trans @@ -303,7 +303,7 @@ def _report_raw_psd(report, raw, raw_pca=None, raw_erm=None, raw_erm_pca=None, (raw_pca, f'{section}: Raw processed (zoomed)'), (raw_erm, f'{section}: ERM (zoomed)'), (raw_erm_pca, f'{section}: ERM processed (zoomed)')]: - _, ax = plt.subplots(n_ax, figsize=(10, 8)) + _, ax = plt.subplots(n_ax, figsize=(10, 8), layout="constrained") if this_raw is not None: figs.append(_gen_psd_plot(this_raw, fmax=fmax, n_fft=n_fft, ax=ax)) captions.append(caption) @@ -398,7 +398,7 @@ def gen_html_report(p, subjects, structurals, run_indices=None): preload = p.report_params.get('preload', False) for si, subj in enumerate(subjects): struc = structurals[si] if structurals is not None else None - report = Report(verbose=False) + report = Report(title=subj, verbose=False) print(' Processing subject %s/%s (%s)' % (si + 1, len(subjects), subj)) @@ -771,7 +771,8 @@ def gen_html_report(p, subjects, structurals, run_indices=None): n_e = len(all_evoked) n_row = n_s * n_e + 1 figs, axes = plt.subplots( - n_row, 1, figsize=(7, 3 * n_row)) + n_row, 1, figsize=(7, 3 * n_row), layout="constrained", + ) captions = [ '%s: %s["%s"] (N=%s)' % (section, analysis, all_evoked[0].comment, @@ -782,7 +783,7 @@ def gen_html_report(p, subjects, structurals, run_indices=None): sl = slice(ei, n_e * n_s, n_e) these_axes = list(axes[sl]) + [axes[-1]] evo.plot_white( - noise_cov, verbose='error', axes=these_axes) + noise_cov, verbose='error', axes=these_axes, show=False) for ax in these_axes[:-1]: n_text = 'N=%d' % (evo.nave,) if ei != 0: @@ -826,7 +827,6 @@ def gen_html_report(p, subjects, structurals, run_indices=None): axes[-1].set_title( f'{axes[-1].get_title()} (halves {SQ2STR})') axes[-1] - figs.tight_layout() figs = [figs] _add_figs_to_section( report, figs, captions, section=section, @@ -864,7 +864,7 @@ def gen_html_report(p, subjects, structurals, run_indices=None): % op.basename(fname_evoked), end='') else: inv = mne.minimum_norm.read_inverse_operator(fname_inv) - figs, ax = plt.subplots(1, figsize=(7, 5)) + figs, ax = plt.subplots(1, figsize=(7, 5), layout="constrained") all_evoked = _get_std_even_odd(fname_evoked, name) for ei, evoked in enumerate(all_evoked): if ei != 0: @@ -873,7 +873,7 @@ def gen_html_report(p, subjects, structurals, run_indices=None): try: evoked.nave = max(orig, 1) plot_snr_estimate( - evoked, inv, axes=ax, verbose='error') + evoked, inv, show=False, axes=ax, verbose='error') finally: evoked.nave = orig if len(all_evoked) > 1: @@ -899,7 +899,6 @@ def gen_html_report(p, subjects, structurals, run_indices=None): % (section, analysis, name, '/'.join(str(e.nave) for e in all_evoked))) - figs.tight_layout() _add_figs_to_section( report, figs, captions, section=section, image_format=img_form) @@ -1003,9 +1002,6 @@ def gen_html_report(p, subjects, structurals, run_indices=None): times, **kwargs) assert isinstance(fig, plt.Figure) fig.axes[0].set(ylim=(-max_, max_)) - t = fig.axes[-1].texts[0] - t.set_text( - f'{t.get_text()}; {n_text})') else: fig = plt.figure() all_figs += [fig] @@ -1161,8 +1157,6 @@ def gen_html_report(p, subjects, structurals, run_indices=None): % (section, analysis, name, extra, this_evoked.nave,)) captions = ['%2.3f sec' % t for t in times] - print(f'add {repr(title)}') - print(repr(captions)) _add_slider_to_section( report, figs, captions=captions, section=section, title=title, image_format=img_form) @@ -1235,7 +1229,7 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): ch_names = [info['ch_names'][pick] for pick in mne.pick_types(info, meg=meg, eeg=eeg)] # Some of these will be missing because of prebads - idx = np.where([np.in1d(ch_names, proj['data']['col_names']).all() + idx = np.where([np.isin(ch_names, proj['data']['col_names']).all() for proj in projs])[0] if len(idx) != count: raise RuntimeError('Expected %d %s projector%s for channel type ' @@ -1253,17 +1247,17 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): for name in ch_names] proj['data']['data'] = proj['data']['data'][:, sub_idx] proj['data']['col_names'] = ch_names - topo_axes = [plt.subplot2grid(shape, (ri, ci + cs_trace)) + fig = plt.figure(layout="constrained") + topo_axes = [plt.subplot2grid(shape, (ri, ci + cs_trace), fig=fig) for ci in range(count)] # topomaps - with warnings.catch_warnings(record=True): - plot_projs_topomap(these_projs, info=info, show=False, - axes=topo_axes) + plot_projs_topomap(these_projs, info=info, show=False, + axes=topo_axes) plt.setp(topo_axes, title='', xlabel='') unit = mne.defaults.DEFAULTS['units'][ch_type] if cs_trace: ax = plt.subplot2grid(shape, (ri, n_col - cs_trace - 1), - colspan=cs_trace) + colspan=cs_trace, fig=fig) this_evoked = evoked.copy().pick_channels(ch_names) p = np.concatenate([p['data']['data'] for p in these_projs]) assert p.shape == (len(these_projs), len(this_evoked.data)) @@ -1274,8 +1268,7 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): ch_traces = evoked.copy().pick_channels(use_ch).data ch_traces -= np.mean(ch_traces, axis=1, keepdims=True) ch_traces /= np.abs(ch_traces).max() - with warnings.catch_warnings(record=True): # tight_layout - this_evoked.plot(picks='all', axes=[ax]) + this_evoked.plot(picks='all', axes=[ax], show=False) for line in ax.lines: line.set(lw=0.5, zorder=3) for t in list(ax.texts): @@ -1307,16 +1300,14 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): need_legend = False last_ax[1] = ax # Before and after traces - ax = plt.subplot2grid(shape, (ri, 0), colspan=cs_trace) - with warnings.catch_warnings(record=True): # tight_layout - this_evoked.plot( - picks='all', axes=[ax]) + ax = plt.subplot2grid(shape, (ri, 0), colspan=cs_trace, fig=fig) + this_evoked.plot(picks='all', axes=[ax], show=False) for line in ax.lines: line.set(lw=0.5, zorder=3) loff = len(ax.lines) - with warnings.catch_warnings(record=True): # tight_layout - this_evoked.copy().add_proj(projs).apply_proj().plot( - picks='all', axes=[ax]) + e = this_evoked.copy().add_proj(projs) + e.info.normalize_proj() + e.apply_proj().plot(picks='all', axes=[ax], show=False) for line in ax.lines[loff:]: line.set(lw=0.5, zorder=4, color='g') for t in list(ax.texts): @@ -1328,7 +1319,6 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): if cs_trace: for ax in last_ax: ax.set(xlabel='Time (sec)') - fig.subplots_adjust(0.1, 0.15, 1.0, 0.9, wspace=0.25, hspace=0.2) assert used.all() and (used <= 2).all() return fig diff --git a/mnefun/_viz.py b/mnefun/_viz.py index 5c040f6..b945350 100644 --- a/mnefun/_viz.py +++ b/mnefun/_viz.py @@ -74,9 +74,8 @@ def plot_colorbar(lims, ticks=None, ticklabels=None, figsize=(1, 2), if ticks is None: ticks = none_ticks del colormap, lims, use_lims - adjust = (ax is None) if ax is None: - fig, ax = plt.subplots(1, figsize=figsize) + fig, ax = plt.subplots(1, figsize=figsize, layout="constrained") else: fig = ax.figure norm = Normalize(vmin=vmin, vmax=vmax) @@ -111,8 +110,6 @@ def plot_colorbar(lims, ticks=None, ticklabels=None, figsize=(1, 2), vas = ['top', 'bottom'] for x, y, l, ha, va in zip(xs, ys, end_labels, has, vas): ax.text(x, y, l, ha=ha, va=va, fontsize=ticklabelsize) - if adjust: - fig.subplots_adjust(0.01, 0.05, 0.2, 0.95) return fig @@ -383,7 +380,7 @@ def plot_good_coils(raw, t_step=1., t_window=0.2, dist_limit=0.005, t, counts, n_coils = compute_good_coils(raw, t_step, t_window, dist_limit) del t_step, t_window, dist_limit - fig, ax = plt.subplots(figsize=(8, 2)) + fig, ax = plt.subplots(figsize=(8, 2), layout="constrained") ax.step(t, counts, zorder=4, color='k', clip_on=False) ax.set(xlim=t[[0, -1]], ylim=[0, n_coils], xlabel='Time (sec)', ylabel='Good coils') From 1636bae33337abd5b69e2c1909dd66f2baaa5eed Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 20 Sep 2024 10:45:08 -0400 Subject: [PATCH 3/4] FIX: Limit --- mnefun/_report.py | 5 +++-- setup.cfg | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/mnefun/_report.py b/mnefun/_report.py index 67d499d..6373c25 100644 --- a/mnefun/_report.py +++ b/mnefun/_report.py @@ -1251,8 +1251,9 @@ def _proj_fig(fname, info, proj_nums, proj_meg, kind, use_ch, duration): topo_axes = [plt.subplot2grid(shape, (ri, ci + cs_trace), fig=fig) for ci in range(count)] # topomaps - plot_projs_topomap(these_projs, info=info, show=False, - axes=topo_axes) + plot_projs_topomap( + these_projs, info=info, show=False, axes=topo_axes, + ) plt.setp(topo_axes, title='', xlabel='') unit = mne.defaults.DEFAULTS['units'][ch_type] if cs_trace: diff --git a/setup.cfg b/setup.cfg index 65322a7..8f28713 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,7 @@ [flake8] exclude = __init__.py,externals ignore = W504,PD005,PD011 +max-line-length = 88 [tool:pytest] addopts = From 51a60f4e5d1e49249dab59a930ee2d48e1a36710 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 20 Sep 2024 11:40:36 -0400 Subject: [PATCH 4/4] FIX: noqa --- mnefun/_fix.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mnefun/_fix.py b/mnefun/_fix.py index 916d87c..7210f07 100644 --- a/mnefun/_fix.py +++ b/mnefun/_fix.py @@ -118,7 +118,7 @@ def fix_eeg_channels(raw_files, anon=None, verbose=True): anon = anon.copy() if ( isinstance(raw.info["subject_info"].get("birthday"), datetime.date) - and isinstance(anon.get("birthday"), tuple) + and isinstance(anon.get("birthday"), tuple) # noqa ): anon["birthday"] = datetime.date(*anon["birthday"]) anon['birthday'] = raw.info["subject_info"]["birthday"]