Model

from mcot.dippi.model import Model
class mcot.dippi.model.Model(shells: mcot.dippi.scan.MultiShell, T2=False, dual_phase=False, only_phase=False)[source]

Model to fit to the DIPPI data

__init__(shells: mcot.dippi.scan.MultiShell, T2=False, dual_phase=False, only_phase=False)[source]

Creates a new DIPPI model

Parameters
  • shells – Describes the acquisition parameters

  • T2 – if True fit R2 and R2* instead of fitting each amplitude independently

  • dual_phase – if True fit unmyelinated and myelinated axons as separate compartments

  • only_phase – Ignore the biophysical model and just fit the phase difference between readouts for every dyad

Inheritance diagram

Inheritance diagram of mcot.dippi.model.Model

Methods

cost(parameters, data[, only_mag])

Squared offset between the model signal and observed data

derivative(name)

Computes the derivative with respect to a given parameter

func_args(parameters[, to_vary])

Fills in the arguments for the numpy functions from self.:meth:funcs

funcs([derivative, only_mag])

Return the model equations as numpy functions

get_cost(parameters, data, tofit[, only_mag])

Returns a set of functions that allows for efficient evalution of the model during model optimisation

signal(parameters[, only_mag, split_fibres])

Computes the signal given a set of parameters

cost

Model.cost(parameters: mcot.dippi.model.Parameters, data, only_mag=False)[source]

Squared offset between the model signal and observed data

Parameters
  • parameters – set of model parameters

  • data – input data (list with for each shell the complex signal during first and second readout)

  • only_mag – if True only consider the magnitude rather than the complex signal

Returns

total cost across all shells and readouts

derivative

Model.derivative(name)[source]

Computes the derivative with respect to a given parameter

This function uses cacheing

Parameters

name – name of one of the parameters

Returns

sympy equations with derivative as a list with the equation for each shell and both readouts

func_args

Model.func_args(parameters: mcot.dippi.model.Parameters, to_vary=())[source]

Fills in the arguments for the numpy functions from self.:meth:funcs

Parameters
  • parameters – current best estimate of the parameters

  • to_vary – names of the parameters that should not be filled in yet (None placeholder)

Returns

for each shell a list of arguments (which are the same for the first and second readout)

funcs

Model.funcs(derivative=None, only_mag=False)[source]

Return the model equations as numpy functions

Parameters
  • derivative – set to a name to return the derivative with respect to that parameter

  • only_mag – if True only compute the magnitude rather than the complex signal

Returns

for each shell return a tuple with functions for the first and second readout signal (or its derivatives)

get_cost

Model.get_cost(parameters: mcot.dippi.model.Parameters, data, tofit, only_mag=False)[source]

Returns a set of functions that allows for efficient evalution of the model during model optimisation

Used internally by singla_fit() and model_fit.

Parameters
  • parameters – initial set of parameters

  • data – input data (list with for each shell the complex signal during first and second readout)

  • tofit – sequence with parameter names to fit

  • only_mag – if True only fit the mangitude rather than the complex signal

Returns

A tuple with:

  • function that given an array with current parameter values returns the cost and its derivatives

  • function that turns array of best-fit parameter values back into a Parameter object

  • array with initial parameter values

signal

Model.signal(parameters: mcot.dippi.model.Parameters, only_mag=False, split_fibres=False)[source]

Computes the signal given a set of parameters

Parameters
  • parameters – set of model parameters

  • only_mag – if True return the magnitude rather than the complex signal

  • split_fibres – if True return the signal for each fibre population individually

Returns

a list with for each shell the signal during the first and second readout