philistine.mne.write_raw_brainvision

philistine.mne.write_raw_brainvision(raw, vhdr_fname, events=True)[source]

Write raw data to BrainVision format.

Parameters:
  • raw (instance of Raw) – The raw data to do these estimations on.
  • vhdr_fname (str) – Path to the EEG header file.
  • events (boolean or ndarray) – If ndarry, events to write in marker file. Otherwise, boolean indicator to extract and write events from raw.

Notes

The BrainVision format supports by-channel filter and measurement information and moreover distinguishes between hardware and software filters. MNE does neither. Currently, filter information is not exported.

Moreover BrainVision also allows for more complex trigger codes than MNE’s simple integers, e.g. distinguishing on supported hardware between stimulus codes (prefixed by an S) and responses codes (prefixed by an R). MNE’s numeric events are all treated as ‘stimulus markers’ and prefixed by an S on output.

Note however that only channels of type ‘eeg’,’eog’, ‘meg’ and ‘misc’ are exported. This follows from the observation that BrainVision recordings produced by BrainProducts devices generally only contain EEG and a few auxiliary channels. The stimulus channel is not exported as channel data, but, in line with BrainVision convention, the events array can be exported to the vmrk file. Channels marked as bad are also not exported, in line with MNE’s default behavior of generally ignoring bad channels. As the current MNE readers do not do much with the channel-level annotations in the vhdr file, it is not really desireable to depend on encoding channel-type or “goodness” there. As such any information related to channel type or badness is lost upon export.

If you really want to export unsupported datatypes or bad channels, then create a copy, mark everything as good and of type ‘eeg’, and export. Be aware that the metadata will have to be corrected the next time the data is read. Other options are to use the private member functions directly that write each of the constituent files (understanding that their API is not guaranteed to be stable) or use the pybv library.

In other words, a round trip import-export is a lossy operation in terms of metadata. The actual EEG recording should be losslessly preserved within the realm of floating point precision and the constraints above.