sab_dataset module

class sab_dataset.ChannelInfo(channel_names)

Bases: object

Contains informations about channels

Attributes:
n_chan : int

Number of channels

chan_names : numpy array (str)

Array containing the channels’ name

chan_names_no_eeg : numpy array (str)

Channel names without the ‘EEG’ prefix

chan_elec_names : numpy array (str)

Name of the electrode for each channel

elec_names : numpy array (str)

Name of all different electrodes

elec_eeg_names : numpy array (str)

Name of all different EEG electrodes

n_elec : int

Number of electrodes

# n_elec_eeg : int

Number of EEG electrodes

Methods

get_channel_name(chan_sel_pos) Get the channel name from the channel’s position
get_channel_pos(chan_sel_name[, true_match]) Return the channel position from the channel’s name
get_eeg_channels() Used to find the EEG channels
get_electrode_channels_pos(elec_desc) Get the channels position of the selected electrode
get_electrode_names() Used to get electrode names from the channel names
get_channel_name(chan_sel_pos)

Get the channel name from the channel’s position

Parameters:
chan_sel_pos : int | array

Channel’s position

Returns:
chan_names : str | list

Channel’s names

get_channel_pos(chan_sel_name, true_match=True)

Return the channel position from the channel’s name

chan_sel_name : str
Channel’s name
true_match : bool (default: True)
If True, search an exact match between chan_sel_name parameter and chan_names attribute. If False returns, every channel position containing chan_sel_name
get_eeg_channels()

Used to find the EEG channels

Note

EEG channels’ name should start with the prefix ‘EEG’

Note

If no EEG channel can be found, all channels are considered to be EEG channels

Returns:
eeg_channels_ind : array [boolean]

Boolean array containing 1 if channel is an EEG channel, 0 otherwise

n_eeg_channels : int

Number of eeg channels

get_electrode_channels_pos(elec_desc)

Get the channels position of the selected electrode

Parameters:
elec_desc : int | str | array

Either the number of the electrode, or the name of the electrode to select

Returns:
elec_chan_pos : array

Position of the channels of the selected electrode

get_electrode_names()

Used to get electrode names from the channel names

Returns:
Electrode names : array
class sab_dataset.SabDataset(matlab_dataset_dirpath, subject_id, dataset_type='rec', colors_dict=[], **kwargs)

Bases: object

Class representing a SAB dataset - can represent the encoding phase or recognition phase. SabDataset instances are created from the Matlab EEGrec/EEGenc datasets (See documentation for more details)

Attributes:
matlab_dataset_dirpath : str

Path of the Matlab dataset

subject_id : str

Subject identifier

dataset_type : str

either ‘rec’ or ‘enc’ for recognition and encoding datasets respectively

srate : int

Sampling Rate (Hz)

data : numpy array [3D]

Data matrix 3D - size [n_chan, n_pnts, n_trials]

times : numpy array

time vector

n_chan, n_pnts, n_trials : int

number of channels / time points / trials

tmin, tmax : num

minimum / maximum time

channel_info : ChannelInfo instance

Contains information about the channels

For ‘rec’ datasets:
hits, correct_rejects, false_alarms, omissions : list | array

binary vectors representing each conditions [size: (n_samples)]

reaction_times : list | array

reaction times vector [size: (n_samples)]

Methods

create_features([chan_sel, electrode_sel, …]) Create a TimeFeatures instance from the current dataset
downsample(decimate_order) Downsample the data along the time axis.
plot_electrode_erps(elec_desc[, plot_ci, …]) Plot on the same figure the ERPs for each channel of the selected electrode
plot_erp(channel_desc[, plot_ci, plot_hits, …]) Plot the evoked response averaged over trials
plot_erp_subplot(data, ax, color_str, plot_ci) Internal rountine used by plot_erp method
plot_itpc(channel_desc[, trial_pos, …]) Plot the ITPC, Inter-Trial Phase Coherence
save([dir_path, filename]) Save the SabDataset instance to a pickle file using the pickle module.
save_sig_to_file(chanpos[, trialpos, output_dir]) Save the signal to a file
plot_mean_spectrum  
create_features(chan_sel=[], electrode_sel=[], trial_sel=[])

Create a TimeFeatures instance from the current dataset

Parameters:
chan_sel : int | str | array | None (default: None)

Channel selection to compute the feature only on these channels. If none, select all channels

electrode_sel : int | str | array | None (default: None)

Electrode selection to compute the feature only on these electrodes. If none, the selection is done based on chan_sel parameter

trial_sel : array | None (default: None)

Trial selection to compute the features only with these trials. If none, select all trials

Returns:
TimeFeatures : Instance of TimeFeatures

TimeFeatures instance generated from the amplitude of the current dataset, given the selected channels

.. note:: If both chan_sel and electrode_sel are provided, the selection is only done given the electrode
selection
downsample(decimate_order)

Downsample the data along the time axis.

Parameters:
decimate_order : int

Order of the down-sampling. Sampling frequency will be divided by this number

