[ANN] Four new fMRI-related packages: CIFTI.jl, WatershedParcellation.jl, and more

Hi everyone, I’d like to announce four packages I’ve written that may be of interest to anyone working with surface-space representations of fMRI data in Julia.

First of all, there’s CIFTI.jl, a very basic and easy-to-use interface for reading and writing surface-space neuroimaging files of the CIFTI (Connectivity Informatics Technology Initiative) format.

Then the heavyweight package here is WatershedParcellation.jl. This package supplies a new implementation of a well-known method in the field, which is basically the application of the classic watershed image segmentation technique to the domain of surface-space fMRI. It’s based on the original MATLAB code from Evan Gordon and Tim Laumann from their 2016 paper “Generation and Evaluation of a Cortical Surface Area Parcellation.” The new implementation supplies these advantages:

  • very substantial speedups (probably less than 30 minutes total runtime, versus ~16 hours in the original MATLAB code)
  • better RAM usage so that it’s now feasible to run on a relatively modest hardware setup, or to run several instances in parallel in an HPC environment
  • easy to understand, flexible

And there are two more packages. Originally I just meant to make the WatershedParcellation code available in one big standalone package, but then when I started refactoring it for public use I realized that there were some pieces of it that could be really useful even outside of this specific application. That’s when I decided to branch things off into these two additional pacakges, which together provide the backbone for much of what WatershedParcellation does:

  • CorticalSurfaces.jl: A Julia package encapsulating the surface-space representation of the cerebral cortex
  • CorticalParcels.jl: A Julia package supplying abstractions and operations for efficiently working with parcels, or regions of interest, on a CorticalSurface

There’s one more package coming within the next couple of weeks, which will provide some GLMakie-based visualization utilities for all of the above. I’ve struggled to come up with a good name for it, though, so I welcome suggestions on that.

Thanks and I hope some people out there may find these packages useful.

7 Likes

Could you explain parcellation simply please?
Yeah… I should do a search.

Sure. A parcellation is basically just the segmentation of the brain into regions. It can be used as a dimensionality reduction technique, for example. There are many ways out there of doing that. WatershedParcellation.jl implements one particular well-known (in the field) method.

CorticalParcels.jl on the other hand provides more general-purpose tools for working with parcels/regions, irrespective of any particular parcellation method. It provides operations like rotation and resizing of regions, finding centroids, finding distances between regions, etc. You could even use these tools to build a new parcellation method, as I kind of demonstrate in WatershedParcellation.jl – because much of that is expressed just as a combination of those basic operations provided in CorticalParcels.jl.

Thankyou. I worked in medical imaging many years ago. The research group I was alongside at Kings was starting work on brain atlases. I guess the state of the art in that field has improved greatly due to early foundations.

For anyone working with surface space fMRI data (e.g. CIFTI and GIFTI files), I’d like to announce that I’ve finished up some substantial updates to my CIFTI.jl package mentioned above, and to related packages in my fMRI mini-ecosystem: CorticalSurfaces, CorticalParcels, and, especially, ObservableCortex. (WatershershedParcellation has not yet gotten an update but it will soon.)

Here’s a link to my original announcement about ObservableCortex, a set of routines that attempt to leverage my surface space abstractions from those other packages and expose the power of interactive/animated 3d plotting with Makie and Observables in this domain. When I first made this package a couple years ago, I didn’t know enough about how Observables actually worked in order to properly expose its interface, but I hope I’ve remedied that now. I’m also working on an set of much more extensive demos.

These packages came out of my time working with a neuroimaging research group from 2019 to 2024. When I made them a couple years ago, the idea was to build the set of tools that I wish I’d had from the beginning in my work there. Now I’ve taken the time to go back through the packages, update them, and hopefully bring them closer to full realization of their potential. I hope some people may find them useful.

To address what has changed. In all packages I’ve made method signatures more generic and have cleaned up dependencies. CIFTI and ObservableCortex have had the heaviest breaking updates and new features so I’ll list those here:

CIFTI v2.0.0

Breaking changes

  • Heavily revised error-handling throughout

New features

  • New accessors eltype, brainstructure, data, index_types, and istransposed
  • New examples/lazy.jl to demonstrate how you could use the package for lazy or incremental reading of CIFTI data (for example if the file(s) are too big or too numerous to fit in RAM)

ObservableCortex v0.4.0

Breaking changes

  • Renamed OrthographicView → Panel, OrthographicLayout → PanelLayout, and Montage.views → Montage.panels
  • Updated dependencies, especially CIFTI for v2.0, and CorticalSurfaces and CorticalParcels for v0.11
  • Made method signatures more generic where possible

New features

  • Montage now contains a plots component that stores a matrix of Makie.Mesh plots, which are accessible now by getindex(m::Montage, ...) (see README for more info)
  • plot!(m::Montage, ...) now accepts an Observable as the values to plot
  • Improved tests and extended demos (the latter still in progress)

Hey @myersm0 ! We have a bunch of folks who may be interested in this work from within JuliaHealth – we are active in the #health-and-medicine channel on the Julia Slack. Feel free to share over there too! Congrats on the new updates and releases!

Additionally, I’ll CC @cncastillo @Jakub_Mitura too!

1 Like