timefeatures.TimeFeatures(data, labels, tmin, tmax, channel_names, label_names, srate, reaction_times=[], name=[])¶Bases: object
Class for the extraction and visualization of features across time from the raw amplitude data.
Visualize the evolution of different features over a time course [tmin, tmax], for multiples trials, for
multiple conditions. The condition of each trial is defined by the labels vector.
The original data is given by the 3D array data_ori (size: [n_features, n_pnts, n_trials]) which usually
represents the amplitude of each channel. From these original data, other feature can be computed using the
feature_extracter attribute, which will be stored in the data attribute.
| Attributes: |
|
|---|
Methods
add_feature(feat_mat, feat_name, feat_type, …) |
Add the feature matrix feat_mat to the existing features in data attribute. |
add_trials(trials_mat, label_id, label_name) |
Add trials related to a new or already existing label |
cluster_data(cluster_algo[, do_plot, ax, cb_ax]) |
Cluster the data selected by **kwargs - see timefeatures.get_data() - Return the cross-tabulation of the predicted versus true labels |
compute_correlation_feature_target(**kwargs) |
Compute and plot the correlation between the selected features for 2 specified conditions. |
compute_correlation_hits_reaction_times([…]) |
Compute and plot the correlation (Pearson or Spearman) between selected features and reaction times (if defined). |
compute_feature_importance(label_keys[, …]) |
Compute feature importance using forest of decitions trees. |
extract_feature([feature_type]) |
Compute features from the original data data_ori and add them to the feature array data |
feature_name2pos(feature_sel_names) |
Return the feature names from the feature positions |
feature_pos2name(feature_pos) |
Return the feature position from the feature names |
get_data(**kwargs) |
Select the data corresponding to selected feature and/or labels and/or time points. |
get_feature_pos([feature_pos, feature_type, …]) |
Get the feature position from feature type or/and feature channel name |
get_label_key_from_value(dict_value) |
Return the label key from the value of the dictionnary attribute label_dict |
interactive_feature_rt_correlation([…]) |
Interactive plot of the correlation between feature and reaction times (for hits trials) |
plot_feature_distribution([ax]) |
Plot the distribution of features at a certain time point for selected labels. |
plot_feature_erp([plot_traces, ax]) |
Plot the feature evolution across time. |
plot_feature_erpimage([ax, cax]) |
Plot the erp-image of the selected features |
plot_feature_hits_reaction_time([scaling, …]) |
Plot the reaction time in function of the feature. |
sample2time(sample) |
Return the time in seconds from the sample index |
save([dir_path, filename, filename_desc]) |
Save the time features instance to a pickle file using the pickle module. |
sort_features([sorting_variable]) |
Sort the features according to sorting_variable |
sort_trials([sorting_variable, direction]) |
Sort the data trial order given the sorting variable. |
time2sample(t_sec) |
Return the sample index from the time in seconds |
add_feature(feat_mat, feat_name, feat_type, feat_channame)¶Add the feature matrix feat_mat to the existing features in data attribute. Update feature_name,
feature_channame and feature_type attributes.
| Parameters: |
|
|---|
add_trials(trials_mat, label_id, label_name, reaction_times=[])¶Add trials related to a new or already existing label
| Parameters: |
|
|---|
cluster_data(cluster_algo, do_plot=False, ax=[], cb_ax=[], **kwargs)¶Cluster the data selected by **kwargs - see timefeatures.get_data() -
Return the cross-tabulation of the predicted versus true labels
| Parameters: |
|
|---|---|
| Returns: |
|
compute_correlation_feature_target(**kwargs)¶Compute and plot the correlation between the selected features for 2 specified conditions. These conditions
must be specified by providing a label_keys parameter. Feature selections parameters can be used to select
features - see get_data() -
| Parameters: |
|
|---|
compute_correlation_hits_reaction_times(transform=[], method='pearson', scaling='', feature_range=(0, 1), ax_list=[], **kwargs)¶Compute and plot the correlation (Pearson or Spearman) between selected features and reaction times (if defined).
| Parameters: |
|
|---|---|
| Returns: |
|
compute_feature_importance(label_keys, n_decision_trees=250)¶Compute feature importance using forest of decitions trees. See sklearn.ensemble.ExtraTreesClassifier()
| Parameters: |
|
|---|
extract_feature(feature_type=[])¶Compute features from the original data data_ori and add them to the feature array data
| Parameters: |
|
|---|
feature_name2pos(feature_sel_names)¶Return the feature names from the feature positions
| Parameters: |
|
|---|---|
| Returns: |
|
feature_pos2name(feature_pos)¶Return the feature position from the feature names
| Parameters: |
|
|---|---|
| Returns: |
|
get_data(**kwargs)¶Select the data corresponding to selected feature and/or labels and/or time points. The selection parameter can be the feature position, channel’s name, type and/or the condition (label_key) and/or the time points.
| Parameters: |
|
|---|---|
| Returns: |
|
get_feature_pos(feature_pos=[], feature_type=[], feature_channame=[], join=0)¶Get the feature position from feature type or/and feature channel name
| Parameters: |
|
|---|---|
| Returns: |
|
get_label_key_from_value(dict_value)¶Return the label key from the value of the dictionnary attribute label_dict
| Parameters: |
|
|---|---|
| Returns: |
|
interactive_feature_rt_correlation(transform=[], method='pearson', scaling=[], feature_range=(0, 1), **kwargs)¶Interactive plot of the correlation between feature and reaction times (for hits trials)
| Parameters: |
|
|---|
plot_feature_distribution(ax=[], **kwargs)¶Plot the distribution of features at a certain time point for selected labels. The time_points parameter should be specified.
| Parameters: |
|
|---|
plot_feature_erp(plot_traces=0, ax=[], **kwargs)¶Plot the feature evolution across time. Selection parameters can be passed.
| Parameters: |
|
|---|
plot_feature_erpimage(ax=[], cax=[], **kwargs)¶Plot the erp-image of the selected features
feature_pos, feature_type, feature_channame,
label_keys, time_points. See get_data()plot_feature_hits_reaction_time(scaling=[], feature_range=(0, 1), transform=[], ax_list=[], **kwargs)¶Plot the reaction time in function of the feature. Used to visualize any correlation between the feature and the reaction time (if it is defined). The ‘time_points’ parameter must be set and contain only 1 value. Only one feature must be selected.
| Parameters: |
|
|---|
sample2time(sample)¶Return the time in seconds from the sample index
| Parameters: |
|
|---|---|
| Returns: |
|
save(dir_path='.', filename=[], filename_desc=[])¶Save the time features instance to a pickle file using the pickle module.
| Parameters: |
|
|---|
sort_features(sorting_variable='feature_type')¶Sort the features according to sorting_variable
| Parameters: |
|
|---|
sort_trials(sorting_variable='label', direction='ascend')¶Sort the data trial order given the sorting variable. Sort data_ori and data given the new trial order
| Parameters: |
|
|---|
time2sample(t_sec)¶Return the sample index from the time in seconds
| Parameters: |
|
|---|---|
| Returns: |
|
timefeatures.correlation_1d(vect_x, vect_y, method='pearson', transform_x=[], transform_y=[])¶Correlation measure between 1D arrays
| Parameters: |
|
|---|---|
| Returns: |
|
timefeatures.load_time_features(filepath)¶Load a time feature instance previously saved using the pickle module
| Parameters: |
|
|---|---|
| Returns: |
|
timefeatures.scale_data(data, scaling, feature_range=(0, 1))¶Scale the data using scikit-learn scalers
| Parameters: |
|
|---|---|
| Returns: |
|