plot_electrode_erps(elec_desc, plot_ci=0, plot_hits=1, plot_cr=0, plot_omissions=0, plot_fa=0)

Plot on the same figure the ERPs for each channel of the selected electrode

Parameters:
elec_desc : str

Electrode’s name

plot_ci : bool (default: False)

If True, plot the confidence interval around the mean

plot_hits : bool (default: True)

If True, plot the ERP for the ‘Hit’ condition

plot_cr : bool (default: False)

If True, plot the ERP for the ‘Correct Reject’ condition

plot_omissions : bool (default: False)

If True, plot the ERP for the ‘Omission’ condition

plot_fa : bool (default: False)

If True, plot the ERP for the ‘False Alarme’ condition

plot_erp(channel_desc, plot_ci=1, plot_hits=1, plot_cr=1, plot_omissions=0, plot_fa=0, ax=[], colors_dict=[])

Plot the evoked response averaged over trials

Parameters:
channel_desc : str | int | array

Channel’s name or position

plot_ci : bool (default: True)

If True, plot the confidence interval around the mean

plot_hits : bool (default: True)

If True, plot the ERP for the ‘Hit’ condition

plot_cr : bool (default: True)

If True, plot the ERP for the ‘Correct Reject’ condition

plot_omissions : bool (default: False)

If True, plot the ERP for the ‘Omission’ condition

plot_fa : bool (default: False)

If True, plot the ERP for the ‘False Alarme’ condition

ax : list | none (default: none)

List of axis where to plot the ERP

Returns:
ax_list : list

List of axis where to plot the ERP

leg_h : array

Array of legends handles

plot_erp_subplot(data, ax, color_str, plot_ci)

Internal rountine used by plot_erp method

plot_itpc(channel_desc, trial_pos=[], filt_cf=array([ 3., 3.54095194, 4.17944689, 4.93307353, 5.82259211, 6.87250628, 8.11173816, 9.57442501, 11.30085962, 13.33860028, 15.74378087, 18.58265717, 21.93343201, 25.88840958, 30.55653809, 36.06641099, 42.56980938, 50.24588311, 59.30608584, 70. ]), filt_bw=array([ 1.5, 1.71908979, 1.9701798, 2.25794399, 2.58773897, 2.96570377, 3.39887404, 3.89531311, 4.464262, 5.11631148, 5.86359922, 6.7200357, 7.70156317, 8.82645241, 10.11564282, 11.59313219, 13.28642346, 15.22703661, 17.45109544, 20. ]), f_tolerance=[], noise_tolerance=[], n_monte_carlo=20, ftype='elliptic', forder=4, do_plot=1, contour_plot=1, n_contours=20)

Plot the ITPC, Inter-Trial Phase Coherence

Parameters:
channel_desc : int | str | array

Channel’s position or name

trial_pos : array | None (default: None)

Trial to select before computing the ITPC. If none, select all trials

filt_cf : array

Filter’s center frequency for computing the ITPC (in Hz)

filt_bw : array | int

Filter’s bandwidth. Can be fixed or evolve with the center frequency. (In Hz)

f_tolerance : float | array | None (default: none)

Tolerance of the cut-off frequencies. A random number in the interval [-f_tolerance/2, +f_tolerance/2] will be added to the cut-off frequencies. If none, f_tolerance is set to filt_bw / 100 for each filter.

noise_tolerance : float | None (default: none)

Random noise from a uniform distribution in [-noise_tolerance/2, +noise_tolerance/2] will be added to the signal x_raw. If none, noise_tolerance is set to np.std(data_sel) / 30.

n_monte_carlo : int

Number of monte carlo repetition

ftype : str

Filter type:

  • ‘butter’ : Butterworth filter
  • ‘elliptic’ (default) : Elliptic filter
  • ‘fir’ : Finite Impulse Response filter
forder : int

Filter order - default : 4

do_plot : int | bool

If 1, plot the ITPC (default: 0)

contour_plot : int | bool

If 1 , plot the contours (contourf function) else use the imshow function (default: 1)

n_contours : int

If contour_plot=1, number of levels in contourf function

See also

phase_utils.itpc

plot_mean_spectrum(channel_desc, fmin=2, fmax=90, plot_hits=1, plot_cr=1, plot_omissions=0, plot_fa=0)
save(dir_path='.', filename=[])

Save the SabDataset instance to a pickle file using the pickle module.

Parameters:
dir_path : str

Path of the directory where it will be saved

filename : str

Filename

save_sig_to_file(chanpos, trialpos=[], output_dir='.')

Save the signal to a file

Parameters:
chanpos : int | str

Channel position

trialpos : int | None (default: None)

Trial position. If none, will save all the trials in a 3D data matrix.

output_dir : str (default: ‘.’)

Output directory path

sab_dataset.load_sab_dataset(filepath)

Load a time SabDataset instance previously saved using the pickle module

Parameters:
filepath : str

Path of the pickle file

Returns:
sab_dataset : SabDataset instance

The SabDataset instance