src.original.fitting.IAR_LundUniversity package

Submodules

src.original.fitting.IAR_LundUniversity.ivim_fit_method_biexp module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_biexp.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_biexp.IvimModelBiExp(gtab, bounds=None, initial_guess=None, rescale_units=False)[source]

Bases: ReconstModel

fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

ivim_model(b, S0, f, D_star, D)[source]
rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]

src.original.fitting.IAR_LundUniversity.ivim_fit_method_linear module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_linear.IvimFit(model, model_params)[source]

Bases: object

property D
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_linear.IvimModelLinear(gtab, b_threshold=200, bounds=None, rescale_units=False)[source]

Bases: ReconstModel

fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]
sivim_model(b, S0, f, D)[source]

src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_mix module

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_mix.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_mix.IvimModelVP(gtab, bounds=None, maxiter=10, xtol=1e-08, rescale_units=False, rescale_results_to_mm2_s=False)[source]

Bases: ReconstModel

cvx_fit(signal, phi)[source]

Performs the constrained search for the linear parameters f after the estimation of x is done. Estimation of the linear parameters f is a constrained linear least-squares optimization problem solved by using a convex optimizer from cvxpy. The IVIM equation contains two parameters that depend on the same volume fraction. Both are estimated as separately in the convex optimizer. Parameters ———- phi : array

Returns an array calculated from :func: phi.

signalarray

The signal values measured for this model.

Returns

f1, f2 (volume fractions) Notes —– cost function for differential evolution algorithm: .. math:

minimize(norm((signal)- (phi*f)))
fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

ivim_mix_cost_one(phi, signal)[source]

Constructs the objective for the :func: stoc_search_cost. First calculates the Moore-Penrose inverse of the input phi and takes a dot product with the measured signal. The result obtained is again multiplied with phi to complete the projection of the variable into a transformed space. (see [1]_ and [2]_ for thorough discussion on Variable Projections and relevant cost functions). Parameters ———- phi : array

Returns an array calculated from :func: Phi.

signalarray

The signal values measured for this model.

Returns

(signal - S)^T(signal - S) Notes —– to make cost function for Differential Evolution algorithm: .. math:

(signal -  S)^T(signal -  S)

References

nlls_cost(x_f, signal)[source]

Cost function for the least square problem. The cost function is used in the Least Squares function of SciPy in :func: fit. It guarantees that stopping point of the algorithm is at least a stationary point with reduction in the the number of iterations required by the differential evolution optimizer. Parameters ———- x_f : array

Contains the parameters ‘x’ and ‘f’ combines in the same array.

signalarray

The signal values measured for this model.

Returns

sum{(signal - phi*f)^2} Notes —– cost function for the least square problem. .. math:

sum{(signal -  phi*f)^2}
phi(x)[source]

Creates a structure for the combining the diffusion and pseudo- diffusion by multiplying with the bvals and then exponentiating each of the two components for fitting as per the IVIM- two compartment model. Parameters ———-

xarray

input from the Differential Evolution optimizer.

Returns

exp_phi1array

Combined array of parameters perfusion/pseudo-diffusion and diffusion parameters.

stoc_search_cost(x, signal)[source]

Cost function for differential evolution algorithm. Performs a stochastic search for the non-linear parameters ‘x’. The objective function is calculated in the :func: ivim_mix_cost_one. The function constructs the parameters using :func: phi. Parameters ———- x : array

input from the Differential Evolution optimizer.

signalarray

The signal values measured for this model.

Returns

func:

ivim_mix_cost_one

x_and_f_to_x_f(x, f)[source]

Combines the array of parameters ‘x’ and ‘f’ into x_f for performing NLLS on the final stage of optimization. Parameters ———-

x, farray

Split parameters into two separate arrays

Returns

x_farray

Combined array of parameters ‘x’ and ‘f’ parameters.

x_f_to_x_and_f(x_f)[source]

Splits the array of parameters in x_f to ‘x’ and ‘f’ for performing a search on the both of them independently using the Trust Region Method. Parameters ———- x_f : array

Combined array of parameters ‘x’ and ‘f’ parameters.

Returns

x, farray

Split parameters into two separate arrays

src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_topopro module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_topopro.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_modified_topopro.IvimModelTopoPro(gtab, bounds=[[0, 0.005, 1e-05], [1, 0.1, 0.004]], rescale_units=False, shgo_iters=5, rescale_results_to_mm2_s=False)[source]

Bases: ReconstModel

cvx_fit(signal, phi)[source]

Performs the constrained search for the linear parameters f after the estimation of x is done. Estimation of the linear parameters f is a constrained linear least-squares optimization problem solved by using a convex optimizer from cvxpy. The IVIM equation contains two parameters that depend on the same volume fraction. Both are estimated as separately in the convex optimizer.

Parameters

phiarray

Returns an array calculated from :func: phi.

signalarray

The signal values measured for this model.

Returns

