/**

\page org_mitk_views_pharmacokinetics_mri The DCE MR Perfusion DataFit View


\imageMacro{pharmacokinetics_mri_doc.svg,"Icon of the DCE MR Perfusion View",3.0}

\tableofcontents

\section FIT_DCE_Introduction Introduction
In dynamic contrast-enhanced (DCE) MRI, pharmacokinetic (PK) modeling can be used to quantify tissue physiology.
Parameters describing the tissue microvasculature can be derived by fitting a pharmacokinetic model, e.g. a compartment model, to the dynamic data.
This view offers a comprehensive set of tools to perform pharmacokinetic analysis.

\section FIT_DCE_Contact Contact information
If you have any questions, need support, find a bug or have a feature request, feel free to contact us at www.mitk.org.

\subsection FIT_DCE_Cite Citation information
If you use the view for your research please cite our work as reference:\n\n
Debus C and Floca R, Ingrisch M, Kompan I, Maier-Hein K, Abdollahi A, Nolden M, <i>MITK-ModelFit: generic open-source framework for model fits and their exploration in medical imaging – design, implementation and application on the example of DCE-MRI</i>. https://doi.org/10.1186/s12859-018-2588-1 (BMC Bioinformatics 2019 20:31)

\section FIT_DCE_Data_and_ROI_Selection Time series and mask selection
\imageMacro{dce_mri_maskAndFittingStrategy.png, "Time series and mask selection.", 10}
In principle, every model can be fitted on the entire image. However, for model configuration reasons (e.g. AIF required) and computational time cost, this is often not advisable.
Therefore, apart from the image to be fitted (<i>Selected Time Series</i>), a ROI segmentation can be defined (<i>Selected Mask</i>), within which model fitting is performed.
The view currently offers <i>Pixel based</i> and/or <i>ROI based</i> averaged fits of time-varying curves. The <i>ROI based</i> fitting option becomes enabled, if a mask is selected.


\section FIT_DCE_General_models Supported models
Currently the following pharmacokinetic models for gadolinium-based contrast agent are available:
-	The Descriptive Brix model \ref FIT_DCE_lit_ref1 "[1]"
-	A semi-quantitative two/three segment linear model (2SL/3SL)
-	The standard tofts model \ref FIT_DCE_lit_ref2 "[2]"
-	The extended Tofts model \ref FIT_DCE_lit_ref3 "[3]"
-	The two compartment exchange model (2CXM) \ref FIT_DCE_lit_ref4 "[4, 5]"

\section FIT_DCE_Settings Model settings
\imageMacro{dce_mri_modelSettings.png, "Model settings of the view for the standard Tofts model.", 10}

\subsection FIT_DCE_Settings_model Model specific settings
Selecting one of the \ref FIT_DCE_General_models "supported models" will open below tabs for further configuration of the model.
- The descriptive Brix model requires only definition of the duration of the bolus, i.e. the overall time of the injection (<i>Injection Time [min]</i>).
- The 3SL is a semi-quantitative descriptive model that distinguishes three different segments of the signal: A constant baseline, the initial fast rise (wash-in) and the final slow rise / signal decrease (washout). Each of these segments is approximated by a linear curve, with change points in-between. It requires no further configuration.
- The standard Tofts model, the extended Tofts model and the 2CXM are compartment models that require the input of the concentration time curve in the tissue feeding artery, the arterial input function (AIF).
In the DCE MR Perfusion Datafit View, the arterial input function can be defined in several ways. For patient individual image derived AIFs, select the radio button <i>Select AIF from Image</i>.
In that case, a segmentation ROI for the artery has to be selected. This can be done by clicking on the <i>AIF Mask</i> selection widget and selecting a suitable AIF segmentation from the data loaded in the Data Manager. In cases where the respective artery does not lie in the same image as the investigated tissue (e.g. in animal experiments, where a slice through the heart is used for AIF extraction), a dedicated AIF image can be selected using the corresponding <i>Dedicated AIF image</i> selection widget.
An alternative option is to define the AIF via an external file by selecting <i>Select AIF from File</i> (e.g. for population derived AIFs or AIFs from blood sampling). By clicking the <i>Browse</i> button, one can select a csv file that holds the AIF values and corresponding timepoints (in tuple format (Time, Value)).
Caution: the file must not contain a header line, but the first line must start with Time and Intensity values.
Furthermore, the <i>Hematocrit Level</i> has to be set (from 0 to 1) for conversion from whole blood to plasma concentration. It is set as default to the literature value of 0.45.

\subsection FIT_DCE_Settings_start Start parameter
\imageMacro{dce_mri_start.png, "Example screenshot for start parameter settings.", 10}
In cases of noisy data it can be useful to define the initial starting values of the parameter estimates, at which optimization starts, in order to prevent optimization results in local optima.
Each model has default scalar values (applied to every voxel) for initial values of each parameter, however these can be adjusted.
Moreover, initial values can also be defined locally for each individual voxel via starting value images. To load a starting value image, change the <i>Type</i> from <i>scalar</i> to <i>image</i>. This can be done by double-clicking on the type cell.
In the <i>Value</i> column, selection of a starting value image will be available.

\subsection FIT_DCE_Settings_constraint Constraints settings
\imageMacro{dce_mri_constraints.png, "Example screenshot for constraints settings.", 10}
To limit the fitting search space and to exclude unphysical/illogical results for model parameter estimates, constraints to individual parameters as well as combinations can be imposed.
Each model has default constraints, however, new ones can be defined or removed by the + and – buttons in the table.
The first column specifies the parameter(s) involved in the constraint (if multiple parameters are selected, their sum will be used) by selection in the drop down menu.
The second column <i>Type</i> defines whether the constraint defines an upper or lower boundary.
<i>Value</i> defines the actual constraint value, that should not be crossed, and <i>Width</i> allows for a certain tolerance width.

\subsection FIT_DCE_Settings_concentration Signal to concentration conversion settings
\imageMacro{dce_mri_concentration.png, "Example screenshot for concentration conversion settings.", 10}
Most models require contrast agent concentration values as input rather than raw signal intensities (i.e. all compartment models).
The DCE MR Perfusion DataFit View offers a variety of tools for the conversion from signal to concentration:
by means of relative and absolute signal enhancement, via a T1-map calculated by the variable flip angle method, as well as a special conversion for turbo flash sequences.
A more detailed description of these conversion methods, for example the exact formulas used for the absolute and relative signal enhancement calculations, can be found here: \ref org_mitk_views_pharmacokinetics_concentration_mri.
For the conversion methods, a baseline image prior to contrast agent arrival is required.
In many data sets, multiple baseline images are available. The <i>Baseline Range Selection</i> allows for selection of a range of time frames, from which the average image (along the time dimension) is calculated and set as baseline input image.
Remark: The number of the first time frame is 0.

\section FIT_DCE_Fitting Executing a fit

In order to distinguish results from different model fits to the data, a <i>Fitting name</i> can be defined.
As default, the name of the model and the fitting strategy (pixel/ROI) are given. This name will then be appended by the respective parameter name.\n\n

For development purposes and evaluation of the fits, the option <i>Generate debug parameter images</i> is available.
Enabling this option will result in additional parameter maps displaying the status of the optimizer at fit termination.
In the following definitions, an <i>evaluation</i> describes the process of cost function calculation and evaluation by the optimizer for a given parameter set.

- <i>Stop condition</i>: Reasons for the fit termination, i.e. criterion reached, maximum number of iterations,...
- <i>Optimization time</i>: The overall time from fitting start to termination.
- <i>Number of iterations</i>: The number of iterations from fitting start to termination.
- <i>Constraint penalty ratio</i>: Ratio between evaluations that were penalized and all evaluations. 0.0 means no evaluation was penalized; 1.0 all evaluations were. Evaluations that hit the failure threshold count as penalized, too.
- <i>Constraint last failed parameter</i>: Ratio between evaluations that were beyond the failure threshold. 0.0 means no evaluation was a failure (but some may be penalized).
- <i>Constraint failure ratio</i>: Index of the first (in terms of index position) parameter, which failed the constraints in the last evaluation.

After all necessary configurations are set, the button <i>Start Modelling</i> is enabled, which starts the fitting routine.
Progress can be seen in the message box on the bottom. Resulting parameter maps will afterwards be added to the Data Manager as sub-nodes of the analyzed 4D image.

\section FIT_DCE_lit References/Literature
- \anchor FIT_DCE_lit_ref1 [1] Brix G, Semmler W, Port R, Schad LR, Layer G, Lorenz WJ. Pharmacokinetic parameters in CNS Gd-DTPA enhanced MR imaging. J Comput Assist Tomogr. 1991;15:621–8.
- \anchor FIT_DCE_lit_ref2 [2] Tofts PS, Kermode AG. Measurement of the blood-brain barrier permeability and leakage space using dynamic MR imaging. 1. Fundamental concepts. Magn Reson Med. 1991;17:357–67.
- \anchor FIT_DCE_lit_ref3 [3] Sourbron SP, Buckley DL. On the scope and interpretation of the Tofts models for DCE-MRI. Magn Reson Med. 2011;66:735–45.
- \anchor FIT_DCE_lit_ref4 [4] Brix G, Kiessling F, Lucht R, Darai S, Wasser K, Delorme S, et al. Microcirculation and microvasculature in breast tumors: Pharmacokinetic analysis of dynamic MR image series. Magn Reson Med. 2004;52:420–9.
- \anchor FIT_DCE_lit_ref5 [5] Sourbron, Buckley. Tracer kinetic modelling in MRI: estimating perfusion and capillary permeability - pdf. Phys Med Biol. 2012. https://iopscience.iop.org/article/10.1088/0031-9155/57/2/R1/pdf. Accessed 1 May 2016.



*/

