def test_vmin_none_in_dataview2d(): data = np.arange(np.product(volshape)).reshape(volshape, order='C') view = cortex.Volume2D(data, data + 1, subject=subj, xfmname=xfmname) cortex.quickshow(view) data = np.arange(nverts) view = cortex.Vertex2D(data, data + 1, subject=subj) cortex.quickshow(view)
def alphaplot(sub, dat, R2, thresh, fig, save, fname): light = cortex.Vertex2D(dat, R2, subject=sub, vmin=np.nanmin(dat), vmax=np.nanmax(dat), vmin2=thresh, vmax2=1, cmap='plasma_alpha') mfig = cortex.quickshow(light, with_curvature=True, fig=fig) sp.savefig(fname, dpi=300, facecolor='w', edgecolor='w', orientation='portrait', papertype=None, format='png', transparent=False, bbox_inches=None, pad_inches=0.1, frameon=None)
figure_out, 'flatmap_space-fsaverage_rsq-%0.2f_type-polar_angle_noalpha.svg' % rsq_threshold) print('saving %s' % filename) _ = cortex.quickflat.make_png(filename, images['polar_noalpha'], recache=True, with_colorbar=False, with_curvature=True, with_sulci=True) # vertex for rsq images['rsq'] = cortex.Vertex2D(masked_rsq.T, alpha_ones, 'fsaverage_gross', vmin=0, vmax=1.0, vmin2=0, vmax2=1.0, cmap='Reds_cov') #cortex.quickshow(images['rsq'],with_curvature=True,with_sulci=True) filename = os.path.join( figure_out, 'flatmap_space-fsaverage_rsq-%0.2f_type-rsquared.svg' % rsq_threshold) print('saving %s' % filename) _ = cortex.quickflat.make_png(filename, images['rsq'], recache=True, with_colorbar=True, with_curvature=True, with_sulci=True)
# plot rsq values in cortex alpha_ones = np.ones(alpha_mask.shape) alpha_ones[alpha_mask] = np.nan # seems stupid, but necessary to take ou the dtype object info (pycortex doesnt work otherwise) rsq = estimates['r2'] rsq = np.vstack(rsq) rsq = rsq[..., 0] # vertex for rsq images = {} images['rsq'] = cortex.Vertex2D(rsq, alpha_ones, 'fsaverage', vmin=0, vmax=1.0, vmin2=0, vmax2=1.0, cmap='Reds_cov') #images['rsq'] = cortex.Vertex(rsq,'fsaverage', # vmin=0, vmax=1.0, # cmap='Reds') #cortex.quickshow(images['rsq'],with_curvature=True,with_sulci=True) filename = os.path.join( figure_out, 'flatmap_space-fsaverage_rsq-%0.2f_type-rsquared.svg' % rsq_threshold) print('saving %s' % filename) _ = cortex.quickflat.make_png(filename, images['rsq'], recache=False, with_colorbar=True,
filename = os.path.join(figure_out,'flatmap_space-fsaverage_type-rsquared-normalized_visual.svg') print('saving %s' %filename) _ = cortex.quickflat.make_png(filename, images['rsq_visual_norm'], recache=False,with_colorbar=True,with_curvature=True,with_sulci=True) images['rsq_motor_norm'] = cortex.Vertex(rsq_motor_norm,'fsaverage_gross', vmin=0, vmax=1, cmap='Blues') cortex.quickshow(images['rsq_motor_norm'],with_curvature=True,with_sulci=True) filename = os.path.join(figure_out,'flatmap_space-fsaverage_type-rsquared-normalized_motor.svg') print('saving %s' %filename) _ = cortex.quickflat.make_png(filename, images['rsq_motor_norm'], recache=False,with_colorbar=True,with_curvature=True,with_sulci=True) images['rsq_combined'] = cortex.Vertex2D(rsq_visual_norm,rsq_motor_norm, subject='fsaverage_gross', vmin=0, vmax=1, vmin2=0,vmax2=1, cmap=col2D_name)#'PU_RdBu_covar') cortex.quickshow(images['rsq_combined'],with_curvature=True,with_sulci=True) filename = os.path.join(figure_out,'flatmap_space-fsaverage_type-rsquared-normalized_combined_bins-%d.svg'%n_bins) print('saving %s' %filename) _ = cortex.quickflat.make_png(filename, images['rsq_combined'], recache=False,with_colorbar=True,with_curvature=True,with_sulci=True) # correlation coeficient for each task images['R_visual_norm'] = cortex.Vertex(r_visual_norm,'fsaverage_gross', vmin=0, vmax=1, cmap='Reds') cortex.quickshow(images['R_visual_norm'],with_curvature=True,with_sulci=True) filename = os.path.join(figure_out,'flatmap_space-fsaverage_type-R-normalized_visual.svg')
import cortex import cortex.polyutils import numpy as np import matplotlib.pyplot as plt subject = 'S1' # In order to get the number of vertices in this subject's cortical surface # we have to load in their surfaces and get the number of points in each surfs = [cortex.polyutils.Surface(*d) for d in cortex.db.get_surf(subject, "fiducial")] # This is the total number of vertices in the left and right hemispheres num_verts = [s.pts.shape[0] for s in surfs] # Creating one random dataset that is basically a gradient across each # hemisphere based on vertex number test_data1 = np.hstack((np.arange(num_verts[0]), np.arange(num_verts[1]))) # Picking a different vertex in each hemisphere to create another fake # gradient away from that vertex second_verts = [n / 4 for n in num_verts] test_data2 = np.hstack((np.abs(np.arange(num_verts[0]) - second_verts[0]), np.abs(np.arange(num_verts[1]) - second_verts[1]))) # This creates a 2D Vertex object with both of our test datasets for the # given subject vertex_data = cortex.Vertex2D(test_data1, test_data2, subject) cortex.quickshow(vertex_data, with_colorbar=False) plt.show()
# define Vertex images #contains RGBA colors for each voxel in a volumetric dataset # vertex for polar angles images['polar'] = cortex.VertexRGB(rgb[..., 0].T, rgb[..., 1].T, rgb[..., 2].T, subject='fsaverage', alpha=alpha) # vertex for ecc images['ecc'] = cortex.Vertex2D(eccentricity.T, alpha * 10, 'fsaverage', vmin=0, vmax=10, vmin2=0, vmax2=1.0, cmap='BROYG_2D') #images['ecc'] = cortex.Vertex2D(eccentricity.T, rsq.T, 'fsaverage', # vmin=0, vmax=10, # vmin2=rsq_threshold, vmax2=1.0, cmap='BROYG_2D') # vertex for size images['size'] = cortex.dataset.Vertex2D(size.T, alpha * 10, 'fsaverage', vmin=0, vmax=10, vmin2=0, vmax2=1.0,