gallantlab / pycortex

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

Visualizing ROIs #545

Open vpzgithub opened 2 months ago

vpzgithub commented 2 months ago

Hey, Pycortex is a fantastic tool, but I'm currently facing some challenges. Simply put, I'm looking to draw specific ROIs on the unfolded cortical surface, such as certain brain areas from the AAL atlas. I would like to ask for your advice on how to draw these ROI outlines. This is because I want to show others which brain areas my data points belong to, those displayed on the unfolded map. I understand that I might need to use software like Inkscape, but I'm not clear about the overall process. Could you please clarify the general workflow for me? Thank you very much for your assistance!

yinxu1996 commented 2 months ago

I have the same problem.

candytaco commented 1 month ago

The short of adding an ROI is to:

  1. add the ROI-defining data to the overlays.svg file: v = cortex.Volume(<data>, <subject>, <transform>) or if you have vertex-defined data v = cortex.Vertex(<data>, <subject>) cortex.add_roi(v, name = '<your ROI name>', open_inkscape = True)

    • note when open_inkscape is true, pycortex will automatically open inkscape for you after this method call, otherwise you will need to manually navigate to the subject directory and open the overlays.svg file
  2. Draw the ROI.

    • Inside the overlays.svg file, the data from step 1 will be in the data layer, inside a sublayer with the name that was passed to cortex.add_roi.
    • Inside the rois/shapes sublayer, there will be an empty layer with the same name.
    • Use the pen tool to draw the ROI boundary (ies) inside this sublayer inside roi/shapes.
    • You can draw as many shapes as need in this layer - all shapes will be treated as part of this ROI.
    • You can also rename the ROI by changing the sublayer name.
    • Shapes can go off the edge of the flatmap - pycortex will ignore those regions.
    • Shapes need to be closed, and can overlap other ROIs.
    • Save the file.
  3. To have the new ROI show up, when calling cortex.quickflat or cortex.webgl methods for the first time after adding ROIs, add the recache = True argument to the method call, e.g. cortex.webgl.show(<data>, recache = True).