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)
    brain = Brain(sw0.subject_id, hemi, sw0.surf, \
    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")

###
Ejemplo n.º 5
0
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)
    
Ejemplo n.º 6
0
    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")

###
    # 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)
        #
# 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)
    brain = Brain(sw0.subject_id, hemi, sw0.surf, config_opts=sw0.config_opts, subjects_dir=sw0.subjects_dir)