Cross-Temporal Representational Similarity Analysis (CTRSA)¶
neurora.ctrdm_cal module¶
a module for calculating the cross-temporal RDM based on EEG-like data
- neurora.ctrdm_cal.ctRDM(data, sub_opt=1, chl_opt=0, time_win=5, time_step=5)¶
Calculate CTRDMs for EEG-like data
- Parameters
data (array) – EEG/MEG data from a time-window. The shape of data must be [n_cons, n_subs, n_chls, n_ts]. n_cons, n_subs, n_chls & n_ts represent the number of conditions, the number of subjects, the number of channels and the number of time-points, respectively.
sub_opt (int 0 or 1. Default is 1.) – Return the subject-result or average-result. If sub_opt=0, return the average result. If sub_opt=1, return the results of each subject.
chl_opt (int 0 or 1. Default is 0.) – Caculate the CTRDMs for each channel or not. If chl_opt=1, calculate the CTRDMs for each channel. If chl_opt=0, calculate the CTRDMs after averaging the channels.
time_win (int. Default is 5.) – Set a time-window for calculating the CTRDM for different time-points. If time_win=10, that means each calculation process based on 10 time-points.
time_step (int. Default is 5.) – The time step size for each time of calculating.
- Returns
CTRDMs – Cross-Temporal RDMs. if chl_opt=1, the shape of CTRDMs is [n_subs, n_chls, int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, n_cons, n_cons] if chl_opt=0, the shape of CTRDMs is [n_subs, int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, n_cons, n_cons]
- Return type
array
neurora.ctrdm_corr module¶
a module for calculating the Similarity/Correlation Coefficient between two Cross-temporal RDMs
- neurora.ctrdm_corr.ctrdm_correlation_kendall(CTRDM1, CTRDM2)¶
Calculate the similarity based on Kendalls tau Correlation Coefficient between two CTRDMs
- Parameters
CTRDM1 (array [n_conditions, n_conditions]) – The CTRDM 1. The shape of CTRDM1 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
CTRDM2 (array [n_conditions, n_conditions]) – The CTRDM 2. The shape of CTRDM2 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
- Returns
corr – The Kendalls tau Correlation result. The shape of corr is [2], including a r-value and a p-value.
- Return type
array [r, p].
- neurora.ctrdm_corr.ctrdm_correlation_pearson(CTRDM1, CTRDM2)¶
Calculate the similarity based on Pearson Correlation Coefficient between two CTRDMs
- Parameters
CTRDM1 (array [n_conditions, n_conditions]) – The CTRDM 1. The shape of CTRDM1 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
CTRDM2 (array [n_conditions, n_conditions]) – The CTRDM 2. The shape of CTRDM2 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
- Returns
corr – The Pearson Correlation result. The shape of corr is [2], including a r-value and a p-value.
- Return type
array [r, p].
- neurora.ctrdm_corr.ctrdm_correlation_spearman(CTRDM1, CTRDM2)¶
Calculate the similarity based on Spearman Correlation Coefficient between two CTRDMs
- Parameters
CTRDM1 (array [n_conditions, n_conditions]) – The CTRDM 1. The shape of CTRDM1 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
CTRDM2 (array [n_conditions, n_conditions]) – The CTRDM 2. The shape of CTRDM2 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
- Returns
corr – The Spearman Correlation result. The shape of corr is [2], including a r-value and a p-value.
- Return type
array [r, p].
- neurora.ctrdm_corr.ctrdm_distance(CTRDM1, CTRDM2)¶
Calculate the similarity based on Euclidean Distance between two CTRDMs
- Parameters
CTRDM1 (array [n_conditions, n_conditions]) – The CTRDM 1. The shape of CTRDM1 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
CTRDM2 (array [n_conditions, n_conditions]) – The CTRDM 2. The shape of CTRDM2 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
- Returns
dist – The Euclidean Distance result.
- Return type
float.
- neurora.ctrdm_corr.ctrdm_similarity(CTRDM1, CTRDM2)¶
Calculate the similarity based on Cosine Similarity between two CTRDMs
- Parameters
CTRDM1 (array [n_conditions, n_conditions]) – The CTRDM 1. The shape of CTRDM1 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
CTRDM2 (array [n_conditions, n_conditions]) – The CTRDM 2. The shape of CTRDM2 must be [n_cons, n_cons]. n_cons represent the number of conidtions.
- Returns
similarity – The Cosine Similarity result.
- Return type
float
neurora.ctcorr_cal module¶
a module for calculating the cross-temporal similarity
- neurora.ctcorr_cal.ctsim_cal(data1, data2, sub_opt=1, chl_opt=0, time_win=5, time_step=5)¶
Calculate the Cross-Temporal Similarities between neural data under two conditions
- Parameters
data1 (array) – EEG/MEG/fNIRS/EEG-like data from a time-window under condition1. The shape of data1 must be [n_subs, n_chls, n_ts]. n_subs, n_chls, n_ts represent the number of conditions, the number of subjects, the number of channels and the number of time-points respectively.
data2 (array) – EEG/MEG/fNIRS/EEG-like data from a time-window under condition2. The shape of data2 must be [n_subs, n_chls, n_ts]. n_subs, n_chls, n_ts represent the number of conditions, the number of subjects, the number of channels and the number of time-points respectively.
sub_opt (int 0 or 1. Default is 1.) – Caculate the similarities for each subject or not. If sub_opt=0, calculating based on all data. If sub_opt=1, calculating based on each subject’s data, respectively.
chl_opt (int 0 or 1. Default is 0.) – Caculate the similarities for each channel or not. If chl_opt=0, calculating based on all channels’ data. If chl_opt=1, calculating based on each channel’s data respectively.
time_win (int. Default is 5.) – Set a time-window for calculating the similarities for different time-points. If time_win=5, that means each calculation process based on 10 time-points.
time_step (int. Default is 5.) – The time step size for each time of calculating.
- Returns
CTSimilarities – Cross-temporal similarities. If sub_opt=1 and chl_opt=1, the shape of CTSimilarities will be [n_subs, n_channels, int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, 2]. If sub_opt=1 and chl_opt=0, the shape of CTSimilarities will be [n_subs, int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, 2]. If sub_opt=0 and chl_opt=1, the shape of CTSimilarities will be [n_channels, int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, 2]. If sub_opt=0 and chl_opt=0, the shape of CTSimilarities will be [int((n_ts-time_win)/time_step)+1, int((n_ts-time_win)/time_step)+1, 2]
- Return type
array
- neurora.ctcorr_cal.ctsim_ctrdms_cal(CTRDMs, Model_RDM, method='spearman')¶
Calculate the Cross-Temporal Similarities between CTRDMs and a Coding Model RDM
- Parameters
CTRDMs (array) – The Cross-Temporal Representational Dissimilarity Matrices. The shape could be [n_ts, n_ts, n_cons, n_cons] or [n_subs, n_ts, n_ts, n_cons, n_cons] or [n_chls, n_ts, n_ts, n_cons, n_cons] or [n_subs, n_chls, n_ts, n_ts, n_cons, n_cons]. n_ts, n_cons, n_subs, n_chls represent the number of time-points, the number of conditions, the number of subjects and the number of channels, respectively.
Model_RDM (array [n_cons, n_cons].) – The Coding Model RDM.
method (string 'spearman' or 'pearson' or 'kendall' or 'similarity' or 'distance'. Default is 'spearman'.) – The method to calculate the similarities. If method=’spearman’, calculate the Spearman Correlations. If method=’pearson’, calculate the Pearson Correlations. If methd=’kendall’, calculate the Kendall tau Correlations. If method=’similarity’, calculate the Cosine Similarities. If method=’distance’, calculate the Euclidean Distances.
- Returns
CTSimilarities – Cross-temporal similarities. If method=’spearman’ or ‘pearson’ or ‘kendall’:
If the shape of CTRDMs is [n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_ts, n_ts, 2]. If the shape of CTRDMs is [n_subs, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_subs, n_ts, n_ts, 2]. If the shape of CTRDMs is [n_channels, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_channels, n_ts, n_ts, 2]. If the shape of CTRDMs is [n_subs, n_channels, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_subs, n_channels, n_ts, n_ts, 2].
- If method=’similarity’ or ‘distance’:
If the shape of CTRDMs is [n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_ts, n_ts]. If the shape of CTRDMs is [n_subs, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_subs, n_ts, n_ts]. If the shape of CTRDMs is [n_channels, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_channels, n_ts, n_ts]. If the shape of CTRDMs is [n_subs, n_channels, n_ts, n_ts, n_cons, n_cons], the shape of CTSimilarities will be [n_subs, n_channels, n_ts, n_ts].
- Return type
array
- neurora.ctcorr_cal.ctsim_drsa_cal(Model_RDMs, RDMs, method='spearman')¶
Calculate the Cross-Temporal Similarities between temporal model RDMs and temporal neural RDMs (dynamic-RSA)
- Parameters
Model_RDMs (array) – The Coding Model RDMs. The shape should be [n_ts, n_cons, n_cons]. n_ts and n_cons represent the number of time-points and the number of conditions, respectively.
RDMs (array) – The Representational Dissimilarity Matrices in time series. The shape could be [n_ts, n_cons, n_cons] or [n_subs, n_ts, n_cons, n_cons] or [n_channels, n_ts, n_cons, n_cons] or [n_subs, n_channels, n_ts, n_cons, n_cons]. n_ts, n_cons, n_subs, n_channels represent the number of time-points, the number of conditions, the number of subjects and the number of channels, respectively.
method (string 'spearman' or 'pearson' or 'kendall' or 'similarity' or 'distance'. Default is 'spearman'.) – The method to calculate the similarities. If method=’spearman’, calculate the Spearman Correlations. If method=’pearson’, calculate the Pearson Correlations. If methd=’kendall’, calculate the Kendall tau Correlations. If method=’similarity’, calculate the Cosine Similarities. If method=’distance’, calculate the Euclidean Distances.
- Returns
CTSimilarities – Cross-temporal similarities. If the shape of RDMs is [n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_ts, n_ts, 2]. If the shape of RDMs is [n_subs, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_subs, n_ts, n_ts, 2]. If the shape of RDMs is [n_chls, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_chls, n_ts, n_ts, 2]. If the shape of RDMs is [n_subs, n_chls, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_subs, n_chls, n_ts, n_ts, 2]. If the shape of RDMs is [n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_ts, n_ts]. If the shape of RDMs is [n_subs, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_subs, n_ts, n_ts]. If the shape of RDMs is [n_chls, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_chls, n_ts, n_ts]. If the shape of RDMs is [n_subs, n_chls, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_subs, n_chls, n_ts, n_ts].
- Return type
array
- neurora.ctcorr_cal.ctsim_rdms_cal(RDMs, method='spearman')¶
Calculate the Cross-Temporal Similarities based on RDMs in time series
- Parameters
RDMs (array) – The Representational Dissimilarity Matrices in time series. The shape could be [n_ts, n_cons, n_cons] or [n_subs, n_ts, n_cons, n_cons] or [n_chls, n_ts, n_cons, n_cons] or [n_subs, n_chls, n_ts, n_cons, n_cons]. n_ts, n_conditions, n_subs, n_chls represent the number of time-points, the number of conditions, the number of subjects and the number of channels, respectively.
method (string 'spearman' or 'pearson' or 'kendall' or 'similarity' or 'distance'. Default is 'spearman'.) – The method to calculate the similarities. If method=’spearman’, calculate the Spearman Correlations. If method=’pearson’, calculate the Pearson Correlations. If methd=’kendall’, calculate the Kendall tau Correlations. If method=’similarity’, calculate the Cosine Similarities. If method=’distance’, calculate the Euclidean Distances.
- Returns
CTSimilarities – Cross-temporal similarities. If the shape of RDMs is [n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_ts, n_ts, 2]. If the shape of RDMs is [n_subs, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_subs, n_ts, n_ts, 2]. If the shape of RDMs is [n_chls, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_chls, n_ts, n_ts, 2]. If the shape of RDMs is [n_subs, n_channels, n_ts, n_cons, n_cons] and method=’spearman’ or ‘pearson’ or ‘kendall’, the shape of CTSimilarities will be [n_subs, n_channels, n_ts, n_ts, 2]. If the shape of RDMs is [n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_ts, n_ts]. If the shape of RDMs is [n_subs, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_subs, n_ts, n_ts]. If the shape of RDMs is [n_chls, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_chls, n_ts, n_ts]. If the shape of RDMs is [n_subs, n_channels, n_ts, n_cons, n_cons] and method=’similarity’ or ‘distance’, the shape of CTSimilarities will be [n_subs, n_chls, n_ts, n_ts].
- Return type
array