CRIMSON: An open-source software framework for cardiovascular integrated modelling and simulation

In this work, we describe the CRIMSON (CardiovasculaR Integrated Modelling and SimulatiON) software environment. CRIMSON provides a powerful, customizable and user-friendly system for performing three-dimensional and reduced-order computational haemodynamics studies via a pipeline which involves: 1) segmenting vascular structures from medical images; 2) constructing analytic arterial and venous geometric models; 3) performing finite element mesh generation; 4) designing, and 5) applying boundary conditions; 6) running incompressible Navier-Stokes simulations of blood flow with fluid-structure interaction capabilities; and 7) post-processing and visualizing the results, including velocity, pressure and wall shear stress fields. A key aim of CRIMSON is to create a software environment that makes powerful computational haemodynamics tools accessible to a wide audience, including clinicians and students, both within our research laboratories and throughout the community. The overall philosophy is to leverage best-in-class open source standards for medical image processing, parallel flow computation, geometric solid modelling, data assimilation, and mesh generation. It is actively used by researchers in Europe, North and South America, Asia, and Australia. It has been applied to numerous clinical problems; we illustrate applications of CRIMSON to real-world problems using examples ranging from pre-operative surgical planning to medical device design optimization.


Introduction
One of the revolutionary successes of twentieth century in applied mathematics is the development of the finite element method (FEM) into a reliable engineering tool. It is now routinely deployed by practitioners in fields where the problems of interest are described by systems of partial differential equations (PDEs). FEM, in combination with high-performance computing (HPC), has enabled solution of these systems of PDEs rapidly and accurately.
In the present work, FEM is applied to the incompressible Navier-Stokes equations in patient-specific vascular geometries. This enables analysis of clinically-relevant blood flow phenomena including the impact of the geometry, vascular wall properties, or prospective surgical decisions on blood pressure, wall shear stress, and mass (e.g. protein or drug) transport. These capabilities support the key applications of surgical planning, patient diagnosis, medical device design and optimisation, and basic cardiovascular disease research. Such applications are collectively called computational haemodynamics (CH).
A serious factor limiting widespread adoption of CH has been the arcane and unwieldy nature of existing academic software packages and workflows, coupled with the fact that no commercial package truly supports cutting-edge CH. Specifically, key aspects of the computational modelling workflow have been done in a manual fashion, resulting in cumbersome, manual workflows. This is error-prone and non-systematic. Examples of such operations are: parameter estimation, application of physiologically-relevant boundary conditions such as PC-MRI informed velocity profiles, and the ability to simulate physiologically-varying conditions.
More generally, and due in part to the patchwork nature of academic software development involving multiple researchers with differing goals over many years, simulation workflows often require using multiple pieces of software and ad-hoc scripts. One pathway to addressing this issue is specialised, problem-specific commercial enterprise. For example, HeartFlow Ltd. provides CH-as-a-service for diagnosis of coronary artery disease, taking medical imaging data and producing computational clinical reports on the hemodynamic significance of coronary lesions. In their workflow, medical image data are uploaded to the HeartFlow servers, and a report is returned to the clinician [1]. However, if CH is to be performed in a research setting using open-source tools, custom workflows must be created. Given the complexity of the software components and the interdisciplinary nature of the user base (e.g., clinicians, students, and academics), it is important that the software provides powerful capabilities, whilst presenting an intuitive, expandable, and user-friendly graphical user interface (GUI). In this article, we describe how we address these issues in our CH software environment CRIMSON (Cardio-vasculaR Integrated Modelling and SimulatiON).
CRIMSON consists of two components. The first is the CRIMSON GUI, which is a Windows application for setting up simulations via segmenting medical image data, creating finite element meshes, assigning boundary conditions, and examining results. The second component is the CRIMSON Flowsolver, which is a Message Passing Interface (MPI) parallel application, scalable to tens of thousands of cores [2], which can be run on Windows or Linux; simulations with the Flowsolver can either be run on the local machine from within the GUI, or transferred to a high-performance computer for simulation there.
The conceptual ancestor of CRIMSON is SimVascular [3], which has been widely used in numerous CH studies [4][5][6][7][8]. During the early design phase of CRIMSON, we determined that there was a pressing need for developing a CH software package that leveraged the strengths of SimVascular's Flowsolver with a modern UI with broad community support and best-in-class open source components for key operations of the simulation workflow (CAD, boundary condition specification, meshing, parameter estimation, etc.). For example, assigning a boundary condition directly to a surface of the 3D-rendered model was not supported by SimVascular's GUI. CRIMSON GUI was therefore created to avoid these limitations, introduce many novel features and improvements, and expand functionality, workflow robustness, and accessibility.
A key decision was to utilise for the first time in CH [9] the Medical Imaging Interaction Toolkit (MITK) [10]. CRIMSON allowed the creation of novel and unique features including GUI support for a wide range of fine-tuneable boundary condition (BC) types, including direct imposition of phase-contrast magnetic resonance imaging (PC-MRI) flow data [11], rapid design and prototyping of arbitrary lumped parameter network (LPN) reduced order models, and spatially-varying vessel wall material properties, all of which are supported in a modern, user-friendly GUI. Furthermore, CRIMSON supports automatic model parameter estimation via filtering of time-resolved data [12]. The key driving philosophy is that for these powerful features to reach their maximum potential, they must be accessible to both clinicians and technical researchers. To achieve this, CRIMSON aims to present clearly-documented, logical workflows in the GUI, and to protect users from common errors. The latter goal is achieved, for example, by supporting clear graphical BC specification in the GUI, by including undo/ redo stacks for operations, and by limiting the interaction that users have with text-based configuration files.
Beyond making the basic workflow as user-friendly as possible, CRIMSON has several unique features which enable novel simulation capabilities. For example, CRIMSON allows users to implement-at run-time-arbitrary rules for adjusting boundary condition parameters during simulations, based upon the simulation state. This allows modelling of cardiovascular control mechanisms, and transitional hemodynamic states-for example, between rest and exercise [13]. Further, for model parameterisation, testing, and exploring longterm behaviour, CRIMSON supports a one-click-to-enable pure-zero-dimensional mode, so that the haemodynamic influence of the boundary conditions can be explored without the computational cost of a full 3D domain. This ability for rapid exploration is invaluable for novices learning how parameters affect simulation results in simple models, and for experts exploring parameter space during the development of novel complex models. A comparison of key features between CRIMSON and some alternative packages is presented in Table 1.

