gallantlab / pycortex

Pycortex is a python-based toolkit for surface visualization of fMRI data
https://gallantlab.github.io/pycortex
BSD 2-Clause "Simplified" License
585 stars 137 forks source link

Adding ROIs to flatmap plotted using matplotlib #324

Closed drorcohengithub closed 5 years ago

drorcohengithub commented 5 years ago

Hello guys,

Cheers for the awesome work!

Sometimes I need more control over my plots so I break down the plotting routines. For example:

get the surface curv_vertices = cortex.db.get_surfinfo(V.subject) # (V is the volume to plot)

get the surface image curv_arr, _ = cortex.quickflat.make_flatmap_image(curv_vertices)

can't remember why we need this, but we do

mask4curv = np.isnan(curv_arr)
curv_arr = np.where(curv_arr > 0, 0.5, 0.25)
curv_arr[mask4curv] = np.nan

the actual data to plot arr, ext = cortex.quickflat.make_flatmap_image(V,sampler = 'nearest') create a large figure figh = plt.figure(figsize = (20,20))
plot curvature as first layer hc = plt.imshow(curv_arr, cmap='Greys_r', vmin=0, vmax=1)

plot actual data hd = plt.imshow(arr,alpha = 0.5,vmin=-0.1, vmax=0.4, cmap = 'gnuplot');

*Now I'd like to overlay the ROIs on top of this.* I tried to add:

cortex.quickflat.composite.add_rois(figh, V)

But it complains about the 'extent':

You must specifyextentsargument if you have not yet plotted a data flatmap!

Now I can probably hack something to figure out the 'extents', but I am feeling like I overlooked something obvious.

Suggestions?

marklescroart commented 5 years ago

I strongly suggest you check out the pycortex gallery and the advanced compositing example

drorcohengithub commented 5 years ago

Ah I missed it. Thanks mate.