def visualize_colorbar(savedir, min=0.75, max=1.0): gl.resetdefaults() gl.minmax(0, min, max) gl.colorname(0, colorname) gl.opacity(0, 0) gl.colorbarposition(1) gl.savebmp(os.path.join(savedir, 'colorbar.png'))
def visualize_axial(niidir, savedir, min=0.75, max=1.0): gl.viewaxial(1) for method in ['grad', 'cam']: for network in ['Vis', 'SomMot', 'DorsAttn', 'SalVentAttn', 'Limbic', 'Cont', 'Default']: for gender in ['female', 'male']: gl.overlayload(os.path.join(niidir, 'network', 'saliency_{}_{}_top20_{}_lh'.format(method, gender, network))) gl.overlayload(os.path.join(niidir, 'network', 'saliency_{}_{}_top20_{}_rh'.format(method, gender, network))) gl.minmax(1, min, max) gl.minmax(2, min, max) gl.colorname(1, colorname) gl.colorname(2, colorname) gl.savebmp(os.path.join(savedir, '{}_{}_{}_axial.png'.format(method, network, gender))) gl.overlaycloseall()
def visualize_sagittal(niidir, savedir, min=0.75, max=1.0): for hemisphere in ['lh', 'rh']: if hemisphere =='lh': gl.clipazimuthelevation(0.49, 90, 0) elif hemisphere =='rh': gl.clipazimuthelevation(0.49, 270, 0) for network in ['Vis', 'SomMot', 'DorsAttn', 'SalVentAttn', 'Limbic', 'Cont', 'Default']: for gender in ['female', 'male']: gl.overlayload(os.path.join(niidir, 'network', 'saliency_{}_top20_{}_{}'.format(method, gender, network, hemisphere))) gl.minmax(1, min, max) gl.colorname(1, colorname) gl.viewsagittal(1) gl.savebmp(os.path.join(savedir, '{}_{}_sagittal_{}_lt.png'.format(network, gender, hemisphere))) gl.viewsagittal(0) gl.savebmp(os.path.join(savedir, '{}_{}_sagittal_{}_rt.png'.format(network, gender, hemisphere))) gl.overlaycloseall()
networks_names=['DMN','SMOTOR','VISUAL','AUDIT','ECN_L','ECN_R'] netfile_sufx= ['_Group1X','_Group2L','_Group3R','_Group4N'] for net in networks_names: savefolder=FILESPATH + '\\' + net + '\\' for i in netfile_sufx: FILENAME=net+i SEEDFILENAME=net+"_seed" gl.overlaycloseall() gl.overlayload(FILENAME) gl.overlayload(SEEDFILENAME) gl.colorname (2,"3blue") #gl.opacity(1,50) # changing view ---------------------- gl.azimuthelevation(140,20) ktime= 1 ksteps= 72 for x in range(0, ksteps): gl.azimuthelevation(140+(x*5),20) gl.wait(ktime) if x < 10: gl.savebmp(savefolder + FILENAME + '_0' + str(x)+'.png') else: gl.savebmp(savefolder + FILENAME + '_' + str(x)+'.png')
# %% General---------------------- gl.backcolor(255, 255, 255) # %% background image ---------------------- gl.loadimage('mni152') # %% overlay ---------------------- FILESPATH = 'D:\\GD_UNICAMP\\IC_NeuroFisica\\Projetos\\fMRI_TLE_2020\\Seed_based_analysis' os.chdir(FILESPATH) #networks_names=['DMN','SMOTOR','VISUAL','AUDIT','DAN'] networks_names = ['DAN_R', 'DAN_L'] netfile_sufx = ['_Group1X', '_Group2L', '_Group3R', '_Group4N'] for net in networks_names: SEEDFILENAME = net + '_seed' for sufx in netfile_sufx: FILENAME = net + sufx gl.overlaycloseall() gl.overlayload(FILENAME) gl.overlayload(SEEDFILENAME) gl.colorname(2, "3blue") gl.azimuthelevation(0, 90) gl.savebmp(FILESPATH + '\\' + FILENAME)
'//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/oldadult/spmT_0001.nii' ] #OA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/oldadult/spmT_0002.nii'] #OA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/oldadult/spmT_0003.nii'] #OA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/oldadult/spmT_0004.nii'] #OA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/oldadult/spmT_0005.nii'] gl.overlayload(OA_filename[0]) gl.minmax(1, 1, 5) gl.colorname(1, "8redyell") gl.opacity(1, 80) #gl.mosaic('l+ h -0.3 v -0.1 a 55 s x r 0') gl.mosaic('a 55') gl.colorbarposition(0) #gl.linewidth(5) gl.savebmp(OA_filename[0]) gl.loadimage( '//cifs.rc.ufl.edu/ufrc/rachaelseidler/tfettrow/Crunch_Code/MR_Templates/MNI_2mm.nii' ) YA_filename = [ '//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/youngadult/spmT_0001.nii' ] #YA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/youngadult/spmT_0002.nii'] #YA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/youngadult/spmT_0003.nii'] #YA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/youngadult/spmT_0004.nii'] #YA_filename = ['//cifs.rc.ufl.edu/ufrc/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/Level2_Results/MRI_files/05_MotorImagery/youngadult/spmT_0005.nii'] gl.overlayload(YA_filename[0]) gl.minmax(1, 1, 5) gl.colorname(1, "8redyell")
rois_to_plot = ['neurosynth_acc_gmMasked', 'neurosynth_dlpfc_left_gmMasked', 'neurosynth_dlpfc_right_gmMasked'] # rois_to_plot = ['neurosynth_acc_mask', 'neurosynth_dlpfc_left_mask', 'neurosynth_dlpfc_right_mask'] # rois_to_plot = ['left_dlpfc', 'right_dlpfc', 'left_acc', 'right_acc'] ###################################### gl.loadimage('//exasmb.rc.ufl.edu/blue/rachaelseidler/tfettrow/Crunch_Code/MR_Templates/MNI_2mm.nii') gl.opacity(1,1) ###################################### # rois_plotted=1; # this_index=0; for this_roi in rois_to_plot: # gl.loadimage('//exasmb.rc.ufl.edu/blue/rachaelseidler/tfettrow/Crunch_Code/MR_Templates/MNI_2mm.nii') # gl.opacity(1,10) # gl.mosaic('a -36 -32 -28 -24 -20 -16 -10 -6 -2; 2 6 10 14 18 22 26 30 34; 38 42 46 50 54 58 62 66 70') # gl.mosaic("A R 0 C R 0 S R 0; A R -0 C R -0 S R -0"); gl.mosaic("A R 0"); gl.overlayload("//exasmb.rc.ufl.edu/blue/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/ROIs/"+this_roi) #gl.minmax(0,.01,.01) gl.colorbarposition(0) gl.colornode(1,2,255,0,0,255,255) # blue gl.colornode(2,2,255,255,0,0,255) # red gl.colornode(3,2,255,0,255,0,255) # green # gl.colornode(4,2,255,0,88,0,255) #darkgreen gl.backcolor(255,255,255) gl.savebmp("//exasmb.rc.ufl.edu/blue/rachaelseidler/share/FromExternal/Research_Projects_UF/CRUNCH/MiM_Data/ROIs/"+this_roi)
gl.minmax(1, 0, 3) gl.minmax(2, 0, 3) gl.colorname(1, '1red') gl.colorname(2, '3blue') output_dir_path = os.path.join(analysis_path, 'imageSequenceFolders', 'pVal_inv_sig_InDe') if not os.path.exists(output_dir_path): os.mkdir(output_dir_path) y_min = -13.15 y_max = 0 y_step = 0.05 y = y_min count = 0 while y <= y_max: print(y) count = count + 1 print(count) gl.orthoviewmm(0, y, -4) gl.view(2) gl.linewidth(0) gl.colorbarposition(0) filepath = os.path.join(output_dir_path, 'imagenew' + '_' + str(round(count)).rjust(3, '0')) + '_' + str(y) gl.savebmp(filepath) y = y + y_step
OAi_filenames=['C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/OAi_Flat', \ 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/OAi_Low', \ 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/OAi_Med', \ 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/OAi_Hard' ] for this_index in range(0, len(OAi_filenames)): gl.overlaycloseall() gl.overlayload(OAi_filenames[this_index]) gl.minmax(1, 0, 5) gl.colorname(1, "8redyell") gl.opacity(1, 80) #gl.mosaic('l+ h -0.3 v -0.1 a 55 s x r 0') gl.mosaic('a 55') gl.colorbarposition(0) #gl.linewidth(5) gl.savebmp(OAi_filenames[this_index]) # YA_filenames=['C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/YA_Flat', \ # 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/YA_Low', \ # 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/YA_Med', \ # 'C:/Users/tfettrow/Dropbox (UFL)/CrunchReview/Tables_and_Figs/YA_Hard' ] # for this_index in range(0,len(YA_filenames)): # gl.overlaycloseall() # gl.overlayload(YA_filenames[this_index]) # gl.minmax(1, 0, 5) # gl.colorname (1,"8redyell") # gl.opacity(1,80) # #gl.mosaic('l+ h -0.3 v -0.1 a 55 s x r 0') # gl.mosaic('a 55') # gl.colorbarposition(0)