diff --git a/doc/changes/dev/14246.newfeature.rst b/doc/changes/dev/14246.newfeature.rst new file mode 100644 index 00000000000..f08e4464881 --- /dev/null +++ b/doc/changes/dev/14246.newfeature.rst @@ -0,0 +1 @@ +Speed up reading large Artemis123, Curry, EEGLAB, Eximia, FIL and NSx files by reading them in cache-sized blocks, by `Bruno Aristimunha`_. diff --git a/mne/io/artemis123/artemis123.py b/mne/io/artemis123/artemis123.py index 54d83b4296c..a7ca0378675 100644 --- a/mne/io/artemis123/artemis123.py +++ b/mne/io/artemis123/artemis123.py @@ -19,6 +19,10 @@ from ..base import BaseRaw from .utils import _load_mne_locs, _read_pos +# read in cache-sized blocks rather than one huge one (1.5x on a 176 MB file); see +# _read_segments_file() for why a smaller block is faster +_BLOCK_BYTES = 16 * 1024**2 + @verbose def read_raw_artemis123( @@ -536,4 +540,15 @@ def __init__( def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): """Read a chunk of raw data.""" - _read_segments_file(self, data, idx, fi, start, stop, cals, mult, dtype=">f4") + _read_segments_file( + self, + data, + idx, + fi, + start, + stop, + cals, + mult, + dtype=">f4", + max_block_bytes=_BLOCK_BYTES, + ) diff --git a/mne/io/curry/curry.py b/mne/io/curry/curry.py index c39471694db..8f62050f2e3 100644 --- a/mne/io/curry/curry.py +++ b/mne/io/curry/curry.py @@ -209,6 +209,11 @@ def _get_curry_recording_type(fname): return "evoked" +# read in cache-sized blocks rather than one huge one (1.5x on a 107 MB file); see +# _read_segments_file() for why a smaller block is faster +_BLOCK_BYTES = 16 * 1024**2 + + def _get_curry_epoch_info(fname): _soft_import("curryreader", "read epoch info") _soft_import("pandas", "dataframe integration") @@ -865,7 +870,16 @@ def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): else: _read_segments_file( - self, data, idx, fi, start, stop, cals, mult, dtype="