Skip to content

General instructions for creating Pycortex Flatmaps

Aria Wang edited this page Oct 18, 2023 · 7 revisions

Cut the cortical surface to make the flat map

  1. Set environement Variables of $SUBJECTS_DIR. e.g. .../NSD/derivatives/freesurfer_pycortex
  2. In terminal, for specific subject, e.g., subject subj01, run
tksurfer subj01 lh inflated

Follow instruction on this page. Try to mimic your cut to this brain viewer to maximize visual cortex visibility. After the cuts, a patch should be save to the $SUBJECTS_DIR/{SUBJECTS}/surf directory.

  1. Go to that direcotry and run (e.g. for the left hemi)
mris_flatten -w 10 lh.full.patch.3d lh.full.flat.patch.3d
  1. After the lh.full.flat.patch.3d is generated, we can use pycortex to import them and make ROIs. For example,
cortex.freesurfer.import_flat('subj01', 'full')

Drawing ROIs

  1. Put functional localizer data into a local folder. (e.g. ./roi_data/subj01/floc-bodies.nii.gz)
  2. cd src, then run make_ROI.sh to reslice ROIs in functional space and also project to surface.
  3. Run
python make_ROI.py --roi-format 'surf'

to call pycortex, which opens Inkscape so that you can draw the ROIs. After the python file is run, Inkscape will automatically open with activation related to one ROI showing on the flatmap (as shown in the screenshot below). The buttons in red square are what you need to click to get into drawing mode and selection mode. The red boundary on the flatmap shows how an ROI can be drawn. After the boundary is drawn, it should be in the layer in rois > shapes. The boundary should appear/disappear while you click the eye symbol. After each ROI is drawn, click save on the right side bar, close the application window, and a new ROI related activation will show up. Repeat the process until all ROIs are drawn.

inkscape

Visualize results on Pycortex

Run visualize_in_pycortex.py to make volumes out of data and visualize them in the interactive WebGL Viewer.

Clone this wiki locally