else: data_min = data[data.nonzero()].min() return [data_min, data_max] print 'getting range' ranges = np.array([get_range(pfile) for pfile in pfiles]) dmin = ranges.min() dmax = ranges.max() print 'min=%.4f; max=%.4f' % (dmin, dmax) ### ### # Surface Viz for i, pfile in enumerate(pfiles): print pfile oprefix = path.join(odir, "C4_fstats_global_easythresh_surface_scan%i" % (i + 1)) sw = SurfWrap(name=factor, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = dmin sw.max = dmax sw.run(compilation="box") sw.montage(compilation="stick") ###
# Overlap overlap_lh = scan1_lh[:] * scan2_lh[:] overlap_rh = scan1_rh[:] * scan2_rh[:] ### ### # Plot overlap import code sw0 = SurfWrap() sw0.set_underlay() sw0.set_options() sw0.min = 0 sw0.max = 2 sw0.sign = "pos" oprefix = path.join(odir, "E_global_easythresh_surface_overlap") sw0.set_output(oprefix) scan1_surfs = {"lh": scan1_lh, "rh": scan1_rh} scan2_surfs = {"lh": scan2_lh, "rh": scan2_rh} overlap_surfs = {"lh": overlap_lh, "rh": overlap_rh} #code.interact(local=locals()) for hemi in sw0.hemis: print "visualize %s" % hemi # Bring up the beauty (the underlay)
data = img.get_data() data_max = data.max() if data_max == 0: data_min = data_max else: data_min = data[data.nonzero()].min() return [data_min, data_max] print 'getting range' ranges = np.array([ get_range(pfile) for pfile in pfiles ]) dmin = ranges.min() dmax = ranges.max() print 'min=%.4f; max=%.4f' % (dmin,dmax) ### ### # Surface Viz for i,pfile in enumerate(pfiles): print pfile oprefix = path.join(odir, "C4_fstats_global_easythresh_surface_scan%i" % (i+1)) sw = SurfWrap(name=factor, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = dmin; sw.max = dmax sw.run(compilation="box") sw.montage(compilation="stick") ###
data_max = data.max() if data_max == 0: data_min = data_max else: data_min = data[data.nonzero()].min() return [data_min, data_max] print "getting range" ranges = np.array([get_range(pfile) for pfile in pfiles]) dmin = ranges[ranges != 0].min() dmax = ranges[ranges != 0].max() print "min=%.4f; max=%.4f" % (dmin, dmax) ### ### # Surface Viz for i, pfile in enumerate(pfiles): print pfile oprefix = path.join(odir, "C2_global_perms_surface_scan%i" % (i + 1)) sw = SurfWrap(name=factor, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = dmin sw.max = dmax sw.run(compilation="box") sw.montage(compilation="stick") ###
data = img.get_data() data_max = data.max() if data_max == 0: data_min = data_max else: data_min = data[data.nonzero()].min() return [data_min, data_max] print 'getting range' ranges = np.array([ get_range(pfile) for pfile in pfiles ]) dmin = ranges[ranges!=0].min() dmax = ranges[ranges!=0].max() print 'min=%.4f; max=%.4f' % (dmin,dmax) ### ### # Surface Viz for i,pfile in enumerate(pfiles): print pfile oprefix = path.join(odir, "B_global_perms_surface_scan%i" % (i+1)) sw = SurfWrap(name=factor, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = dmin; sw.max = dmax sw.run(compilation="box") sw.montage(compilation="stick") ###
scan2_lh[scan2_lh>dmin] = 2 scan2_rh[scan2_rh>dmin] = 2 # Overlap overlap_lh = scan1_lh[:] * scan2_lh[:] overlap_rh = scan1_rh[:] * scan2_rh[:] ### ### # Plot overlap sw0 = SurfWrap() sw0.set_underlay() sw0.set_options() sw0.min = 1; sw0.max = 2; sw0.sign = "pos" oprefix = path.join(odir, "D_perms_surface_overlap") sw0.set_output(oprefix) scan1_surfs = {"lh": scan1_lh, "rh": scan1_rh} scan2_surfs = {"lh": scan2_lh, "rh": scan2_rh} overlap_surfs = {"lh": overlap_lh, "rh": overlap_rh} for hemi in sw0.hemis: print "visualize %s" % hemi # Bring up the beauty (the underlay) brain = Brain(sw0.subject_id, hemi, sw0.surf, \ config_opts=sw0.config_opts, \ subjects_dir=sw0.subjects_dir)
from os import path from surfwrap import SurfWrap obase = "/home2/data/Projects/CWAS/adhd200_rerun/cwas" comparisons = ["adhdc_vs_adhdi", "tdc_vs_adhdc", "tdc_vs_adhdi"] # GLOBAL! preproc = "global" for comparison in comparisons: print "group comparison: %s" % comparison # Input pfile distdir = path.join(obase, "%s_rois_random_k3200" % preproc) mdmrdir = path.join(distdir, "%s_gender+age+iq+mean_FD.mdmr" % comparison) pfile = path.join(mdmrdir, "log_pvals_%s.nii.gz" % comparison) # Output oprefix odir = path.join(mdmrdir, "images") if not path.exists(odir): os.mkdir(odir) oprefix = path.join(odir, path.basename(pfile).replace(".nii.gz", "")) # Surface Viz sw = SurfWrap(name=comparison, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = 1.3 sw.run() # import pysurfer # pysurfer = reload(pysurfer) # SurfWrap = pysurfer.SurfWrap
# Overlap top 15% between mdmr and glm lh_overlap = (lh_cwas_perc>0)*1 + (lh_glm_perc>0)*2 rh_overlap = (rh_cwas_perc>0)*1 + (rh_glm_perc>0)*2 ### ### # Plot top percentiles print "plot percentiles" sw0 = SurfWrap(hemis=['lh']) sw0.set_underlay() sw0.set_options() sw0.min = 1; sw0.max = 3; sw0.sign = "pos" oprefix = op.join(figdir, "B_surface_percentiles") sw0.set_output(oprefix) cwas_perc_surfs = {"lh": lh_cwas_perc} glm_perc_surfs = {"lh": lh_glm_perc} overlap_surfs = {"lh": lh_overlap} for hemi in sw0.hemis: print "visualize %s" % hemi ## MDMR #oprefix = op.join(figdir, "B_%s_percentiles_mdmr" % scans[i]) #sw0.set_output(oprefix) # #brain = Brain(sw0.subject_id, hemi, sw0.surf, \
# Overlap top 15% between mdmr and glm lh_overlap = (lh_cwas_perc > 0) * 1 + (lh_glm_perc > 0) * 2 rh_overlap = (rh_cwas_perc > 0) * 1 + (rh_glm_perc > 0) * 2 ### ### # Plot top percentiles print "plot percentiles" sw0 = SurfWrap(hemis=['lh']) sw0.set_underlay() sw0.set_options() sw0.min = 1 sw0.max = 3 sw0.sign = "pos" oprefix = op.join(figdir, "B_surface_percentiles") sw0.set_output(oprefix) cwas_perc_surfs = {"lh": lh_cwas_perc} glm_perc_surfs = {"lh": lh_glm_perc} overlap_surfs = {"lh": lh_overlap} for hemi in sw0.hemis: print "visualize %s" % hemi ## MDMR #oprefix = op.join(figdir, "B_%s_percentiles_mdmr" % scans[i]) #sw0.set_output(oprefix)
obase = "/home2/data/Projects/CWAS/adhd200_rerun/cwas" comparisons = ["adhdc_vs_adhdi", "tdc_vs_adhdc", "tdc_vs_adhdi"] # GLOBAL! preproc = "global" for comparison in comparisons: print "group comparison: %s" % comparison # Input pfile distdir = path.join(obase, "%s_rois_random_k3200" % preproc) mdmrdir = path.join(distdir, "%s_gender+age+iq+mean_FD.mdmr" % comparison) pfile = path.join(mdmrdir, "log_pvals_%s.nii.gz" % comparison) # Output oprefix odir = path.join(mdmrdir, "images") if not path.exists(odir): os.mkdir(odir) oprefix = path.join(odir, path.basename(pfile).replace(".nii.gz", "")) # Surface Viz sw = SurfWrap(name=comparison, infile=pfile, cbar="red-yellow", outprefix=oprefix) sw.min = 1.3 sw.run() # import pysurfer # pysurfer = reload(pysurfer) # SurfWrap = pysurfer.SurfWrap
# Overlap overlap_lh = scan1_lh[:] * scan2_lh[:] overlap_rh = scan1_rh[:] * scan2_rh[:] ### ### # Plot overlap import code sw0 = SurfWrap() sw0.set_underlay() sw0.set_options() sw0.min = 0 sw0.max = 2 sw0.sign = "pos" oprefix = path.join(odir, "E_global_easythresh_surface_overlap") sw0.set_output(oprefix) scan1_surfs = {"lh": scan1_lh, "rh": scan1_rh} scan2_surfs = {"lh": scan2_lh, "rh": scan2_rh} overlap_surfs = {"lh": overlap_lh, "rh": overlap_rh} # code.interact(local=locals()) for hemi in sw0.hemis: print "visualize %s" % hemi # Bring up the beauty (the underlay)