This document outlines the workflows used at Simula for converting raw MRI data into finite element meshes suitable for FEniCS/FEniCSx simulations. It covers current software choices, specific user pipelines, dataset locations, and future development needs.
A summary of who is using what, serving as a point of contact for specific variations of the pipeline.
| Contact | Meshing Engine | Segmentation Source | Dataset / Repo | Key Notes |
|---|---|---|---|---|
| Ingvild | Ftetwild | FreeSurfer / SynthSeg | OpenNeuro ds004478 | Uses mri2mesh. Feature request: Node index tracking. |
| Andreas | SVMTK | FreeSurfer | SVMTK Repo | Standard SVMTK pipeline. |
| Henrik | Ftetwild | NeuroQuant | Biophysics Repo | Uses a config-file driven approach. Handles NeuroQuant labels (different from FS). |
| Cecile | Ftetwild | FreeSurfer / SynthSeg | CerebroSpinalFlow | Based on Marius Causemann's transport repo. |
| Timo / Jørgen | SVMTK / PyVista | FreeSurfer | Gonzo | SVMTK preferred for surface preprocessing (keeps sulci better than PyVista). |
Conversion of scanner output (typically DICOM) to research-standard formats (NIfTI).
- Tools:
dcm2niix(Standard), proprietary scanner tools. - Target Modalities:
- T1/T2: Structural anatomy (geometry).
- Look-Locker: T1 mapping.
- DTI: Diffusion Tensor Imaging (anisotropy tensors).
- fMRI/BOLD: Functional activation maps.
- FLAIR: Fluid-attenuated inversion recovery.
Aligning different image modalities (e.g., registering DTI to the T1 structural scan) or registering subjects to a common atlas (MNI).
- Greedy: Fast, effective for standard rigid/affine registration.
- ANTs: Gold standard for non-linear warping and complex registration.
- FSL FLIRT: Robust linear registration.
Classifying voxels into tissue types (White Matter, Gray Matter, CSF).
- Command:
recon-all - Pros: Industry standard, highly detailed cortical surfaces, separates hemispheres.
- Cons: Slow (hours), requires high-quality T1.
- Output:
aseg.mgz,lh.pial,rh.white.
- Command:
mri_synthsegandrecon-all-clinical - Pros: Fast (minutes), robust to domain shifts and lower resolution scans.
- Cons: Surfaces may lack the topological guarantees of FreeSurfer.
- Note: Also part of FreeSurfer.
- FastSurfer
- NextBrain
- GOUHFI
- SAM3
- NeuroQuant - This is a commercial tool used by Anders Dale
Converting voxel labels into triangular surface meshes (STL/PLY).
- SVMTK:
- Works well with output from Freesurfer. Provide fixes for issues introduced by Freesurfer
- FreeSurfer:
- Native extraction via
mri_tessellateormri_mc.
- Native extraction via
- PyVista:
- Uses VTK marching cubes. Good for visualization, but requires careful smoothing to avoid non-manifold artifacts in complex brain geometry.
Creating the tetrahedral mesh for FEniCS / FEniCSx.
- Implementations:
wildmeshing-python(Wrapper by Cecile or Marius).pytetwild(PyVista wrapper).- C++ Source.
- Pros: Extremely robust. Can mesh "dirty," self-intersecting, or non-manifold surfaces where other algorithms fail.
- Cons: Tricky to install. It is possible to install with
pipon linux x84 and mac arm (but not linux on arm, i.e docker on arm mac). - Note: They are also working on a new version, but this is not ready for us to use.
- Examples:
- Implementation: GitHub Link
- Pros:
- Wraps CGAL.
- Specifically designed for biomedical domains.
- Excellent utilities for surface repair and subdomain marking.
- Cons:
- Only maintained by Lars Magnus Valnes
- Tricky to install (conda is the best alternative)
- Examples:
Mapping physiological data from NIfTI images to the generated mesh.
- Workflow:
- Load NIfTI (via
nibabel). - Align coordinate systems (RAS vs LPS).
- Create FEniCS FunctionSpace (e.g., DG0 for voxels, CG1 for continuous fields).
- Probe/Interpolate values.
- Load NIfTI (via
- Applications:
- Tissue properties (conductivity, elasticity).
- DTI-based diffusion tensors.
- Concentration maps.
- Examples:
- https://github.com/jorgenriseth/gonzo
- Utility functions in scifem
A hypothetical workflow to go from raw scan to a Stokes + Advection-Diffusion simulation.
- Preprocessing:
- Convert DICOM to NIfTI (
dcm2niix).
- Convert DICOM to NIfTI (
- Segmentation:
- Run
mri_synthseg --i input.nii --o seg.nii(Fast, robust).
- Run
- Surface Extraction (PyVista):
- Extract isosurfaces for GM, WM, CSF and perhaps ventricles. Smooth surfaces with PyVista.
- Save output to
.plyfiles.
- Meshing (Ftetwild):
- Generate tetrahedral mesh from the cleaned surfaces using boolean (union) operations.
- Mark subdomains (Cell tags) and boundaries (Facet tags).
- Simulation (FEniCSx):
- Import XDMF mesh.
- Define function spaces.
- Solve Stokes equations (Fluid flow).
- Solve Advection-Diffusion (Transport).
- Gonzo: (GitHub: jorgenriseth/gonzo)
- OpenNeuro ds004478: Raw T1w and fMRI BOLD data.
- MNI152: Standard template for registration testing.
- csftracermodeling/csftracermodeling: Submitted code
- The Gonzo Dataset: Human Brain MRI Data of CSF Tracer Evolution Over 72h For Data-Integrated Simulations
- Ratbrain mesh
- jorgenriseth/mri2fem-multicompartment: v2.1
- meg-simula/optimal-transport-fenics: v1.0.1
- Software for Mathematical modeling of the human brain - from magnetic resonance images to finite element simulation
- Software and data for "Advection versus diffusion in brain ventricular transport"
- Example meshes for 'Human brain solute transport quantified by glymphatic MRI-informed biophysics during sleep and sleep deprivation'
- Software and data for "In-silico molecular enrichment and clearance of the human intracranial space"
- Software and data for "Stretch and flow at the gliovascular interface: high-fidelity modelling of the mechanics of astrocyte endfeet"
- Human intracranial pulsatility during the cardiac cycle: a computational modelling framework
- Supplementary material (code) for Are brain displacements and pressures within the parenchyma induced by surface pressure differences? A computational modelling study by E. Piersanti, M. E. Rognes, V. Vinje
- Uncertainty quantification of parenchymal tracer distribution using random diffusion and convective velocity fields (data sets)
- Mesh files for idealized and image-based periarterial and perivenous spaces
- mechanisms-behind-pvs-flow-v1.0
- geometrically-reduced-PVS-flow-v1.0
- MRI2FEM data set
- MRI2FEM book: paper, code
- MRI2FEM2 book: To be announced
- MariusCausemann/intracranialPulsation - Paper repo (Legacy FEnICS + multiphenics)
- MariusCausemann/brain-PVS-SAS-transport - Paper repo (Legacy FEnICS)
- gMRI2FEM - Tool for working with GMRI data (based on FEniCS, SVMTK and many other tools)
- pantarei - A collection of utilities for fluid flow modelling using FEniCS (legacy)
- Gonzo - Full pipline with dataset (based on gMRI2FEM)
- fenics-in-the-wild - Meshing with FtetWild
- scifem - Scientific finite element toolbox (also some biomedical) (FEniCSx)
- mri2mesh - Tools for converting images to mesh (PyVista + FEniCSx)
- bzapf/braintransport - Paper repo (Legacy FEniCS + dolfin-adjoint)
- cdaversin/CerebroSpinalFlow - Full pipeline in FEniCSx