MemmapData#
- class MemmapData(filename, shape, *, dtype=dtype('float32'), mode='r+', order='F', transposed=False, temporary=False, debug=False, _backing=None)#
Bases:
objectNumPy-compatible handle for channel-major EEG data stored on disk.
Indexing uses the logical EEG shape and ordinary zero-based NumPy rules. Out-of-range indices raise, and assigning an empty array does not delete.
matlab_assignanddeleteimplement EEGLAB@mmosubscript behaviour: growth, empty-assignment deletion, andfindon logical masks.transposed=Truemaps EEGLAB.dat-style storage whose physical axes are(samples, trials, channels)without exposing that layout to callers. Explicit and deep copies share the backing file until a copy is mutated, at which point that handle gets a private temporary file.- Parameters:
- classmethod empty(shape, *, filename=None, dtype=dtype('float32'), order='F', transposed=False, temporary=None, fill_value=0.0)#
Create a writable disk-backed array initialized to
fill_value.
- classmethod from_array(data, *, filename=None, dtype=dtype('float32'), order='F', transposed=False, temporary=None)#
Write an array to disk and return a logical memory-mapped view.
- flush()#
Flush pending writes to the backing file.
- Return type:
None
- close()#
Flush and release the backing memory map handle.
- Return type:
None
- copy(order='C')#
Return an in-memory copy of the mapped data.
- mapped_copy()#
Return an independent writable disk-backed copy.
- Return type:
- resize(shape, *, fill_value=0.0)#
Resize this mapping, retaining the overlapping logical data region.
Resizing writes a private replacement sidecar. The original sidecar is never resized underneath another handle.
- delete(indices, *, axis=None)#
Delete logical indices and replace the sidecar with the smaller data.
axis=Nonefollows column-major linear deletion. Matrix results become row vectors, while column-vector inputs remain columns. Deletion alongaxisaddresses that axis of the full array and does not fold trailing dimensions. A boolean mask is converted withfindfirst: onlyTruepositions are removed, and an all-false mask is a no-op.
- change_file(filename, *, writable=False)#
Move a private mapping, or copy a shared mapping, to
filename.
- reshape(*shape, **kwargs)#
Return a reshaped view using NumPy’s reshape semantics.
- astype(*args, **kwargs)#
Return a typed array using NumPy’s astype semantics.
- sum(*args, **kwargs)#
Return NumPy’s sum over the mapped data.
- mean(*args, **kwargs)#
Return NumPy’s mean over the mapped data.
- matlab_assign(key, value)#
Assign using EEGLAB
@mmosubscript rules.Numeric indices past the end grow that axis and fill the new samples with zeros. An empty value deletes the indexed entries. A key shorter than the array rank folds trailing dimensions together before that deletion, so two subscripts on a channels-by-samples-by-trials array address channels by samples-times-trials. A boolean mask is converted with
find: onlyTruepositions are removed, and an all-false mask leaves the mapping unchanged.With
debug=True, a write printsusing same copywhen it updates the current file,new copy createdwhen copy-on-write replaces it, andnew copy created, old deletedwhen growth or deletion replaces the file. Ordinary[]indexing does not grow, delete, or print.