wonambi.dataset module

Module has information about the datasets, not data.

class wonambi.dataset.Dataset(filename, IOClass=None, session=None, bids=False)[source]

Bases: object

Contain specific information and methods, associated with a dataset.

Parameters:
  • filename (str or Path) – name of the file

  • IOClass (class) – one of the classes of wonambi.ioeeg

  • bids (bool) – whether you give precedence to the information stored in the accompanying files which are in the BIDS format

filename

name of the file

Type:

str

IOClass

format of the file

Type:

class

header
  • subj_idstr

    subject identification code

  • start_timedatetime

    start time of the dataset. If it cannot get the start time from the header, wonambi reads it from the timestamp of the file

  • s_freqfloat

    sampling frequency

  • chan_namelist of str

    list of all the channels

  • n_samplesint

    number of samples in the dataset

  • origdict

    additional information taken directly from the header

Type:

dict

dataset
this requires at least three attributes:
  • filename

  • return_hdr

  • return_dat

Type:

instance of a class which depends on format,

Notes

There is a difference between Dataset.filename and Dataset.dataset.filename because the former is where the file that you want to read (the argument), while the latter is the file that you really read. There might be differences, for example, if the argument points to a file within a directory, or if the file is mapped to memory.

read_data(chan=None, begtime=None, endtime=None, begsam=None, endsam=None, events=None, pre=1, post=1, s_freq=None)[source]

Read the data and creates a ChanTime instance

Parameters:
  • chan (list of strings) – names of the channels to read

  • begtime (int or timedelta or datetime or list) – start of the data to read; if it’s int or float, it’s assumed it’s s; if it’s timedelta, it’s assumed from the start of the recording; if it’s datetime, it’s assumed it’s absolute time. It can also be a list of any of the above type.

  • endtime (int or timedelta or datetime) – end of the data to read; if it’s int or float, it’s assumed it’s s; if it’s timedelta, it’s assumed from the start of the recording; if it’s datetime, it’s assumed it’s absolute time. It can also be a list of any of the above type.

  • begsam (int) – first sample (this sample will be included)

  • endsam (int) – last sample (this sample will NOT be included)

  • events (list of int or of timedelta or of datetime) – list of the onset time of the events of interest. This option is useful if you want to run a trial-based analysis.

  • pre (float) – only when “events” is specified, the amount of data before each event to be included (in s). Use a positive number to indicate the time before the event.

  • post (float) – only when “events” is specified, the amount of data after each event to be included (in s).

  • s_freq (int) – sampling frequency of the data

Returns:

An instance of ChanTime

Notes

begsam and endsam follow Python convention, which starts at zero, includes begsam but DOES NOT include endsam.

If begtime and endtime are a list, the two lists should have the same length and the data will be stored in trials.

If neither begtime or begsam are specified, it starts from the first sample. If neither endtime or endsam are specified, it reads until the end.

The time axis will indicate the time in seconds from data.start_time, unless you specify “events”. In that case, time will run from -“pre” to +”post”.

read_markers(**kwargs)[source]

Return the markers. You can add optional arguments that will be passed to the method specific for each datafile.

read_videos(begtime=None, endtime=None)[source]

Return list of videos with start and end times for a period.

Parameters:
  • begtime (int or timedelta or datetime or list) – start of the data to read; if it’s int, it’s assumed it’s s; if it’s timedelta, it’s assumed from the start of the recording; if it’s datetime, it’s assumed it’s absolute time. It can also be a list of any of the above type.

  • endtime (int or timedelta or datetime) – end of the data to read; if it’s int, it’s assumed it’s s; if it’s timedelta, it’s assumed from the start of the recording; if it’s datetime, it’s assumed it’s absolute time. It can also be a list of any of the above type.

Returns:

  • list of path – list of absolute paths (as str) to the movie files

  • float – time in s from the beginning of the first movie when the part of interest starts

  • float – time in s from the beginning of the last movie when the part of interest ends

Raises:
  • OSError – when there are no video files at all

  • IndexError – when there are video files, but the interval of interest is not in the list of files.

wonambi.dataset.detect_format(filename)[source]

Detect file format.

Parameters:

filename (str or Path) – name of the filename or directory.

Returns:

  • class used to read the data.

  • list (indices of sessions)