f1, f2 (volume fractions)

Notes

cost function for differential evolution algorithm:

\[minimize(norm((signal)- (phi*f)))\]
fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

ivim_shgo(phi, signal)[source]

Constructs the objective for the :func: stoc_search_cost.

First calculates the Moore-Penrose inverse of the input phi and takes a dot product with the measured signal. The result obtained is again multiplied with phi to complete the projection of the variable into a transformed space. (see [1]_ and [2]_ for thorough discussion on Variable Projections and relevant cost functions).

Parameters

phiarray

Returns an array calculated from :func: Phi.

signalarray

The signal values measured for this model.

Returns

(signal - S)^T(signal - S)

Notes

to make cost function for Differential Evolution algorithm: .. math:

(signal -  S)^T(signal -  S)

References

nlls_cost(x_f, signal)[source]

Cost function for the least square problem. The cost function is used in the Level 2 of TopoPro algorithm :func: fit.

Parameters

x_farray

Contains the parameters ‘x’ and ‘f’ combines in the same array.

signalarray

The signal values measured for this model.

Returns

sum{(signal - phi*f)^2}

Notes

cost function for the least square problem.

\[sum{(signal - phi*f)^2}\]
phi(x)[source]

Creates a structure for the combining the diffusion and pseudo- diffusion by multipling with the bvals and then exponentiating each of the two components for fitting as per the IVIM- two compartment model.

Parameters

xarray

input from the Differential Evolution optimizer.

Returns

exp_phi1array

Combined array of parameters perfusion/pseudo-diffusion and diffusion parameters.

rescale_bounds_and_initial_guess(rescale_units)[source]
stoc_search_cost(x, signal)[source]

Cost function for SHGO algorithm. Performs an approximation of the homology groups of a complex built on a hypersurface homeomorphic to a complex on the objective function for the non-linear parameters ‘x’. The objective funtion is calculated in the :func: ivim_shgo. The function constructs the parameters using :func: phi.

Parameters

xarray

input from the Simplicial Homology optimizer.

signalarray

The signal values measured for this model.

Returns

func:

ivim_shgo

x_and_f_to_x_f(x, f)[source]

Combines the array of parameters ‘x’ and ‘f’ into x_f for performing SHGO on the Level 2 of the optimization process.

Parameters

x, farray

Splitted parameters into two separate arrays

Returns

x_farray

Combined array of parameters ‘x’ and ‘f’ parameters.

x_f_to_x_and_f(x_f)[source]

Splits the array of parameters in x_f to ‘x’ and ‘f’ for performing a search on the both of them independently using the simplicial homology optimizer (SHGO).

Parameters

x_farray

Combined array of parameters ‘x’ and ‘f’ parameters.

Returns

x, farray

Splitted parameters into two separate arrays

src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_2step module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_2step.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_2step.IvimModelSegmented2Step(gtab, b_threshold=200, initial_guess=None, perf_initial_guess=None, bounds=None, rescale_units=False)[source]

Bases: ReconstModel

diffusion_signal(b, S0, D)[source]
fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

ivim_signal(b, S0, f, D_star, D)[source]
perfusion_signal(b, S0, D_star)[source]
rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]

src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_3step module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_3step.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_segmented_3step.IvimModelSegmented3Step(gtab, b_threshold_upper=100, b_threshold_lower=200, initial_guess=None, bounds=None, rescale_units=False)[source]

Bases: ReconstModel

diffusion_signal(b, S0, D)[source]
fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

ivim_signal(b, S0, f, D_star, D)[source]
perfusion_signal(b, S0, D_star)[source]
rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]

src.original.fitting.IAR_LundUniversity.ivim_fit_method_sivim module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_sivim.IvimFit(model, model_params)[source]

Bases: object

property D
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_sivim.IvimModelsIVIM(gtab, b_threshold=200, bounds=None, initial_guess=None, rescale_units=False)[source]

Bases: ReconstModel

fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]
sivim_model(b, S0, f, D)[source]

src.original.fitting.IAR_LundUniversity.ivim_fit_method_subtracted module

Classes and functions for fitting ivim model

class src.original.fitting.IAR_LundUniversity.ivim_fit_method_subtracted.IvimFit(model, model_params)[source]

Bases: object

property D
property D_star
property S0_predicted
property perfusion_fraction
property shape
class src.original.fitting.IAR_LundUniversity.ivim_fit_method_subtracted.IvimModelSubtracted(gtab, b_threshold_upper=100, b_threshold_lower=200, initial_guess=None, bounds=None, rescale_units=False)[source]

Bases: ReconstModel

diffusion_signal(b, S0, D)[source]
fit(data, *, mask=None, **kwargs)

Fit method for every voxel in data

perfusion_signal(b, S0, D_star)[source]
rescale_bounds_and_initial_guess(rescale_units)[source]
set_bounds(bounds)[source]
set_initial_guess(initial_guess)[source]

Module contents