Skip to content

RFP: SurfaceImage API #936

Open
Open
@effigies

Description

@effigies

When operating on or plotting surface data, generally you will need two things:

  1. A data array containing a scalar or vector at loci sampled over a surface
  2. A description of that surface, typically a mesh (vertices and faces)

This mirrors roughly the data+affine model of SpatialImage. Unlike most SpatialImages, we cannot expect data to be placed in the same file as the geometric description. Additionally, while the data is generally tied to the mesh, the specific coordinates are often considered mutable, at least when it comes to plotting.

From talking with the nilearn team, they are uninterested in proposing any new data structures. namedtuples of ndarrays can summarize their goal:

surface = namedtuple('surface', ['mesh', 'data'])
mesh = namedtuple('mesh', ['vertices', 'triangles'])

So you would expect the following:

mesh = surf.mesh
data = surf.data
vertices = mesh.vertices
triangles = mesh.triangles

An alternative approach they considered is using GiftiImage as their base object, which has a definite API they can count on, and other formats would be internally built into GiftiImages. In my opinion, turning the FreeSurfer IO (which gets you tuples of ndarrays, close to their preferred API) into a FS-GIFTI conversion would be massive overkill. The end result is a pretty unwieldy mirror of the XML structure.

It would be ideal if we could come up with a coherent but simple API, which I am provisionally dubbing a SurfaceImage that the various surface formats could implement. We should reach out to various projects which make use of surfaces to see what use cases need to be supported. I will try to come up with a list of contacts tomorrow, but I want to send this tonight before it sits in my open tabs for another week.

Related: nilearn/nilearn#2171


This is a delayed write-up from nilearn dev days, which is now a couple months gone, so my deepest apologies for both the delay and the inevitable failures of memory.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions