Skip to content

Commit

Permalink
MAINT: Speed up doc build (#12040)
Browse files Browse the repository at this point in the history
  • Loading branch information
larsoner committed Oct 1, 2023
1 parent ff6bad2 commit 110947f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 41 deletions.
9 changes: 2 additions & 7 deletions examples/inverse/dics_epochs.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
events = mne.find_events(raw)
epochs = mne.Epochs(
raw,
events,
events[:22], # just for execution speed of the tutorial
event_id=1,
tmin=-1,
tmax=2.5,
Expand All @@ -56,7 +56,6 @@
),
preload=True,
)
epochs = epochs[:10] # just for speed of execution for the tutorial

# We are mostly interested in the beta band since it has been shown to be
# active for somatosensory stimulation
Expand Down Expand Up @@ -121,7 +120,7 @@
subjects_dir=subjects_dir,
hemi="both",
views="dorsal",
initial_time=0.55,
initial_time=1.2,
brain_kwargs=dict(show=False),
add_data_kwargs=dict(
fmin=fmax / 10,
Expand All @@ -131,7 +130,3 @@
colorbar_kwargs=dict(label_font_size=10),
),
)

# You can save a movie like the one on our documentation website with:
# brain.save_movie(tmin=0.55, tmax=1.5, interpolation='linear',
# time_viewer=True)
47 changes: 14 additions & 33 deletions tutorials/intro/70_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,9 @@
# ignored; instead, only the explicitly passed projectors will be plotted.

ecg_proj_path = sample_dir / "sample_audvis_ecg-proj.fif"
eog_proj_path = sample_dir / "sample_audvis_eog-proj.fif"

report = mne.Report(title="Projectors example")
report.add_projs(info=raw_path, title="Projs from info")
report.add_projs(info=raw_path, projs=ecg_proj_path, title="ECG projs from path")
report.add_projs(info=raw_path, projs=eog_proj_path, title="EOG projs from path")
report.save("report_projs.html", overwrite=True)

# %%
Expand Down Expand Up @@ -289,7 +286,11 @@

report = mne.Report(title="BEM example")
report.add_bem(
subject="sample", subjects_dir=subjects_dir, title="MRI & BEM", decim=20, width=256
subject="sample",
subjects_dir=subjects_dir,
title="MRI & BEM",
decim=40,
width=256,
)
report.save("report_mri_and_bem.html", overwrite=True)

Expand Down Expand Up @@ -452,7 +453,7 @@

mne_logo_path = Path(mne.__file__).parent / "icons" / "mne_icon-cropped.png"
fig_array = plt.imread(mne_logo_path)
rotation_angles = np.linspace(start=0, stop=360, num=17)
rotation_angles = np.linspace(start=0, stop=360, num=8, endpoint=False)

figs = []
captions = []
Expand All @@ -462,25 +463,19 @@
fig_array_rotated = fig_array_rotated.clip(min=0, max=1)

# Create the figure
fig, ax = plt.subplots()
fig, ax = plt.subplots(figsize=(3, 3), constrained_layout=True)
ax.imshow(fig_array_rotated)
ax.set_axis_off()

# Store figure and caption
figs.append(fig)
captions.append(f"Rotation angle: {round(angle, 1)}°")

# can also be a MNEQtBrowser instance
with mne.viz.use_browser_backend("qt"):
figs.append(raw.plot())
captions.append("... plus a raw data plot")

report = mne.Report(title="Multiple figures example")
report.add_figure(fig=figs, title="Fun with figures! 🥳", caption=captions)
report.save("report_custom_figures.html", overwrite=True)
for fig in figs[:-1]:
for fig in figs:
plt.close(fig)
figs[-1].close()
del figs

# %%
Expand Down Expand Up @@ -517,7 +512,9 @@

report = mne.Report(title="Tags example")
report.add_image(
image=mne_logo_path, title="MNE Logo", tags=("image", "mne", "logo", "open-source")
image=mne_logo_path,
title="MNE Logo",
tags=("image", "mne", "logo", "open-source"),
)
report.save("report_tags.html", overwrite=True)

Expand Down Expand Up @@ -611,7 +608,7 @@
report = mne.Report(
title="parse_folder example 3", subject="sample", subjects_dir=subjects_dir
)
report.parse_folder(data_path=data_path, pattern="", mri_decim=25)
report.parse_folder(data_path=data_path, pattern="", mri_decim=40)
report.save("report_parse_folder_mri_bem.html", overwrite=True)

# %%
Expand All @@ -638,8 +635,8 @@

baseline = (None, 0)
cov_fname = sample_dir / "sample_audvis-cov.fif"
pattern = "sample_audvis-no-filter-ave.fif"
evoked = mne.read_evokeds(sample_dir / pattern)[0]
pattern = "sample_audvis-ave.fif"
evoked = mne.read_evokeds(sample_dir / pattern)[0].pick("eeg").decimate(4)
report = mne.Report(
title="parse_folder example 4", baseline=baseline, cov_fname=cov_fname
)
Expand All @@ -650,22 +647,6 @@
)
report.save("report_parse_folder_evoked.html", overwrite=True)

# %%
# If you want to actually *view* the noise covariance in the report, make sure
# it is captured by the pattern passed to :meth:`~mne.Report.parse_folder`, and
# also include a source for an :class:`~mne.Info` object (any of the
# :class:`~mne.io.Raw`, :class:`~mne.Epochs` or :class:`~mne.Evoked`
# :file:`.fif` files that contain subject data also contain the measurement
# information and should work):

pattern = "sample_audvis-cov.fif"
info_fname = sample_dir / "sample_audvis-ave.fif"
report = mne.Report(title="parse_folder example 5", info_fname=info_fname)
report.parse_folder(
data_path, pattern=pattern, render_bem=False, n_time_points_evokeds=5
)
report.save("report_parse_folder_cov.html", overwrite=True)

# %%
#
# Adding custom HTML (e.g., a description text)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

# Setup for reading the raw data
raw = mne.io.read_raw_fif(raw_fname, preload=True)
raw.filter(1, 30)
raw.filter(1, 25)
events = mne.read_events(event_fname)

# %%
Expand All @@ -75,6 +75,7 @@
tmin,
tmax,
picks=picks,
decim=2, # just for speed!
baseline=None,
reject=reject,
preload=True,
Expand Down

0 comments on commit 110947f

Please sign in to comment.