Pycortex: an interactive surface visualizer for fMRI

James S. Gao, Alexander G. Huth, Mark D. Lescroart, Jack L. GallantFrontiers Neuroinformatics 2015 · DOI

Introduction

Functional Magnetic Resonance Imaging (fMRI) generates vast amounts of volumetric data. However, because the human cerebral cortex is essentially a folded 2D sheet, standard visualization techniques often fall short. Traditional "slice" views (see Figure 1) hide significant portions of the data, while static 3D renders struggle to display activity buried deep within cortical sulci. Furthermore, "vertex-based mapping"—the standard for most tools—often under-samples data, leading to aliasing and blurring, particularly in high-resolution 7T scans.

Standard axial slice view of fMRI activation.

The Pycortex Approach

Pycortex is an open-source Python toolbox designed to overcome these limitations through high-fidelity, interactive web-based displays. Its core innovation is pixel-based mapping. Unlike traditional methods that interpolate values between mesh vertices, Pycortex utilizes GPU shaders to sample the functional volume for every individual pixel on the screen. This ensures that the resulting brain maps (see Figure 2) maintain the highest possible resolution and are "true-to-form."

High-fidelity cortical surface visualization generated by Pycortex.

Beyond mapping, Pycortex offers:

  • Thickness Sampling: Averaging multiple samples across the cortical mantle to capture distributed activity.
  • WebGL Integration: Generating interactive 3D views that run in standard web browsers, facilitating easy data sharing without specialized software.
  • Unified Workflow: Integrating tools like Freesurfer, Blender, and FSL into a cohesive Python API.

Key Insights and Results

A standout feature of Pycortex is its ability to animate transitions between folded anatomical states, inflated brains, and 2D flatmaps. This helps researchers maintain a clear mental link between 3D anatomy and flattened representations. By offloading complex projections to the GPU, the software achieves real-time performance.

Qualitative results show that pixel-based mapping effectively eliminates the "jagged" artifacts common in older systems. Additionally, the tool is highly accessible; a fully interactive web visualization can be generated with just three lines of Python code. The tool also supports 2D colormaps for comparing datasets and allows for ROI definition using standard vector graphics software.

Limitations and Future Work

While Pycortex excels at visualization, it is not a standalone preprocessing suite and relies on external tools for segmentation and alignment. At its release, WebGL stability was a concern for mobile devices, though browser standards have since matured. Future developments aim to support ECoG and EEG data, alongside more complex interactive plugins for real-time data exploration.

Summary updated

BibTeX
@article{gao2015pycortex,
  author = {James S. Gao and Alexander G. Huth and Mark D. Lescroart and Jack L. Gallant},
  title = {{Pycortex: an interactive surface visualizer for fMRI}},
  journal = {Frontiers Neuroinformatics},
  year = {2015},
  doi = {10.3389/fninf.2015.00023},
}
Figure