Save the Results as a NIfTI file (for fMRI)¶
neurora.nii_save module¶
a module for saving the RSA results in a .nii file for fMRI
- neurora.nii_save.corr_save_nii(corrs, affine, filename=None, corr_mask='/Users/zitonglu/opt/anaconda3/lib/python3.9/site-packages/neurora/template/HarvardOxford-cort-maxprob-thr0-1mm.nii.gz', size=[60, 60, 60], ksize=[3, 3, 3], strides=[1, 1, 1], p=1, r=0, correct_method=None, clusterp=0.05, smooth=True, plotrlt=True, img_background=None)¶
Save the searchlight correlation coefficients as a NIfTI file for fMRI
- Parameters
corrs (array) – The similarities between behavioral data and fMRI data for searchlight. The shape of RDMs is [n_x, n_y, n_z, 2]. n_x, n_y, n_z represent the number of calculation units for searchlight along the x, y, z axis and 2 represents a r-value and a p-value.
affine (array or list) – The position information of the fMRI-image array data in a reference space.
filename (string. Default is None - 'rsa_result.nii'.) – The file path+filename for the result .nii file. If the filename does not end in “.nii”, it will be filled in automatically.
corr_mask (string. Default is get_HOcort().) – The filename of a mask data for correcting the RSA result. It can just be one of your fMRI data files in your experiment for a mask file for ROI. If the corr_mask is a filename of a ROI mask file, only the RSA results in ROI will be visible.
size (array or list [nx, ny, nz]. Default is [60, 60, 60].) – The size of the fMRI-img in your experiments.
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.
strides (array or list [sx, sy, sz]. Default is [1, 1, 1].) – The strides for calculating along the x, y, z axis.
p (float. Default is 1.) – The threshold of p-values. Only the results those p-values are lower than this value will be visible.
r (float. Default is 0.) – The threshold of r-values. Only the results those r-values are higher than this value will be visible.
correct_method (None or string 'FWE' or 'FDR' or 'Cluster-FWE' or 'Cluster-FDR'. Default is None.) – The method for correcting the RSA results. If correct_method=’FWE’, here the FWE-correction will be used. If correct_methd=’FDR’, here the FDR-correction will be used. If correct_method=’Cluster-FWE’, here the Cluster-wise FWE-correction will be used. If correct_methd=’Cluster-FDR’, here the Cluster-wise FDR-correction will be used. If correct_method=None, no correction. If correct_method=None, no correction. Only when p<1, correct_method works.
clusterp (float. Default is 0.05.) – The threshold of p-value for cluster-wise correction. Only when correct_method=’Cluster-FDR’ or ‘Cluster-FWE’, clusterp works.
smooth (bool True or False. Default is True.) – Smooth the RSA result or not.
plotrlt (bool True or False.) – Plot the RSA result automatically or not.
img_background (None or string. Default if None.) – The filename of a background image that the RSA results will be plotted on the top of it. If img_background=None, the background will be ch2.nii.gz. Only when plotrlt=True, img_background works.
- Returns
img – The array of the correlation coefficients map. The shape is [nx, ny, nz]. nx, ny, nz represent the size of the fMRI-img.
- Return type
array
Notes
A result .nii file of searchlight correlation coefficients will be generated at the corresponding address of filename.
- neurora.nii_save.stats_save_nii(stats, affine, filename=None, corr_mask='/Users/zitonglu/opt/anaconda3/lib/python3.9/site-packages/neurora/template/HarvardOxford-cort-maxprob-thr0-1mm.nii.gz', size=[60, 60, 60], ksize=[3, 3, 3], strides=[1, 1, 1], p=0.05, correct_method=None, clusterp=0.05, smooth=False, plotrlt=True, img_background=None)¶
Save the searchlight RSA statistical results as a NIfTI file for fMRI
- Parameters
stats (array) – The statistical results between behavioral data and fMRI data for searchlight. The shape of RDMs is [n_x, n_y, n_z, 2]. n_x, n_y, n_z represent the number of calculation units for searchlight along the x, y, z axis and 2 represents a t-value and a p-value. If the filename does not end in “.nii”, it will be filled in automatically.
affine (array or list) – The position information of the fMRI-image array data in a reference space.
filename (string. Default is None - 'rsa_result.nii'.) – The file path+filename for the result .nii file.
corr_mask (string) – The filename of a mask data for correcting the RSA result. It can just be one of your fMRI data files in your experiment for a mask file for ROI. If the corr_mask is a filename of a ROI mask file, only the RSA results in ROI will be visible.
size (array or list [nx, ny, nz]. Default is [60, 60, 60].) – The size of the fMRI-img in your experiments.
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.
strides (array or list [sx, sy, sz]. Default is [1, 1, 1].) – The strides for calculating along the x, y, z axis.
p (float. Default is 0.05.) – The threshold of p-values. Only the results those p-values are lower than this value will be visible.
correct_method (None or string 'FWE' or 'FDR' or 'Cluster-FWE' or 'Cluster-FDR'. Default is None.) – The method for correcting the RSA results. If correct_method=’FWE’, here the FWE-correction will be used. If correct_methd=’FDR’, here the FDR-correction will be used. If correct_method=’Cluster-FWE’, here the Cluster-wise FWE-correction will be used. If correct_methd=’Cluster-FDR’, here the Cluster-wise FDR-correction will be used. If correct_method=None, no correction. Only when p<1, correct_method works.
clusterp (float. Default is 0.05.) – The threshold of p-value for cluster-wise correction. Only when correct_method=’Cluster-FDR’ or ‘Cluster-FWE’, clusterp works.
smooth (bool True or False. Default is False.) – Smooth the RSA result or not.
plotrlt (bool True or False. Default is True.) – Plot the RSA result automatically or not.
img_background (None or string. Default if None.) – The filename of a background image that the RSA results will be plotted on the top of it. If img_background=None, the background will be ch2.nii.gz. Only when plotrlt=True, img_background works.
- Returns
img – The array of the statistical results t-values map. The shape is [nx, ny, nz]. nx, ny, nz represent the size of the fMRI-img.
- Return type
array
Notes
A result .nii file of searchlight statistical results will be generated at the corresponding address of filename.