@@ -381,7 +381,7 @@ def test_electrodes_io(tmp_path):
381381
382382
383383@testing .requires_testing_data
384- def test_task_specific_channels_sidecar (tmp_path ):
384+ def test_task_specific_electrodes_sidecar (tmp_path ):
385385 """Test the optional task- entity in electrodes.tsv."""
386386 raw = _load_raw ()
387387 raw .pick (["eeg" ])
@@ -433,32 +433,20 @@ def test_task_specific_channels_sidecar(tmp_path):
433433 assert coordpath_foo .name == "sub-01_ses-01_acq-01_space-CapTrak_coordsystem.json"
434434 assert coordpath_bar .name == "sub-01_ses-01_acq-01_space-CapTrak_coordsystem.json"
435435
436- # Now test for no task- entity in electrodes.tsv
437-
438- bpath_kwargs = dict (
439- root = bids_root2 ,
440- subject = "01" ,
441- session = "01" ,
442- run = "01" ,
443- acquisition = "01" ,
444- task = "foo" ,
436+ # make sure we are reading the correct electrodes sidecar
437+ raw_foo_want_pos = raw_foo .get_montage ().get_positions ()["ch_pos" ]["EEG 029" ]
438+ raw_foo = mne_bids .read_raw_bids (bpath_foo )
439+ np .testing .assert_allclose (
440+ raw_foo .get_montage ().get_positions ()["ch_pos" ]["EEG 029" ], raw_foo_want_pos
445441 )
446442
447- write_kwargs = dict (
448- allow_preload = True ,
449- electrodes_tsv_task = False ,
450- format = "BrainVision" ,
451- )
443+ # Now test for no task- entity in electrodes.tsv
452444
453- bpath = mne_bids . BIDSPath ( ** bpath_kwargs )
454- bpath_foo = mne_bids . write_raw_bids ( raw_foo , bpath , ** write_kwargs )
445+ bpath_kwargs . update ( root = bids_root2 )
446+ write_kwargs . update ( electrodes_tsv_task = False )
455447
456- bpath_kwargs .update (task = "bar" )
457448 bpath = mne_bids .BIDSPath (** bpath_kwargs )
449+ bpath_foo = mne_bids .write_raw_bids (raw_foo , bpath , ** write_kwargs )
458450
459- # without specifying a task, writing a second electrodes.tsv with the same
460- # filename but different contents fails
461- with pytest .raises (
462- RuntimeError , match = "Trying to write electrodes.tsv, but it already exists"
463- ):
464- bpath_bar = mne_bids .write_raw_bids (raw_bar , bpath , ** write_kwargs )
451+ elpath_foo = bpath_foo .find_matching_sidecar (suffix = "electrodes" , extension = ".tsv" )
452+ assert elpath_foo .name == "sub-01_ses-01_acq-01_space-CapTrak_electrodes.tsv"
0 commit comments