mne-python icon indicating copy to clipboard operation
mne-python copied to clipboard

Add preload keyward argument to Inst.load_data() method call

Open KareemShalabi opened this issue 7 months ago • 3 comments

Preload keyward argument is available only in mne read_* functions. If you want to load data into a memeory mapped file, you have to call one of those functions. There is no way to do it after instanization of the class without playing around with private properites or methods.

#use cases: raw is a copy, or returned from some other function.
raw._data = np.memmap(path, shape, dtype)
Raw.preload = True
# or using self._preload_data which load_data actually calls
raw._preload_data(preload=path)

Adding preload as a keyward argument would prevent users from playing around with private members

KareemShalabi avatar Apr 16 '26 13:04 KareemShalabi

Okay for me to add a str arg to .load_data for whichever classes already support memmapping (at least raw, maybe Epochs?). Calling it preload would be consistent with what it's called in read_raw_*, but seems like a bit of a misnomer here. I think .load_data(memmap=None | Path-like) might make more sense here

larsoner avatar Apr 16 '26 14:04 larsoner

Okay for me to add a str arg to .load_data for whichever classes already support memmapping (at least raw, maybe Epochs?). Calling it preload would be consistent with what it's called in read_raw_*, but seems like a bit of a misnomer here. I think .load_data(memmap=None | Path-like) might make more sense here

Yes that was my thinking also. memmap would be a bit more informative.

KareemShalabi avatar Apr 16 '26 16:04 KareemShalabi

@KareemShalabi are you planning to work on this ? Please let me know, if there are any updates from your side. Thanks 😊

Aniketsy avatar Apr 20 '26 18:04 Aniketsy