Design and Implementation
The CRIMSON workflow, from medical imaging data to simulation results, is shown in Fig 1. The three major stages of the pipeline (i.e., Preprocessing, Flowsolver, and Postprocessing) are depicted, including some optional sub-steps in each column which may or may not be part of the process for a given CH application.  [11] Y N N N Kalman filtering tools for determining boundary condition parameters via clinical data assimilation [12] Y N N N Fluid-structure interaction via efficient arbitrary Lagrangian-Eulerian vessel wall models [17] Upcoming N N N Multi-species reaction-advection-diffusion problems, with run-time specification of reaction equations [15] Upcoming N N N The CRIMSON GUI is built upon MITK, which provides tools to load, visualize and manipulate medical image data. A screenshot of CRIMSON during the Geometric Modelling portion of the workflow is shown in Fig 2. Here, the user loads the medical image volume, and draws one-dimensional paths approximately representing the centreline of each vessel of interest. CRIMSON then re-slices the image data using a plane perpendicular to the centreline at each point along its length (Fig 2, box 3). Upon this re-slice plane, the user generates twodimensional contours to segment the vessel wall [18,19] using MITK's manual and semi-automatic segmentation functions, including tools for delineating the vessel cross-section using circles, ellipses or splines. An analytic NURBS surface is then created of each vessel via lofting or sweeping operations. The vessels of interest are united using a blending operation to create a single geometric CAD model [20], which is then volume-meshed using (only) linear tetrahedral elements. Mesh generation is provided by TetGen [21]. Boundary layers can be specified. CAD models can be exported in step, iges, and brep file formats. CRIMSON also allows for direct importing of discrete surface triangulations of vascular geometries (e.g. stl format) created in external packages.
BCs are subsequently assigned, including upstream or downstream vascular reduced order models. The vessel walls can be modelled as rigid or made deformable via a coupled momentum method, making use of a linear elastic constitutive membrane model for the vessel wall [22], and spatially-varying and anisotropic mechanical properties of the arterial wall can be specified using the theory of "Small on Large" [23]. External tissue support can also be specified, modelling the influence of nearby anatomical structures on the blood vessels. BC can be Neumann, Dirichlet, or based upon the coupled multidomain method [24], which imposes a Dirichlet-to-Neumann relationship at the face. Boundaries can optionally use "backflow stabilization" [14] to prevent numerical instability during periods of flow reversal at Dirichlet-to-Neumann surfaces; this critical feature is required to avoid the use of non-physiological "flow extensions" of the 3D domain often in other software packages. Numerical simulation parameters such as time stepping, and non-linear iteration strategies are then set within the GUI. Simulation files are written and passed to the parallel incompressible Flowsolver, which uses linear tetrahedral finite elements and a Streamline Upwind Petrov-Galerkin (SUPG) stabilized scheme for the spatial discretisation of the Navier-Stokes equations [25], and a second-order accurate generalized-α method [26] for time discretization. The Flowsolver scales efficiently to thousands of cores of HPC hardware, meaning that it can compute pressure and flow fields in very complex problems. Results are retrieved and can be visualized in the CRIMSON GUI. The GUI allows for field-based mesh refinement [27] and repetition of the analysis if necessary. Visualisation is also possible in third-party applications, such as Paraview [28].
The CRIMSON Flowsolver consists of a core Fortran FEM solver, based on PHASTA [29] and closely related to that of SimVascular. We have made significant additions, including: (1) the conversion of the codebase from Fortran 77 to Fortran 90; (2) the addition of a modern C+ +11 layer to manage extensions, including the powerful new arbitrary BC design and control system; (3) the associated Python interface for dynamically adjusting BC parameters during simulations of transitional physiology; and (4) the use of the Verdandi libraries for data assimilation [30]. Additional modifications include the integration of the Google Test framework [31], and our ongoing work towards simulation of non-linear vessel wall-blood flow interactions [32,17] and flexible pipelines for simulation of systems of reaction-advection-diffusion (RAD) transport [15].
To assist with BC design, CRIMSON provides the Netlist Editor Boundary Condition Toolbox (NEBCT), shown in Fig 3. This presents a drag & drop interface for assembling LPNs, represented using electronic circuit symbols and invoking the standard analogy between fluidics and electronics. NEBCT allows tagging of components for Python-specified dynamic control during simulation and generates user-customizable Python controller class definitions, under the CRIMSON Control Systems Framework. NEBCT is based upon the QSapecNG electrical circuit simulation software [16,33].
The CRIMSON GUI embeds another Python interpreter, which enables functionalities ranging from script-based specification of the local vessel wall thickness and elastic modulus, to definition of Python "Solver Setup" modules; this permits straightforward customization of the CRIMSON GUI's interface widgets and output files, providing a pathway to compatibility with different fluid solvers. Thus, research groups may write their own Solver Setup to generate simulation files for their own simulation software; the procedure is documented online (https://crimsonpythonmodules.readthedocs.io/en/latest/). For example, a Solver Setup has been written for the CHeart fluid solver [34,35]. Some additional details regarding the CRIM-SON design and workflow have previously been presented [9].
A summary of the main libraries and frameworks using in CRIMSON is described in Section Guidance for Getting Started with CRIMSON.

