|
45 | 45 |
|
46 | 46 | # %% |
47 | 47 |
|
48 | | -import os.path as op |
49 | 48 | import shutil |
| 49 | +from pathlib import Path |
50 | 50 |
|
51 | 51 | import mne |
52 | 52 | import nibabel as nib |
|
77 | 77 |
|
78 | 78 | # The electrode coords data are in the tsv file format |
79 | 79 | # which is easily read in using numpy |
80 | | -raw = mne.io.read_raw_fif(op.join(misc_path, "seeg", "sample_seeg_ieeg.fif")) |
| 80 | +raw = mne.io.read_raw_fif(misc_path / "seeg" / "sample_seeg_ieeg.fif") |
81 | 81 | raw.info["line_freq"] = 60 # specify power line frequency as required by BIDS |
82 | | -subjects_dir = op.join(misc_path, "seeg") # Freesurfer recon-all directory |
| 82 | +subjects_dir = misc_path / "seeg" # Freesurfer recon-all directory |
83 | 83 |
|
84 | 84 | # %% |
85 | 85 | # When the locations of the channels in this dataset were found in |
|
153 | 153 | task = "motor" |
154 | 154 |
|
155 | 155 | # get MNE-Python directory w/ example data |
156 | | -mne_data_dir = mne.get_config("MNE_DATASETS_MISC_PATH") |
| 156 | +mne_data_dir = Path(mne.get_config("MNE_DATASETS_MISC_PATH")) |
157 | 157 |
|
158 | 158 | # There is the root directory for where we will write our data. |
159 | | -bids_root = op.join(mne_data_dir, "ieeg_bids") |
| 159 | +bids_root = mne_data_dir / "ieeg_bids" |
160 | 160 |
|
161 | 161 | # %% |
162 | 162 | # To ensure the output path doesn't contain any leftover files from previous |
|
182 | 182 | # plot T1 to show that it is ACPC-aligned |
183 | 183 | # note that the origin is centered on the anterior commissure (AC) |
184 | 184 | # with the y-axis passing through the posterior commissure (PC) |
185 | | -T1_fname = op.join(subjects_dir, "sample_seeg", "mri", "T1.mgz") |
| 185 | +T1_fname = subjects_dir / "sample_seeg" / "mri" / "T1.mgz" |
186 | 186 | fig = plot_anat(T1_fname, cut_coords=(0, 0, 0)) |
187 | 187 | fig.axes["x"].ax.annotate( |
188 | 188 | "AC", |
|
295 | 295 | # We can see that the appropriate citations are already written in the README. |
296 | 296 | # If you are preparing a manuscript, please make sure to also cite MNE-BIDS |
297 | 297 | # there. |
298 | | -readme = op.join(bids_root, "README") |
| 298 | +readme = bids_root / "README" |
299 | 299 | with open(readme, encoding="utf-8-sig") as fid: |
300 | 300 | text = fid.read() |
301 | 301 | print(text) |
|
334 | 334 | shutil.rmtree(bids_root) |
335 | 335 |
|
336 | 336 | # load our raw data again |
337 | | -raw = mne.io.read_raw_fif(op.join(misc_path, "seeg", "sample_seeg_ieeg.fif")) |
| 337 | +raw = mne.io.read_raw_fif(misc_path / "seeg" / "sample_seeg_ieeg.fif") |
338 | 338 | raw.info["line_freq"] = 60 # specify power line frequency as required by BIDS |
339 | 339 |
|
340 | 340 | # get Talairach transform |
|
463 | 463 | shutil.rmtree(bids_root) |
464 | 464 |
|
465 | 465 | # get a template mgz image to transform the montage to voxel coordinates |
466 | | -subjects_dir = op.join(mne.datasets.sample.data_path(), "subjects") |
467 | | -template_T1 = nib.load(op.join(subjects_dir, "fsaverage", "mri", "T1.mgz")) |
| 466 | +subjects_dir = mne.datasets.sample.data_path() / "subjects" |
| 467 | +template_T1 = nib.load(subjects_dir / "fsaverage" / "mri" / "T1.mgz") |
468 | 468 |
|
469 | 469 | # get voxels to surface RAS and scanner RAS transforms |
470 | 470 | vox_mri_t = template_T1.header.get_vox2ras_tkr() # surface RAS |
471 | 471 | vox_ras_t = template_T1.header.get_vox2ras() # scanner RAS |
472 | 472 |
|
473 | 473 | raw = mne.io.read_raw_fif( |
474 | | - op.join(misc_path, "seeg", "sample_seeg_ieeg.fif") # load our raw data again |
| 474 | + misc_path / "seeg" / "sample_seeg_ieeg.fif" # load our raw data again |
475 | 475 | ) |
476 | 476 | montage = raw.get_montage() # get the original montage |
477 | 477 | montage.apply_trans(trans) # head->mri |
|
0 commit comments