wonambi.ioeeg.ktlx module

Module reads and writes header and data for KTLX data. The files are:
  • .eeg (patient information)

  • .ent (notes, sometimes with a backup file called .ent.old)

  • .erd (raw data)

  • .etc (table of content)

  • .snc (synchronization file)

  • .stc (segmented table of content)

  • .vtc (video table of content)

  • .avi (videos)

There is only one of these files in the directory, except for .erd, .etc., .avi These files are numbered in the format _%03d, except for the first one, which is not _000 but there is no extension, for backwards compatibility.

This module contains functions to read each of the files, the files are called _read_EXT where EXT is one of the extensions.

class wonambi.ioeeg.ktlx.Ktlx(ktlx_dir)[source]

Bases: object

return_dat(chan, begsam, endsam)[source]

Read the data based on begsam and endsam.

Parameters:
  • chan (list of int) – list of channel indeces

  • begsam (int) – index of the first sample

  • endsam – index of the last sample

Returns:

ndarray – 2-d matrix with data (might contain NaN)

Notes

The sample numbering is not based on the samples in the files (i.e. the first sample of the first file is NOT the first sample of the dataset) because it depends on the stamps in the STC file. Usually, the recording starts and after a few millisecond (maybe one second), the actual acquisition starts. STC takes the offset into account. This has the counterintuitive result that if you call read_data, the first few hundreds samples are nan.

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) – additional information taken directly from the header

return_markers()[source]

Reads the notes of the Ktlx recordings.

return_videos(begtime, endtime)[source]
wonambi.ioeeg.ktlx.convert_sample_to_video_time(sample, orig_s_freq, sampleStamp, sampleTime)[source]

Convert sample number to video time, using snc information.

Parameters:
  • sample (int) – sample that you want to convert in time

  • orig_s_freq (int) – sampling frequency (used as backup)

  • sampleStamp (list of int) – Sample number from start of study

  • sampleTime (list of datetime.datetime) – File time representation of sampleStamp

Returns:

instance of datetime – absolute time of the sample.

Notes

Note that there is a discrepancy of 4 or 5 hours between the time in snc and the time in the header. I’m pretty sure that the time in the header is accurate, so we use that. I think that the time in snc does not take into account the time zone (that’d explain the 4 or 5 depending on summertime). This time is only used to get the right video so we call this “video time”.

wonambi.ioeeg.ktlx.get_date_idx(time_of_interest, start_time, end_time)[source]