Madym: A C++ toolkit for quantitative DCE-MRI analysis

In dynamic contrast-enhanced magnetic resonance imaging (DCE-MRI) a sequence of MRI images are acquired to measure the passage of a contrast-agent within a tissue of interest. Quantitative DCE-MRI (DCE-MRI), in which one or more tracer-kinetic models are fitted to the contrast-agent concentration time-series, enables the estimation of clinically useful parameters of tissue microvasculature (Tofts et al., 1999).

Madym is a C++ toolkit for quantitative DCE-MRI analysis developed at the University of Manchester. It comprises a set of command line tools and a graphical user-interface based on an extendable C++ library. It is cross-platform, and requires few external libraries to build from source. Pre-built binaries (with all dependencies included) for Windows, MacOS and Linux are available so that Madym can be installed directly for users not wanting to or unable to compile the C++ source themselves. We have also developed complementary interfaces in Matlab (available in a separate open-source repository (M. Berks, 2021b)) and python (integrated with the main toolkit), that allow the flexibility of developing in those scripting languages, while allowing C++ to do the heavy-duty computational work of tracer-kinetic model fitting.

Statement of need
Madym has been designed with the following principles: • Ease-of-use: Madym supports many advanced features for DCE-MRI analysis, however the tools have been designed to be usable by anyone, including clinical scientists with no software/programming knowledge. Extensive documentation is provided on the project wiki (M. Berks, 2021a), and an example test set is included with the toolkit, including walk through instructions of how to perform a standard analysis on these data.
• Reproducible research: even the simplest DCE-MRI analysis pipeline requires configuring many parameters (ie typically more than 20), which in some packages may be implicitly encoded in sub-methods, and may therefore differ in non-transparent ways between different implementations of the same analysis pipeline. Wherever possible, Madym exposes all parameters as configurable options, with a single source file specifying their default values used throughout the toolkit. A consistent interface is provided for configuring individual options, either via input config files, setting options directly at the commandline or adjusting interactively in the GUI. Whenever an analysis is run, the complete configuration -including the final set of parameter option values, the version of Madym used and the machine ID on which the analysis was run is saved with the output results.
Thus Madym provides both flexibility in configuring analyses to individual datasets, while supporting reproducibility with a complete record of how results were obtained. In doing so we support the aims of the ISMRM (International Society for Magnetic Resonance in Medicine) Reproducible Research Study Group (Stikov et al., 2019), and have listed Madym on the ISMRM MR-hub (ISMRM, 2021).
• Extensibility: Madym includes several of the most commonly used tracer-kinetic models as standard, including the Patlak (Patlak et al., 1983), extended-Tofts (Tofts, 1997) and two compartment exchange models (Sourbron et al., 2009), as well as more complex models for fitting contrast-agents that are actively metabolised by tissue and/or require dual vascular supply functions (Michael Berks et al., 2021). However these are by no means an exhaustive list and, by decoupling model optimisation from the model definitions, the toolkit has been designed to make adding new models very easy, simply by sub-classing the main abstract model class. Instructions for doing so are provided in the project wiki. Extending T 1 fitting methods (currently variable flip-angle and inversion recovery methods are supported), or even adding a new command-line tool, are designed and documented in the same way.
• Performance: Madym is designed with the aim of voxel-wise model fitting (where a model is fitted to individual tissue voxels rather than spatially averaged regions-of-interest). 3D MRI images have many hundreds of thousands of voxels (eg a typical image may have dimensions 128 x 128 x 40 = 655,360 voxels). By using C++ and externally developed open-source optimisation library (ALGLIB, (Bochkanov, 2019)), on a standard desktop Madym requires ≈ 10µs per voxel to estimate baseline T 1 (allowing T 1 mapping of whole volumes in a few seconds) and < 30ms per voxel to fit the extended-Tofts model (so a typical tumour of 500-1,000 voxels can be analysed in 20-30 seconds, while whole organs can be fitted in a few hours).
Madym has been developed over approximately 20 years and has been used to perform DCE-MRI analyses in more than 20 research papers and many more conference abstracts (landmark papers include (Jayson et al., 2018) and (O'Connor et al., 2012), see the project wiki for a more complete list). Until this year, these used previous non-open source versions, however the first paper using Madym as an open-source toolkit has just been published (Michael Berks et al., 2021), and we hope will be the first of many in the future.

Related work
There are several open-source packages for DCE-MRI analysis that provide similar tracerkinetic model-fitting functionality to Madym. These include standalone tools such as ROCK-ETSHIP (Barnes et al., 2015), DCE@urLAB (Ortuño et al., 2013), and DCEMRI.jl [Smith et al. (2015), and packages for R: DATforDCEMRI (Ferl, 2011), dcemriS4 (Whitcher & Schmid, 2011) or python: pydcemri [welchpydcemri:2017. In terms of providing a fully open-source, cross platform solution that runs complete end-to-end pipelines, MITK-ModelFit (Debus et al., 2019) (also implemented in C++) has probably the closest functionality to Madym. They differ in that MITK-ModelFit builds into the wider MITK and ITK toolkits, with the advantage of providing a richer set of additional pre/post processing options not available in Madym (eg image registration and segmentation), at the expense of requiring a much larger install.
In comparison, Madym (particularly if using the pre-built binaries) provides an arguably easier and lighter package to get started, while the python and Matlab wrappers add flexibility to include other pre/post processing steps. There are also specific features of Madym (such as inversion recovery T 1 -mapping and the implementation of dual-input vascular input functions and active-enhancement models for fitting metabolised contrast-agents in the liver), that we believe are currently unique to publicly available DCE-MRI packages.