@@ -217,7 +217,7 @@ def test_write_participants(_bids_validate, tmp_path):
217217 files are kept, and mne-bids correctly writes all
218218 the subject info it can using ``raw.info['subject_info']``.
219219 """
220- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
220+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
221221 raw = _read_raw_fif (raw_fname )
222222
223223 # add fake participants data
@@ -319,7 +319,7 @@ def test_write_participants(_bids_validate, tmp_path):
319319@testing .requires_testing_data
320320def test_write_correct_inputs ():
321321 """Test that inputs of write_raw_bids is correct."""
322- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
322+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
323323 raw = _read_raw_fif (raw_fname )
324324
325325 bids_path_str = "sub-01_ses-01_meg.fif"
@@ -441,7 +441,7 @@ def test_stamp_to_dt():
441441@testing .requires_testing_data
442442def test_get_anonymization_daysback ():
443443 """Test daysback querying for anonymization."""
444- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
444+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
445445 raw = _read_raw_fif (raw_fname )
446446 daysback_min , daysback_max = _get_anonymization_daysback (raw )
447447 # max_val off by 1 on Windows for some reason
@@ -521,7 +521,7 @@ def test_fif(_bids_validate, tmp_path):
521521 pytest .importorskip ("pybv" , PYBV_VERSION )
522522 bids_root = tmp_path / "bids1"
523523 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" )
524- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
524+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
525525
526526 event_id = {
527527 "Auditory/Left" : 1 ,
@@ -531,9 +531,7 @@ def test_fif(_bids_validate, tmp_path):
531531 "Smiley" : 5 ,
532532 "Button" : 32 ,
533533 }
534- events_fname = op .join (
535- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
536- )
534+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
537535
538536 # Drop unknown events.
539537 events = mne .read_events (events_fname )
@@ -899,7 +897,7 @@ def test_chpi(_bids_validate, tmp_path, fmt):
899897def test_fif_dtype (_bids_validate , tmp_path ):
900898 """Test functionality of the write_raw_bids conversion for fif."""
901899 bids_path = _bids_path .copy ().update (root = tmp_path , datatype = "meg" )
902- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
900+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
903901 desired_fmt = "int"
904902 raw = _read_raw_fif (raw_fname )
905903
@@ -919,7 +917,7 @@ def test_fif_anonymize(_bids_validate, tmp_path):
919917 """Test write_raw_bids() with anonymization fif."""
920918 bids_root = tmp_path / "bids1"
921919 bids_path = _bids_path .copy ().update (root = bids_root )
922- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
920+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
923921
924922 event_id = {
925923 "Auditory/Left" : 1 ,
@@ -929,9 +927,7 @@ def test_fif_anonymize(_bids_validate, tmp_path):
929927 "Smiley" : 5 ,
930928 "Button" : 32 ,
931929 }
932- events_fname = op .join (
933- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
934- )
930+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
935931
936932 # Drop unknown events.
937933 events = mne .read_events (events_fname )
@@ -1006,7 +1002,7 @@ def test_fif_anonymize(_bids_validate, tmp_path):
10061002@testing .requires_testing_data
10071003def test_fif_ias (tmp_path ):
10081004 """Test writing FIF files with internal active shielding."""
1009- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
1005+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
10101006 raw = _read_raw_fif (raw_fname )
10111007
10121008 raw .set_channel_types ({raw .ch_names [0 ]: "ias" })
@@ -1022,7 +1018,7 @@ def test_fif_ias(tmp_path):
10221018@testing .requires_testing_data
10231019def test_fif_exci (tmp_path ):
10241020 """Test writing FIF files with excitation channel."""
1025- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
1021+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
10261022 raw = _read_raw_fif (raw_fname )
10271023
10281024 raw .set_channel_types ({raw .ch_names [0 ]: "exci" })
@@ -1983,10 +1979,11 @@ def test_get_anat_landmarks():
19831979 # Needs to be converted to Nifti because we only have mgh in our test base
19841980 t1w_mgh = op .join (data_path , "subjects" , "sample" , "mri" , "T1.mgz" )
19851981 fs_subjects_dir = op .join (data_path , "subjects" )
1986- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
1982+ base_path = data_path / "MEG" / "sample"
1983+ raw_fname = base_path / "sample_audvis_trunc_raw.fif"
19871984 raw = _read_raw_fif (raw_fname )
19881985 # Write some MRI data and supply a `trans`
1989- trans_fname = raw_fname . replace ( "_raw.fif" , " -trans.fif")
1986+ trans_fname = base_path / "sample_audvis_trunc -trans.fif"
19901987 trans = mne .read_trans (trans_fname )
19911988
19921989 # define some keyword arguments to simplify testing
@@ -2094,7 +2091,8 @@ def test_write_anat(_bids_validate, tmp_path):
20942091 )
20952092
20962093 # write base bids directory
2097- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2094+ base_fpath = data_path / "MEG" / "sample"
2095+ raw_fname = base_fpath / "sample_audvis_trunc_raw.fif"
20982096
20992097 event_id = {
21002098 "Auditory/Left" : 1 ,
@@ -2104,9 +2102,7 @@ def test_write_anat(_bids_validate, tmp_path):
21042102 "Smiley" : 5 ,
21052103 "Button" : 32 ,
21062104 }
2107- events_fname = op .join (
2108- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2109- )
2105+ events_fname = base_fpath / "sample_audvis_trunc_raw-eve.fif"
21102106
21112107 # Drop unknown events.
21122108 events = mne .read_events (events_fname )
@@ -2219,7 +2215,7 @@ def test_write_anat(_bids_validate, tmp_path):
22192215
22202216 # Test now using FLASH
22212217 flash_mgh = op .join (data_path , "subjects" , "sample" , "mri" , "flash" , "mef05.mgz" )
2222- trans_fname = raw_fname . replace ( "_raw.fif" , " -trans.fif")
2218+ trans_fname = base_fpath / "sample_audvis_trunc -trans.fif"
22232219 landmarks = get_anat_landmarks (
22242220 flash_mgh , raw .info , trans_fname , "sample" , op .join (data_path , "subjects" )
22252221 )
@@ -2254,7 +2250,7 @@ def test_write_anat(_bids_validate, tmp_path):
22542250@testing .requires_testing_data
22552251def test_write_raw_pathlike (tmp_path ):
22562252 """Ensure writing pathlib.Path works."""
2257- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2253+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
22582254 event_id = {
22592255 "Auditory/Left" : 1 ,
22602256 "Auditory/Right" : 2 ,
@@ -2285,7 +2281,7 @@ def test_write_raw_pathlike(tmp_path):
22852281@testing .requires_testing_data
22862282def test_write_raw_no_dig (tmp_path ):
22872283 """Test writing without dig."""
2288- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2284+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
22892285 raw = _read_raw_fif (raw_fname )
22902286 bids_root = tmp_path
22912287 bids_path = _bids_path .copy ().update (root = bids_root )
@@ -2305,8 +2301,9 @@ def test_write_raw_no_dig(tmp_path):
23052301def test_write_anat_pathlike (tmp_path ):
23062302 """Test writing anatomical data with pathlib.Paths."""
23072303 pytest .importorskip ("nibabel" )
2308- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2309- trans_fname = raw_fname .replace ("_raw.fif" , "-trans.fif" )
2304+ base_path = data_path / "MEG" / "sample"
2305+ raw_fname = base_path / "sample_audvis_trunc_raw.fif"
2306+ trans_fname = base_path / "sample_audvis_trunc-trans.fif"
23102307 raw = _read_raw_fif (raw_fname )
23112308 trans = mne .read_trans (trans_fname )
23122309
@@ -2338,10 +2335,8 @@ def test_write_anat_pathlike(tmp_path):
23382335@testing .requires_testing_data
23392336def test_write_does_not_alter_events_inplace (tmp_path ):
23402337 """Test that writing does not modify the passed events array."""
2341- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2342- events_fname = op .join (
2343- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2344- )
2338+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
2339+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
23452340
23462341 raw = _read_raw_fif (raw_fname )
23472342 events = mne .read_events (events_fname )
@@ -2419,7 +2414,7 @@ def test_mark_channels(
24192414 # Setup: Create a fresh BIDS dataset.
24202415 bids_root = tmp_path / "bids1"
24212416 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" , suffix = "meg" )
2422- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2417+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
24232418 event_id = {
24242419 "Auditory/Left" : 1 ,
24252420 "Auditory/Right" : 2 ,
@@ -2428,9 +2423,7 @@ def test_mark_channels(
24282423 "Smiley" : 5 ,
24292424 "Button" : 32 ,
24302425 }
2431- events_fname = op .join (
2432- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2433- )
2426+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
24342427
24352428 # Drop unknown events.
24362429 events = mne .read_events (events_fname )
@@ -2531,7 +2524,7 @@ def test_mark_channel_roundtrip(tmp_path):
25312524 # Setup: Create a fresh BIDS dataset.
25322525 bids_root = tmp_path / "bids1"
25332526 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" , suffix = "meg" )
2534- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2527+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
25352528 event_id = {
25362529 "Auditory/Left" : 1 ,
25372530 "Auditory/Right" : 2 ,
@@ -2540,9 +2533,7 @@ def test_mark_channel_roundtrip(tmp_path):
25402533 "Smiley" : 5 ,
25412534 "Button" : 32 ,
25422535 }
2543- events_fname = op .join (
2544- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2545- )
2536+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
25462537
25472538 # Drop unknown events.
25482539 events = mne .read_events (events_fname )
@@ -2583,7 +2574,7 @@ def test_error_mark_channels(tmp_path):
25832574 # Setup: Create a fresh BIDS dataset.
25842575 bids_root = tmp_path / "bids1"
25852576 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" , suffix = "meg" )
2586- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2577+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
25872578 event_id = {
25882579 "Auditory/Left" : 1 ,
25892580 "Auditory/Right" : 2 ,
@@ -2592,9 +2583,7 @@ def test_error_mark_channels(tmp_path):
25922583 "Smiley" : 5 ,
25932584 "Button" : 32 ,
25942585 }
2595- events_fname = op .join (
2596- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2597- )
2586+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
25982587
25992588 # Drop unknown events.
26002589 events = mne .read_events (events_fname )
@@ -2660,7 +2649,7 @@ def test_write_meg_calibration(_bids_validate, tmp_path):
26602649 bids_root = tmp_path / "bids1"
26612650 bids_path = _bids_path .copy ().update (root = bids_root )
26622651
2663- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2652+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
26642653 raw = _read_raw_fif (raw_fname , verbose = False )
26652654 write_raw_bids (raw , bids_path = bids_path , verbose = False )
26662655
@@ -2707,7 +2696,7 @@ def test_write_meg_crosstalk(_bids_validate, tmp_path):
27072696 bids_root = tmp_path / "bids1"
27082697 bids_path = _bids_path .copy ().update (root = bids_root , suffix = "meg" )
27092698
2710- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2699+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
27112700 raw = _read_raw_fif (raw_fname , verbose = False )
27122701 write_raw_bids (raw , bids_path = bids_path , verbose = False )
27132702
@@ -2746,10 +2735,8 @@ def test_annotations(_bids_validate, bad_segments, tmp_path):
27462735 """Test that Annotations are stored as events."""
27472736 bids_root = tmp_path / "bids1"
27482737 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" )
2749- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2750- events_fname = op .join (
2751- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2752- )
2738+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
2739+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
27532740
27542741 events = mne .read_events (events_fname )
27552742 event_id = {
@@ -2890,10 +2877,8 @@ def test_undescribed_events(_bids_validate, drop_undescribed_events, tmp_path):
28902877 """Test we're raising if event descriptions are missing."""
28912878 bids_root = tmp_path / "bids1"
28922879 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" )
2893- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2894- events_fname = op .join (
2895- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2896- )
2880+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
2881+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
28972882
28982883 events = mne .read_events (events_fname )
28992884 if drop_undescribed_events :
@@ -2940,10 +2925,8 @@ def test_event_storage(tmp_path):
29402925 """Test we're retaining the original event IDs when storing events."""
29412926 bids_root = tmp_path / "bids1"
29422927 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" )
2943- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
2944- events_fname = op .join (
2945- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
2946- )
2928+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
2929+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
29472930 events_tsv_fname = bids_path .copy ().update (suffix = "events" , extension = ".tsv" )
29482931
29492932 events = mne .read_events (events_fname )
@@ -3281,10 +3264,8 @@ def test_sidecar_encoding(_bids_validate, tmp_path):
32813264 """Test we're properly encoding text as UTF8."""
32823265 bids_root = tmp_path / "bids1"
32833266 bids_path = _bids_path .copy ().update (root = bids_root , datatype = "meg" )
3284- raw_fname = op .join (data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
3285- events_fname = op .join (
3286- data_path , "MEG" , "sample" , "sample_audvis_trunc_raw-eve.fif"
3287- )
3267+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
3268+ events_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw-eve.fif"
32883269
32893270 raw = _read_raw_fif (raw_fname )
32903271 events = mne .read_events (events_fname )
@@ -3668,7 +3649,7 @@ def test_symlink(tmp_path):
36683649def test_write_associated_emptyroom (_bids_validate , tmp_path , empty_room_dtype ):
36693650 """Test functionality of the write_raw_bids conversion for fif."""
36703651 bids_root = tmp_path / "bids1"
3671- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
3652+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
36723653 raw = _read_raw_fif (raw_fname )
36733654 meas_date = datetime (year = 2020 , month = 1 , day = 10 , tzinfo = timezone .utc )
36743655
@@ -3760,7 +3741,7 @@ def test_preload(_bids_validate, tmp_path):
37603741@testing .requires_testing_data
37613742def test_write_raw_special_paths (tmp_path , dir_name ):
37623743 """Test writing to locations containing strings with special meaning."""
3763- raw_fname = op . join ( data_path , "MEG" , "sample" , "sample_audvis_trunc_raw.fif" )
3744+ raw_fname = data_path / "MEG" / "sample" / "sample_audvis_trunc_raw.fif"
37643745 raw = _read_raw_fif (raw_fname )
37653746
37663747 root = tmp_path / dir_name
0 commit comments