Results
We demonstrate CRIMSON using three different examples, with all necessary input files available in File 1 at https://doi.org/10.7302/4vdx-ek59. We present two application examples (Cases A and B) highlighting specific aspects of CRIMSON's capabilities, followed by an example demonstrating the entire workflow (Case C). In Case A, we demonstrate some of the fundamental features of CRIMSON, including running Navier-Stokes simulation in a patientspecific aortic model. In Case B, we demonstrate segmentation of PC-MRI data to create a patient-specific aortic inflow boundary condition. In Case C, we demonstrate the simulation of dynamic adaptations of blood flow in a surgical planning application.

Example Case A: STL Geometry import, Mesh generation, Netlist boundary conditions, 3D Simulation on a Desktop PC
In Example Case A, we demonstrate the simulation workflow in the case where a geometric vascular model has been created using third-party software, which may be idealised or patientspecific. CRIMSON supports this via a solid model import feature. Note that additional boundary condition data (flow rates at the various model outlets) was assumed in this case; typically, additional patient data such as blood pressure or regional flow rates would be used to parameterize the boundary conditions.
In addition to demonstrating how to work with imported geometries, this example highlights how to use the NEBCT to design simple LPN boundary conditions, how to run low-resolution 3D simulations on a desktop PC (or if the user wishes, high-resolution versions on HPC), how to refine the mesh after a simulation to focus computational effort in regions of high error in subsequent simulations, and how to visualise results within CRIMSON.

