wonambi.ioeeg.wonambi module
Package to import and export common formats.
- class wonambi.ioeeg.wonambi.Wonambi(filename)[source]
Bases:
object
Class to read the data in Wonambi format, which is fast to write and read
- Parameters:
filename (path to file) – the name of the filename with extension .won
- return_dat(chan, begsam, endsam)[source]
Return the data as 2D numpy.ndarray.
- Parameters:
chan (int or list) – index (indices) of the channels to read
begsam (int) – index of the first sample
endsam (int) – index of the last sample
- Returns:
numpy.ndarray – A 2d matrix, with dimension chan X samples. To save memory, the data are memory-mapped, and you cannot change the values on disk.
- Raises:
FileNotFoundError – if .dat file is not in the same directory, with the same name.
Notes
When asking for an interval outside the data boundaries, it returns NaN for those values. It then converts the memmap to a normal numpy array, I think, and so it reads the data into memory. However, I’m not 100% sure that this is what happens.
- return_hdr()[source]
Return the header for further use.
- Returns:
subj_id (str) – subject identification code
start_time (datetime) – start time of the dataset
s_freq (float) – sampling frequency
chan_name (list of str) – list of all the channels
n_samples (int) – number of samples in the dataset
orig (dict) – the json file
- wonambi.ioeeg.wonambi.write_wonambi(data, filename, subj_id='', dtype='float64')[source]
Write file in simple Wonambi format.
- Parameters:
data (instance of ChanTime) – data with only one trial
filename (path to file) – file to export to (the extensions .won and .dat will be added)
subj_id (str) – subject id
dtype (str) – numpy dtype in which you want to save the data
Notes
Wonambi format creates two files, one .won with the dataset info as json file and one .dat with the memmap recordings.
It will happily overwrite any existing file with the same name.
Memory-mapped matrices are column-major, Fortran-style, to be compatible with Matlab.