def plot_brainrsa_regions(img, threshold=None, background=get_bg_ch2(), type='r'): """ Plot the RSA-result regions by 3 cuts (frontal, axial & lateral) Parameters ---------- img : string The file path of the .nii file of the RSA results. threshold : None or int. Default is None. The threshold of the number of voxels used in correction. If threshold=n, only the similarity clusters consisting more than threshold voxels will be visible. If it is None, the threshold-correction will not work. background : Niimg-like object or string. Default is stuff.get_bg_ch2() The background image that the RSA results will be plotted on top of. type : string 'r' or 't' The type of result (r-values or t-values). """ imgarray = nib.load(img).get_fdata() if (imgarray == np.nan).all() == True: print("No Valid Results") else: if threshold != None: imgarray = nib.load(img).get_fdata() affine = get_affine(img) imgarray = correct_by_threshold(imgarray, threshold) img = nib.Nifti1Image(imgarray, affine) if type == 'r': plotting.plot_roi(roi_img=img, bg_img=background, threshold=0, vmin=0.1, vmax=1, title="Similarity", resampling_interpolation="continuous") if type == 't': plotting.plot_roi(roi_img=img, bg_img=background, threshold=0, vmin=-7, vmax=7, title="Similarity", resampling_interpolation="continuous") plt.show() return 0
def test_get_bg_ch2(self): output = get_bg_ch2() package_root = os.path.dirname(os.path.abspath(__file__)) self.assertEqual(output, os.path.join(package_root, 'template/ch2.nii.gz'))