Example Case B: Using Phase-Contrast MRI Data as a patient-specific boundary condition
A unique feature of CRIMSON is the ability to impose image-derived velocity profiles as boundary conditions. Typically, this is used at the aortic root, enabling study of the impact of valvular pathologies-which critically shape the inflow profile-on aortic haemodynamics. Fig 4 illustrates the concept. Imposing patient-specific inflow velocity profiles enables direct comparison with idealized (e.g. healthy) or hypothetical post-operative scenarios (e.g. following valve replacement procedures), without changing any of the other parameters of the system. It has been shown that CH which use idealised inflow profiles in cases where the patient's valve is diseased can lead to significantly altered simulation results [36,11,37,38].
The supplementary files in Example Case B-available in File 1 at https://doi.org/10.7302/ 4vdx-ek59 -show how to use CRIMSON to segment the provided PC-MRI dataset, and impose it upon the provided model.

Example Case C: Cardiovascular risk assessment post-liver-transplant
In Alagille syndrome patients in need of liver transplant, it is important to understand whether their cardiovascular system can withstand the stresses of the transplant surgery [39][40][41][42]. A major concern is that the heart may not be able to support the demands placed on it during post-reperfusion syndrome (PRS)-the result of a sudden release of vasoactive mediators into the circulation after reperfusion of the new liver. PRS is characterised by a decrease in mean arterial pressure and systemic vascular resistance, and an increase in pulmonary pressure and central venous pressure [43]. These factors have the effect of simultaneously increasing the workload on the heart, and-due to the drop in mean arterial pressure-decreasing the coronary perfusion pressure gradient. Thus, the supply of oxygen to the ventricles may become insufficient, placing the patient at risk of cardiovascular complications.
To study this, a subject-specific model of an Alagille syndrome patient was created in CRIMSON, consisting of two (pulmonary and systemic) 3D domains segmented from magnetic resonance images, and a closed-loop circulatory system created using NEBCT (Fig 5). In the present article, we illustrate the difference between the myocardial oxygen supply and demand in one region of the left ventricular myocardium; for further details see [44]. This difference was computed using a model of myocardial oxygen supply and demand [13] and implemented within a coronary boundary condition using the CRIMSON Control Systems Framework. Fig 6 compares the imbalance between myocardial oxygen demand and supply ("myocardial hunger") in a baseline case (case C1), calibrated to patient haemodynamic data at rest, to that same imbalance under a simulated PRS condition (case C2). No long-term mismatch is detected under baseline conditions (the long-wave oscillation is a computational artefact as the simulation reaches a fully periodic state). Conversely, the continual growth in myocardial hunger under PRS indicates that this patient may be at risk of cardiovascular complications posttransplant.
The data available in File 1 at https://doi.org/10.7302/4vdx-ek59 describes how to run this case in 0D and visualize the results, as well as how to run in 3D, and visualize parameters such as local pressures and flows. The 0D simulation is presented here so that it is computationally tractable for most readers. Both the 0D and 3D simulations are presented in detail elsewhere [44]. The closed-loop boundary condition circuit specified in this problem is visualized in Fig  7; guidance on how to perform this visualisation is also provided. Because running this model in 3D requires around 20,000 CPU core-hours, the input files provided in File 1 at https://doi. org/10.7302/4vdx-ek59 for Cases C1 and C2 are configured to run in a simplified 0D mode. Readers with access to HPCs can follow the instructions to enable full 3D simulation.

