resomapper.model_fitting.Tmapfit ================================ .. py:module:: resomapper.model_fitting.Tmapfit Functions --------- .. autoapisummary:: resomapper.model_fitting.Tmapfit.signal_equation_T1 resomapper.model_fitting.Tmapfit.signal_equation_T2T2star resomapper.model_fitting.Tmapfit.Fobj_SSE_Tmaps resomapper.model_fitting.Tmapfit.Tmapfit_voxel_GridSearch resomapper.model_fitting.Tmapfit.Tmapfit_voxel_2timesanalitical resomapper.model_fitting.Tmapfit.Tmapfit_voxel_linear resomapper.model_fitting.Tmapfit.Tmapfit_voxel_nonlinear resomapper.model_fitting.Tmapfit.Tmapfit_slice resomapper.model_fitting.Tmapfit.Tmapfit_image Module Contents --------------- .. py:function:: signal_equation_T1(mri_tr, tissue_par) Generate the signal for a spin echo experiment at variable TR PARAMETERS - mri_tr: list/array indicating the TRs (repetition times, in ms) used for the experiment (one measurement per TR) - tissue_par: list/array of tissue parameters, in the following order: tissue_par[0] = S0 (T1-weighted proton density) tissue_par[1] = T1 (longitudinal relaxation time, in ms) RETURNS - signal: a numpy array of measurements generated according to a multi-repetition time acquistion, signal = S0 * 1 - (exp(-TR/T1)) where TR is the repetition time and where S0 and T1 are the tissue parameters (S0 is the T1-weighted proton density, and T1 is the longitudinal relaxation time, i.e. T1). References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Author: Francesco Grussu, University College London CDSQuaMRI Project .. py:function:: signal_equation_T2T2star(mri_te, tissue_par) Generate the signal for a multi-echo experiment at fixed TR PARAMETERS - mri_te: list/array indicating the TEs (echo times, in ms) used for the experiment (one measurement per TR) - tissue_par: list/array of tissue parameters, in the following order: tissue_par[0] = S0 (T1-weighted proton density) tissue_par[1] = T2 or T2star (transvere relaxation time), in ms RETURNS - signal: a numpy array of measurements generated according to a multi-echo signal model, signal = S0 * exp(-TE/T2) where TE is the echo time and where S0 and T2 are the tissue parameters (S0 is the T1-weighted proton density, and T2 is the transverse relaxation time, i.e. T2 or T2*). Dependencies (Python packages): numpy References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Author: Francesco Grussu, University College London CDSQuaMRI Project .. py:function:: Fobj_SSE_Tmaps(tissue_par, mri_times, meas, signal_equation) Fitting objective function for exponential decay signal model PARAMETERS - tissue_par: list/array of tissue parameters, in the following order: tissue_par[0] = S0 (T1-weighted proton density) tissue_par[1] = either T1 (longitudinal relaxation time), T2 or T2star (transverse relaxation time), in ms - mri_times: list/array indicating the TRs (repetition times) or TEs (echo times), in ms used for the experiment (one measurement per TE) - meas: list/array of measurements RETURNS - fobj: objective function measured as sum of squared errors (SSE) between measurements and predictions, i.e. fobj = SUM_OVER_n( (prediction - measurement)^2 ) Above, the prediction are obtained using the multi-echo signal model implemented by function signal_equation_multiTE(). References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Author: Francesco Grussu, University College London CDSQuaMRI Project .. py:function:: Tmapfit_voxel_GridSearch(mri_times, meas, T_type) Grid search for non-linear fitting of exponential decay signal models PARAMETERS - mri_times: list/array indicating the TEs (echo times, in ms) used for the experiment (one measurement per TE) - meas: list/array of measurements RETURNS - tissue_estimate: estimate of tissue parameters that explain the measurements reasonably well. The parameters are estimated sampling the fitting objective function Fobj_T2fitting_multiTE() over a grid; the output is tissue_estimate[0] = S0 (T1-weighted proton density) tissue_estimate[1] = T2 or T2star (transverse relaxation time, in ms) - fobj_grid: value of the objective function when the tissue parameters equal tissue_estimate References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Author: Francesco Grussu, University College London CDSQuaMRI Project .. py:function:: Tmapfit_voxel_2timesanalitical(sig_voxel, time_values, T_type) .. py:function:: Tmapfit_voxel_linear(sig_voxel, time_values, T_type) .. py:function:: Tmapfit_voxel_nonlinear(sig_voxel, time_values, param_init, fobj_init, T_type) .. py:function:: Tmapfit_slice(data) Fit T1 for a multi-echo experiment on one MRI slice stored as a 2D numpy array INTERFACE data_out = Tmapfit_slice(data) PARAMETERS - data: a list of 7 elements, such that signal_slice is a 3D numpy array contaning the data to fit. The first and second dimensions of data[0] are the slice first and second dimensions, whereas the third dimension of data[0] stores measurements obtained with different flip angles time_values is a numpy monodimensional array storing the TR values (ms) non_linear_fitting is a boolean describing the fitting algorithm (False if only "linear" or True if "nonlinear") mask_slice is a 2D numpy array contaning the fitting mask within the MRI slice (see Tmapfit_image()) idx_slice is a scalar containing the index of the MRI slice in the 3D volume RETURNS - data_out: a list of 4 elements, such that data_out[0] is the parameter S0 (see Tmapfit_image()) within the MRI slice data_out[1] is the parameter T1 (see Tmapfit_image()) within the MRI slice data_out[2] is the exit code of the fitting (see Tmapfit_image()) within the MRI slice data_out[3] is the fitting sum of squared errors withint the MRI slice data_out[4] equals data[4] Fitted parameters in data_out will be stored as double-precision floating point (FLOAT64) References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Author: Francesco Grussu, University College London CDSQuaMRI Project .. py:function:: Tmapfit_image(sig_nifti, times_file, output_rootname, T_type, non_linear_fitting=True, ncpu=None, mask_nifti=None) Fit T1 for multi-echo experiment PARAMETERS - me_nifti: path of a Nifti file storing the multi-echo data as 4D data. - te_text: path of a text file storing the echo times (ms) used to acquire the data. - output_basename: base name of output files. Output files will end in "_S0ME.nii" --> T1-weighted proton density, with receiver coil field bias "_T1ME.nii" --> T1 (ms) "_ExitME.nii" --> exit code (1: successful fitting; 0 background; -1: unsuccessful fitting) "_SSEME.nii" --> fitting sum of squared errors Note that in the background and where fitting fails, S0, T1 and MSE are set to 0.0 Output files will be stored as double-precision floating point (FLOAT64) - non_linear_fitting: fitting algorithm ("linear" or "nonlinear") - ncpu: number of processors to be used for computation - mask_nifti: path of a Nifti file storing a binary mask, where 1 flgas voxels where the signal model needs to be fitted, and 0 otherwise References: "Quantitative MRI of the brain", 2nd edition, Tofts, Cercignani and Dowell editors, Taylor and Francis Group Dependencies: numpy, nibabel, scipy (other than standard library) Author: Francesco Grussu, University College London CDSQuaMRI Project