Skip to content

Commit e4eaf3b

Browse files
authored
Merge branch 'main' into edfanon
2 parents 06fbc43 + dd3c984 commit e4eaf3b

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

mne_bids/tests/test_write.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@
103103
"ignore:Channel mismatch between .*channels\\.tsv and the raw data file "
104104
"detected\\.:RuntimeWarning:mne"
105105
),
106+
converting_to_edf=r"ignore:Converting data files to [BE]DF format:RuntimeWarning",
107+
edf_date="ignore:.*limits dates to after 1985-01-01:RuntimeWarning",
106108
)
107109

108110

@@ -3785,8 +3787,8 @@ def test_write_associated_emptyroom(_bids_validate, tmp_path, empty_room_dtype):
37853787
assert meg_json_data["AssociatedEmptyRoom"] == expected_rel
37863788

37873789

3788-
def test_preload(_bids_validate, tmp_path):
3789-
"""Test writing custom preloaded raw objects."""
3790+
def test_preload_errors(tmp_path):
3791+
"""Test allow_preload error handling."""
37903792
bids_root = tmp_path / "bids"
37913793
bids_path = _bids_path.copy().update(root=bids_root)
37923794
sfreq, n_points = 1024.0, int(1e6)
@@ -3796,21 +3798,37 @@ def test_preload(_bids_validate, tmp_path):
37963798
raw.orig_format = "single"
37973799
raw.info["line_freq"] = 60
37983800

3801+
shared_kwargs = dict(raw=raw, bids_path=bids_path, verbose=False, overwrite=True)
37993802
# reject preloaded by default
38003803
with pytest.raises(ValueError, match="allow_preload"):
3801-
write_raw_bids(raw, bids_path, verbose=False, overwrite=True)
3804+
write_raw_bids(**shared_kwargs)
38023805

38033806
# preloaded raw must specify format
38043807
with pytest.raises(ValueError, match="format"):
3805-
write_raw_bids(
3806-
raw, bids_path, allow_preload=True, verbose=False, overwrite=True
3807-
)
3808+
write_raw_bids(**shared_kwargs, allow_preload=True)
38083809

3810+
3811+
@pytest.mark.filterwarnings(
3812+
warning_str["converting_to_edf"],
3813+
warning_str["edfblocks"],
3814+
)
3815+
@pytest.mark.parametrize("format,ch_type", (("BrainVision", "eeg"), ("EDF", "seeg")))
3816+
def test_preload(_bids_validate, tmp_path, format, ch_type):
3817+
"""Test writing custom preloaded raw objects."""
3818+
bids_root = tmp_path / "bids"
3819+
bids_path = _bids_path.copy().update(root=bids_root)
3820+
sfreq = 1024.0
3821+
info = mne.create_info(["ch1", "ch2"], sfreq, ch_type)
3822+
data = np.zeros((2, 100), dtype=np.float32)
3823+
data[0, 5] = 1.0 # avoid physical_min == physical_max
3824+
raw = mne.io.RawArray(data, info)
3825+
raw.orig_format = "single"
3826+
raw.info["line_freq"] = 60
38093827
write_raw_bids(
38103828
raw,
38113829
bids_path,
38123830
allow_preload=True,
3813-
format="BrainVision",
3831+
format=format,
38143832
verbose=False,
38153833
overwrite=True,
38163834
)

0 commit comments

Comments
 (0)