Further applications of CRIMSON in the literature
Another use-case for CRIMSON is preoperative surgical planning. For example, CRIMSON was applied to a case of open surgical correction of a Fontan procedure, in a patient suffering from unilateral pulmonary arteriovenous malformations. After constructing a model reproducing the patient's pre-operative haemodynamics, two post-operative models were created representing two possible surgical repairs. One was seen to be superior in terms of balancing hepatic venous flow between the pulmonary arteries, and the multidisciplinary surgical team chose this option for the patient [45]. Post-operative clinical data agreed with the simulated predictions.
In another study, CRIMSON was used to evaluate the suitability of different designs of a medical device-vascular endografts for aortic arch repair-in terms of their impact on patient  haemodynamics. Evaluating design alternatives in vivo is neither practical nor ethical, so computational modelling is the only option. The results indicated that the different devices offered significantly different hemodynamic metrics in terms of blood shearing and blood flow to the brain [46]. CRIMSON has been used to systematically examine anatomical risk factors in type-B aortic dissection (TBAD) using idealized models. CRIMSON models permitted isolated changes to specific parameters present in TBAD, including vessel curvature, tear size and shape, false lumen location, and treatment state. The results indicated which combinations lead to unfavourable haemodynamic states, and agreed with clinical studies [47]. A similar study employing a patient-specific model demonstrated that dissection imposes a significant additional workload on the heart, and that the number of additional communicating tears between the true and false lumen has a substantial impact on volumetric flow and peak pressure in the true lumen [48].
In a study reproducing haemodynamics in a patient with a Blalock-Taussig (BT) shunt, CRIMSON was used to determine that the BT shunt's diameter had reduced by 22% since implantation due to neointimal growth. Because the shunt size was below the MRI resolution, CRIMSON was critical in determining this diameter change [49].
A patient-specific model involving three virtual interventions-open repair, conformable endografting, and fenestrated endografting-to repair a kinked ascending aortic graft in a patient-specific model was studied using CRIMSON [50]. The results included evaluation of a metric of platelet aggregation potential, PLAP [51,52], and indicated that surgical repair or the fenestrated endograft would most profoundly reduce thrombus formation risk.
One of the key novel aspects of CRIMSON is its tools for studying cardiovascular control systems and auto-regulations. These include the role of the baroreflex system in adjusting blood pressure after a change in body posture [53], and how the coronary flow autoregulation system responds to changes in exercise intensity in a patient-specific model [13].

