Skip to content

Commit fdcfac7

Browse files
authored
path handling intro folder (#10893)
1 parent 3b2e6c9 commit fdcfac7

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

tutorials/intro/10_overview.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"""
1818
# %%
1919

20-
import os
2120
import numpy as np
2221
import mne
2322

@@ -45,8 +44,8 @@
4544
# could be substituted here when running the tutorial locally.
4645

4746
sample_data_folder = mne.datasets.sample.data_path()
48-
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
49-
'sample_audvis_filt-0-40_raw.fif')
47+
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
48+
'sample_audvis_filt-0-40_raw.fif')
5049
raw = mne.io.read_raw_fif(sample_data_raw_file)
5150

5251
# %%
@@ -339,8 +338,8 @@
339338
# baseline activity level across all of cortex).
340339

341340
# load inverse operator
342-
inverse_operator_file = os.path.join(sample_data_folder, 'MEG', 'sample',
343-
'sample_audvis-meg-oct-6-meg-inv.fif')
341+
inverse_operator_file = (sample_data_folder / 'MEG' / 'sample' /
342+
'sample_audvis-meg-oct-6-meg-inv.fif')
344343
inv_operator = mne.minimum_norm.read_inverse_operator(inverse_operator_file)
345344
# set signal-to-noise ratio (SNR) to compute regularization parameter (λ²)
346345
snr = 3.
@@ -356,7 +355,7 @@
356355
# (the ``subjects_dir``):
357356

358357
# path to subjects' MRI files
359-
subjects_dir = os.path.join(sample_data_folder, 'subjects')
358+
subjects_dir = sample_data_folder / 'subjects'
360359
# plot the STC
361360
stc.plot(initial_time=0.1, hemi='split', views=['lat', 'med'],
362361
subjects_dir=subjects_dir)

tutorials/intro/15_inplace.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,11 @@
2020

2121
# %%
2222

23-
import os
2423
import mne
2524

2625
sample_data_folder = mne.datasets.sample.data_path()
27-
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
28-
'sample_audvis_raw.fif')
26+
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
27+
'sample_audvis_raw.fif')
2928
# the preload flag loads the data into memory now
3029
raw = mne.io.read_raw_fif(sample_data_raw_file, preload=True)
3130
raw.crop(tmax=10.) # raw.crop() always happens in-place

tutorials/intro/20_events_from_raw.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,12 @@
2929

3030
# %%
3131

32-
import os
3332
import numpy as np
3433
import mne
3534

3635
sample_data_folder = mne.datasets.sample.data_path()
37-
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
38-
'sample_audvis_raw.fif')
36+
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
37+
'sample_audvis_raw.fif')
3938
raw = mne.io.read_raw_fif(sample_data_raw_file)
4039
raw.crop(tmax=60).load_data()
4140

@@ -162,7 +161,7 @@
162161
# :attr:`~mne.io.Raw.annotations` attribute of the `~mne.io.Raw` object:
163162

164163
testing_data_folder = mne.datasets.testing.data_path()
165-
eeglab_raw_file = os.path.join(testing_data_folder, 'EEGLAB', 'test_raw.set')
164+
eeglab_raw_file = testing_data_folder / 'EEGLAB' / 'test_raw.set'
166165
eeglab_raw = mne.io.read_raw_eeglab(eeglab_raw_file)
167166
print(eeglab_raw.annotations)
168167

tutorials/intro/30_info.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,11 @@
1717

1818
# %%
1919

20-
import os
2120
import mne
2221

2322
sample_data_folder = mne.datasets.sample.data_path()
24-
sample_data_raw_file = os.path.join(sample_data_folder, 'MEG', 'sample',
25-
'sample_audvis_filt-0-40_raw.fif')
23+
sample_data_raw_file = (sample_data_folder / 'MEG' / 'sample' /
24+
'sample_audvis_filt-0-40_raw.fif')
2625
raw = mne.io.read_raw_fif(sample_data_raw_file)
2726

2827
# %%

0 commit comments

Comments
 (0)