Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"""Export data to BrainVision EEG/VHDR/VMRK file (requires pybv)."""
import pybv
name, ext = 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)[0]
dur = raw.annotations.duration * fs
events = np.column_stack([events[:, [0, 2]], dur.astype(int)])
else:
events = events[:, [0, 2]]
pybv.write_brainvision(data, fs, ch_names, name, parent, events=events)