Repository: mne-tools/mne-python

Issue:
update path handling in examples/preprocessing/muscle_ica.py
all of our `data_path` functions now return `pathlib.Path` objects, which allows things like the following:

https://github.com/mne-tools/mne-python/blob/37a9e5587443109515a85cdc4396af4e014ecf82/examples/datasets/brainstorm_data.py#L32-L35

Compare this to the old pattern (using `os.path.join`, often imported as `op.join`):

```py
raw_path = os.path.join(data_path, 'MEG', 'bst_raw',
                        'subj001_somatosensory_20111109_01_AUX-f.ds')
```

or the *really* old pattern (using the `+` operator on plain strings):

```py
raw_path = (data_path + '/MEG/bst_raw/' +
            'subj001_somatosensory_20111109_01_AUX-f.ds')
```

Update the paths in the file mentioned in the issue title to use the new pathlib-style, which is considered the modern, best-practice way to handle file paths.



Discussion:

Resolving patch:
diff --git a/examples/preprocessing/movement_detection.py b/examples/preprocessing/movement_detection.py
--- a/examples/preprocessing/movement_detection.py
+++ b/examples/preprocessing/movement_detection.py
@@ -23,8 +23,6 @@
 
 # %%
 
-import os.path as op
-
 import mne
 from mne.datasets.brainstorm import bst_auditory
 from mne.io import read_raw_ctf
@@ -32,13 +30,12 @@
 
 # Load data
 data_path = bst_auditory.data_path()
-data_path_MEG = op.join(data_path, 'MEG')
+data_path_MEG = data_path / 'MEG'
 subject = 'bst_auditory'
-subjects_dir = op.join(data_path, 'subjects')
-trans_fname = op.join(data_path, 'MEG', 'bst_auditory',
-                      'bst_auditory-trans.fif')
-raw_fname1 = op.join(data_path_MEG, 'bst_auditory', 'S01_AEF_20131218_01.ds')
-raw_fname2 = op.join(data_path_MEG, 'bst_auditory', 'S01_AEF_20131218_02.ds')
+subjects_dir = data_path / 'subjects'
+trans_fname = data_path / 'MEG' / 'bst_auditory' / 'bst_auditory-trans.fif'
+raw_fname1 = data_path_MEG / 'bst_auditory' / 'S01_AEF_20131218_01.ds'
+raw_fname2 = data_path_MEG / 'bst_auditory' / 'S01_AEF_20131218_02.ds'
 # read and concatenate two files, ignoring device<->head mismatch
 raw = read_raw_ctf(raw_fname1, preload=False)
 mne.io.concatenate_raws(
diff --git a/examples/preprocessing/muscle_detection.py b/examples/preprocessing/muscle_detection.py
--- a/examples/preprocessing/muscle_detection.py
+++ b/examples/preprocessing/muscle_detection.py
@@ -31,7 +31,6 @@
 
 # %%
 
-import os.path as op
 import matplotlib.pyplot as plt
 import numpy as np
 from mne.datasets.brainstorm import bst_auditory
@@ -41,7 +40,7 @@
 
 # Load data
 data_path = bst_auditory.data_path()
-raw_fname = op.join(data_path, 'MEG', 'bst_auditory', 'S01_AEF_20131218_01.ds')
+raw_fname = data_path / 'MEG' / 'bst_auditory' / 'S01_AEF_20131218_01.ds'
 
 raw = read_raw_ctf(raw_fname, preload=False)
 
diff --git a/examples/preprocessing/muscle_ica.py b/examples/preprocessing/muscle_ica.py
--- a/examples/preprocessing/muscle_ica.py
+++ b/examples/preprocessing/muscle_ica.py
@@ -20,11 +20,10 @@
 
 # %%
 
-import os.path as op
 import mne
 
 data_path = mne.datasets.sample.data_path()
-raw_fname = op.join(data_path, 'MEG', 'sample', 'sample_audvis_raw.fif')
+raw_fname = data_path / 'MEG' / 'sample' / 'sample_audvis_raw.fif'
 raw = mne.io.read_raw_fif(raw_fname)
 raw.crop(tmin=100, tmax=130)  # take 30 seconds for speed
 


Test patch: