Calculate the Neural Pattern Similarity (NPS)

neurora.nps_cal module

a module for calculating the neural pattern similarity based on neural data

neurora.nps_cal.nps(data, time_win=5, time_step=5, sub_opt=1)

Calculate the Neural Representational Similarity (NPS) for EEG-like data

Parameters
  • data (array) – The EEG-like neural data. The shape of data must be [2, n_subs, n_trials, n_chls, n_ts]. 2 presents 2 different conditions. n_subs, n_trials, n_chls & n_ts represent the number of subjects, the number of trials, the number of channels & the number of time-points, respectively.

  • time_win (int. Default is 5.) – Set a time-window for calculating the NPS for different time-points. If time_win=5, that means each calculation process based on 5 time-points.

  • time_step (int. Default is 5.) – The time step size for each time of calculating.

  • sub_opt (int 0 or 1. Default is 1.) – Calculate the NPS for each subject or not. If sub_opt=0, calculate the NPS based on all data. If sub_opt=1, calculate the NPS based on each subject’s data

Returns

nps – The EEG-like NPS. If sub_opt=0, the shape of NPS is [n_chls, int((n_ts-time_win)/time_step)+1, 2]. If sub_opt=1, the shape of NPS is [n_subs, n_chls, int((n_ts-time_win)/time_step)+1, 2]. 2 representation a r-value and a p-value.

Return type

array

neurora.nps_cal.nps_fmri(fmri_data, ksize=[3, 3, 3], strides=[1, 1, 1])

Calculate the Neural Representational Similarity (NPS) for fMRI data (searchlight)

Parameters
  • fmri_data (array) – The fmri data. The shape of fmri_data must be [2, n_subs, nx, ny, nz]. 2 presents 2 different conditions. nx, ny, nz represent the size of fMRI-img, respectively.

  • ksize (array or list [kx, ky, kz]. Default is [3, 3, 3].) – The size of the calculation unit for searchlight. kx, ky, kz represent the number of voxels along the x, y, z axis. kx, ky, kz should be odd.

  • strides (array or list [sx, sy, sz]. Default is [1, 1, 1].) – The strides for calculating along the x, y, z axis.

Returns

nps – The fMRI NPS for searchlight. The shape of NPS is [n_subs, n_x, n_y, n_z, 2]. n_subs, n_x, n_y, n_z represent the number of subjects, the number of calculation units for searchlight along the x, y, z axis. 2 represent a r-value and a p-value.

Return type

array

Notes

The size of the calculation units should at least be [3, 3, 3].

neurora.nps_cal.nps_fmri_roi(fmri_data, mask_data)

Calculate the Neural Representational Similarity (NPS) for fMRI data for ROI

Parameters
  • fmri_data (array) – The fmri data. The shape of fmri_data must be [2, n_subs, nx, ny, nz]. 2 presents 2 different conditions. n_subs, nx, ny, nz represent the number of channels & the size of fMRI-img, respectively.

  • mask_data (array [nx, ny, nz].) – The mask data for region of interest (ROI) The size of the fMRI-img. nx, ny, nz represent the number of voxels along the x, y, z axis

Returns

subNPS – The fMRI NPS for ROI. The shape of NPS is [n_subs, 2]. n_subs represents the number of subjects. 2 represents a r-value and a p-value.

Return type

array

Notes

The size of the calculation units should at least be [3, 3, 3].