You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ENH: Support io.BytesIO in BaseRaw.save and mne.io.read_raw #14514
While integrating MNE with Hugging Face datasets (Biosignal feature storing Arrow/Parquet bytes), we noticed that mne.io.read_raw_fif and mne._fiff.write.start_file already accept io.BytesIO, but BaseRaw.save and mne.io.read_raw reject file-like objects:
raw.save(io.BytesIO()) fails in _check_fname (TypeError: fname must be an instance of path-like, got <class '_io.BytesIO'> instead), _write_raw accesses fpath.parent, and end_file calls fid.close() (which frees the BytesIO buffer).
mne.io.read_raw(io.BytesIO(data)) fails in split_name_ext (Path(fname).suffixes) instead of dispatching when _file_like(fname) is True (e.g. via getattr(fname, "name", None) or magic bytes).
Supporting io.BytesIO in raw.save and mne.io.read_raw would avoid temporary .fif files on disk when serializing/deserializing BaseRaw objects in memory.
Activity