Availability and future directions
We invite readers to download installers for Microsoft Windows from www.crimson.software for both CRIMSON GUI and CRIMSON Flowsolver. These are currently time-limited binaries, but users can compile their own versions from the provided source code. Alternatively, users can follow the documentation on the CRIMSON website, describing how to interface the GUI with their own fluid solver. The source code for the GUI is available on GitHub under GNU Affero General Public License v3.0 (https://github.com/carthurs/CRIMSONGUI), and for the Flowsolver under the GNU General Public License v3.0 (https://github.com/carthurs/ CRIMSONFlowsolver). Both licenses further include the Commons Clause. Archived versions of the source code are available under DOIs 10.7302/679b-dw96 and 10.7302/tbx5-7c07 for the GUI and the Flowsolver, respectively. For the avoidance of confusion, a separate CRIMSON GUI called CRIMSON Pro is also available in the CRIMSONGUI GitHub repository. This provides additional interfaces for some advanced features (but does not provide those features themselves). CRIMSON Pro is not the subject of this manuscript. Fig 8 depicts [54], which enabled straightforward implementation without requiring expert knowledge of the Flowsolver. Panel B shows results obtained using Lagrangian particle tracking analysis of haemodynamics in a "Zone 0" thoracic endovascular aortic repair [46]. The colour scale indicates PLAP (platelet activation potential), a metric used to quantify the shear rate experienced by massless particles advected by the flow. This index has been linked to risk of thrombus formation [50]. Panel C shows the estimation of BC model parameters during the application of a sequential Reduced-Order Unscented Kalman Filter (ROUKF). The filter is used to determine suitable parameter values in agreement with time-resolved provided patient data, such as localised pressure or flow measurements [55,30,12]. Panel D displays results of a volumetric mesh motion algorithm, which has been developed as a component of an Arbitrary Lagrangian Eulerian (ALE) based FSI framework utilizing a rotation-free nonlinear shell formulation [17]. This method will enable simulation of large vascular strains and motions, incorporating biologically-relevant constitutive models for the vessel wall (for example, nonlinear strain energy functions for soft tissue, including four fibre models), and involves a novel mathematical formulation that retains displacement-only degrees of freedom for the shell (i.e. no elements across the wall thickness) description for vessel wall, thereby ensuring minimal computational costs compared to other ALE methods. Panel E illustrates the application of a custom ODE model, composed in a few tens of lines of Python by the user, which at run-time can adjust the parameters of an attached BC component. Panel F illustrates the solution of RAD transport problems coupled with flow. Here, a single scalar with zero initial condition is considered, an advective flux is imposed at the inlet with a zero total flux condition on all walls and outlets. This allows simulation of transport under high Peclet numbers and interaction of scalar species, including proteins, drugs, contrast agents and heat, and will enable study of phenomena such as thrombogenesis [15]. CRIMSON will support arbitrary numbers of reacting species, with reaction terms specified by the end-user at run-time in Python.
A further planned enhancement is the integration of a one-dimensional (1D) incompressible Navier-Stokes solver, which enables simulating extensive vascular networks over many cardiac cycles in almost real-time, while retaining features such as pulse wave propagation phenomena [56]. This 1D flow solver could be used in combination with graph theoretic approaches to accurately and efficiently model blood flow in disease conditions [57].
Currently, there are no good models in existence for turbulent cardiovascular flow. There is a need to develop models of transitional and mild turbulence, which are the conditions occurring in some cardiovascular flows. The validation of such models would in principle have to be made using appropriate in vitro models, due to the challenges in acquiring in vivo data on transitional / complex flows.
Furthermore, there is a pressing need to develop workflows for 3D anatomical model creation that rely on machine learning methods. This would greatly reduce the current time required to create anatomical models, which currently require the use of external commercial packages (such as Mimics) or labour-intensive workflows (CRIMSON and SimVascular).
We believe that CRIMSON is an enticing prospect for CH researchers and look forward to working with the community as we continue its development. We aim to be responsive to community input, via our support mailing list, and look forward to receiving feedback from our ever-expanding user-base on how CRIMSON can best support their work. Python Control Systems Framework. B: Example of a Lagrangian particle tracking study of massless particle transport in the blood stream [46]. C: Time history of parameter convergence during Kalman filter data assimilation [12]. D: Arbitrary Lagrangian-Eulerian deformation of a vascular mesh between diastole and systole [17]. E: Support for arbitrary run-time Python code for modelling cardiovascular control systems and changes of state, by controlling component parameters during simulations [16]. F: Scalar reactionadvection-diffusion (RAD) problem with one species transported in the blood stream. Run-time specification of arbitrary reactions between tens of species is under current development [15]. https://doi.org/10.1371/journal.pcbi.1008881.g008

Guidance for getting started with CRIMSON
The version of CRIMSON GUI and CRIMSON Flowsolver current at the time of publication of this article is provided in File 1 at https://doi.org/10.7302/4vdx-ek59. However, a newer version may be available from www.crimson.software, as suggested in each of the cases below. To install CRIMSON, first run the CRIMSON-2019.11.01 exe installer, then run the CRIMSON_Flowsolver exe installer. The order is important. If you use the default installation paths in both, then the GUI will be able to find and run the flowsolver. If you install the GUI to a non-default location, you must change the Flowsolver's install path in the same manner.
If you wish to build from source, follow the instructions in the readme.md file in the CRIM-SON Flowsolver repository https://github.com/carthurs/CRIMSONFlowsolver; and analogously for the GUI repository https://github.com/carthurs/CRIMSONGUI.

Running example Case A
The tutorial pdf for this example case-located in File 1 at https://doi.org/10.7302/4vdx-ek59will guide you through the complete process of creating a model, running the simulation and examining the results.

ExampleCaseA\ExampleA-Meshing-BC-Simulation-visualisation-refinement.pdf-the
instructions for running this case 2. ExampleCaseA\DataFiles\Solid_model.stl-the surface triangular mesh of the vascular geometry we will use 3. ExampleCaseA\DataFiles\steady.flow-specification file for a constant steady inflow at the aortic valve; for use with the Prescribed Velocities inflow boundary condition Steps to Follow:

Running example Case B
The supplementary pdf for this example-available in File 1 at https://doi.org/10.7302/4vdx-ek59 -will guide you through segmenting and imposing a patient-specific aortic inflow velocity profile from a provide PC-MRI dataset.

Running example Case C
The supplementary pdf for this case-available in File 1 at https://doi.org/10.7302/4vdx-ek59will guide you through running a simulation of a patient under rest conditions, and then of the same patient under post-liver-transplant conditions. Many parameters of the haemodynamics could be examined and compared between the two, but in this case we choose to examine the oxygen supply/demand balance in the myocardium under these two states, and will observe that coronary perfusion is insufficient in the post-operative simulation.

Libraries and frameworks used in CRIMSON
The following pre-existing libraries are integral to the CRIMSON software. See S1 Fig for an overview of the structure. The Medical Imaging Interaction Toolkit (MITK) [10] was chosen as the foundation for the CRIMSON GUI due to its established position as an open-source package for development of interactive medical image processing and ongoing development by the German Cancer Research Center. It provides functionality for working with medical image datasets, including multiple orthogonal and 3D views of the image volume, data storage and undo/redo functionality, and image processing and segmentation algorithms [58] via the Insight Toolkit (ITK), Visualization Toolkit (VTK) and Qt [59]. Additionally, it includes a Python interface for easy prototyping and MITK release 2016.11 integrates VMTK (The Vascular Modeling ToolKit) [60], a reference package for vascular segmentation and automatic centreline extraction. MITK is well-regarded, providing a foundation for other research packages including by the more general GIMIAS [61].
MITK itself is built upon the widely used visualisation tools of VTK, adopts segmentation tools from ITK, and is highly customizable due to the modular, cross-platform MITK Blue-Berry framework and CTK (the Common Toolkit). MITK uses the Qt application framework to manage events and connect user interface (UI) elements, the MITK DataStorage system to manage state data (The Qt Company, 2016 [59]). Qt, together with the Python Qt wrappers, allows advanced users to add, remove or modify the widgets presented by the GUI when writing custom Solver Setups (see later in this section). The functionality for lofting or sweeping to create the solid model from the segmented vessel contours, blending the intersecting vessels into a full geometry, and important filleting and Boolean operations is provided by OpenCascade [19].
Volume meshing is provided by the TetGen (Si, 2015 [21]) library; optionally, this can be replaced with the high-quality commercial Simmetrix MeshSim library [62].
OpenCascade [19] is an open-source C++ class library designed for rapid production of complex Computer Aided Design (CAD) applications. This class library makes it possible to define analytical models whose surfaces are parametrized by functions such as non-uniform rational basis splines (NURBS).
Verdandi is an open-source generic C++ library for data assimilation, developed by INRIA (Chapelle, et al., 2013 [30]). Data assimilation is a process that enables combining different sources of information to estimate the state of a dynamical system. By extension, this approach can be used to estimate parameters of a computational model if time-resolved data is available.
Verdandi was designed so that computational models implemented in C++, Fortran, or Python could be make use of Verdandi via either a C++ or a Python interface.
QSapecNG (Manetti, et al., 2012 [33]) is an open-source program based on Qt for drawing linear analogue circuits and performing analysis. We modified it to create a tool for designing custom circuits for BC models (the CRIMSON Netlist Editor Boundary Condition Toolbox), and outputting them in a format readable by the CRIMSON Flowsolver.
Recently a Docker container of the CRIMSON flowsolver has been made available in the American Heart Association's Precision Medicine Platform, which runs on Amazon Web Services. S1 Fig summarizes the main libraries and packages contributing to CRIMSON. A permanently archived versions of the source code for CRIMSON GUI and CRIMSON Flowsolver, and of binary installers and example case studies described in this manuscript, have been made available using the University of Michigan's Deep Blue service [63][64][65].