From b1283694a5841717bd6f17b208baa972aff4858d Mon Sep 17 00:00:00 2001 From: Clemens Brunner Date: Tue, 9 Apr 2024 07:56:15 +0200 Subject: [PATCH] Use built-in MNE export --- src/mnelab/io/writers.py | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/src/mnelab/io/writers.py b/src/mnelab/io/writers.py index a2bfb5fc..e9853c44 100644 --- a/src/mnelab/io/writers.py +++ b/src/mnelab/io/writers.py @@ -61,31 +61,7 @@ def write_edf(fname, raw): def write_bv(fname, raw, events=None): """Export data to BrainVision EEG/VHDR/VMRK file (requires pybv).""" - import pybv - - name, _ = Path(fname).stem, "".join(Path(fname).suffixes) - parent = Path(fname).parent - data = raw.get_data() - fs = raw.info["sfreq"] - ch_names = raw.info["ch_names"] - if events is None: - if raw.annotations: - events = mne.events_from_annotations(raw, regexp=None)[0] - dur = raw.annotations.duration * fs - events = np.column_stack([events[:, [0, 2]], dur.astype(int)]) - else: - events = events[:, [0, 2]] - units = [ch["unit"] for ch in raw.info["chs"]] - units = ["µV" if unit == 107 else "AU" for unit in units] - pybv.write_brainvision( - data=data, - sfreq=fs, - ch_names=ch_names, - fname_base=name, - folder_out=parent, - events=events, - unit=units, - ) + raw.export(fname=Path(fname).with_suffix(".vhdr"), events=events) # this dict contains each supported file extension as a key; the corresponding value is a