Documentation

class mrsimulator.signal_processor.Scale(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, factor: float = 1)

Scale the amplitudes of all dependent variables (y) from a CSDM object.

()\[f(y) = \text{factor} \times y\]
Parameters

factor (float) – The scaling factor. The default value is 1.

Example

>>> from mrsimulator import signal_processor as sp
>>> operation1 = sp.Scale(factor=20)
class mrsimulator.signal_processor.Linear(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, amplitude: float = 1, offset: float = 0)

Apply linear operation across all dependent variables (y) from a CSDM object.

()\[f(y) = \text{amplitude} \times y + \text{offset}\]
Parameters
  • amplitude (float) – The scaling factor. The default value is 1.

  • offset (float) – The offset factor. The default value is 0.

Example

>>> from mrsimulator import signal_processor as sp
>>> operation1 = sp.Linear(amplitude=20, offset=-10)
class mrsimulator.signal_processor.IFFT(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, dim_index: Union[int, list, tuple] = 0)

Apply an inverse Fourier transform on all dependent variables of the CSDM object.

Parameters

dim_index (Union[int, list, tuple]) – Dimension index along which the function is applied.

Example

>>> operation2 = sp.IFFT(dim_index=0)
class mrsimulator.signal_processor.FFT(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, dim_index: Union[int, list, tuple] = 0)

Apply a forward Fourier transform on all dependent variables of the CSDM object.

Parameters

dim_index (Union[int, list, tuple]) – Dimension index along which the function is applied.

Example

>>> operation3 = sp.FFT(dim_index=0)
class mrsimulator.signal_processor.baseline.ConstantOffset(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, offset: float = 0)

Add an offset to the dependent variables (y) of the CSDM object.

()\[y += \text{offset}\]

where \(y\) is the CSDM dependent variable.

Parameters

offset (float) – The offset factor. The default value is 0.

Example

>>> from mrsimulator import signal_processor as sp
>>> operation1 = sp.baseline.ConstantOffset(offset=20)
class mrsimulator.signal_processor.baseline.Polynomial(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, polynomial_dictionary: Dict = {}, dim_index: int = 0)

Add a baseline polynomial to all dependent variables (y) in the CSDM object.

The baseline polynomial function is

()\[f(x) = \sum_{i=0}^n c_i \times x^i,\]

where \(c_i\) are the coefficients corresponding to \(x^i\).

Parameters
  • polynomial_dictionary (Dict) – A dictionary of the form {‘ci’: coef}, where i represents the i-th order polynomial term and ‘coef’ is the leading coefficient for the i-th term. For example \(4x^2 + 5\) would be supplied as {‘c2’: 4, ‘c0’: 5}

  • dim_index (int) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

Example

>>> from mrsimulator import signal_processor as sp
>>> operation1 = sp.baseline.Polynomial(polynomial_dictionary = {'c0':10, 'c2':2})
class mrsimulator.signal_processor.apodization.Gaussian(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'FWHM': <Quantity 1.>}, dim_index: ~typing.Union[int, list, tuple] = 0, dv_index: ~typing.Union[int, list, tuple] = None, FWHM: ~typing.Union[float, str] = 0)

Apodize dependent variables of CSDM dataset with Gaussian function.

The apodization function follows

()\[f(x) = e^{-2 \pi^2 \sigma^2 x^2},\]

where \(x\) are the coordinates of the dimension, and \(\sigma\) is the standard deviation. The relationship between the standard deviation, \(\sigma\), and the full width at half maximum of the reciprocal domain Gaussian function follows

()\[\sigma = \frac{\text{FWHM}}{2\sqrt{2\ln 2}}.\]
Parameters
  • FWHM (Union[float, str]) – The full width at half maximum, FWHM, of the reciprocal domain Gaussian function given as a string with a value and a unit. The default value is 0.

  • dim_index (Union[int, list, tuple]) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

  • dv_index (Union[int, list, tuple]) – The index of the CSDM dependent variable, where the operation is applied. If not provided, the operation will be applied to every dependent variable.

Example

>>> operation4 = sp.apodization.Gaussian(FWHM='143.4 Hz', dim_index=0, dv_index=0)
class mrsimulator.signal_processor.apodization.Exponential(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'FWHM': <Quantity 1.>}, dim_index: ~typing.Union[int, list, tuple] = 0, dv_index: ~typing.Union[int, list, tuple] = None, FWHM: ~typing.Union[float, str] = 0)

Apodize dependent variables of CSDM by exponential function.

The apodization function follows

()\[f(x) = e^{-\Gamma \pi |x|},\]

where \(x\) are the coordinates of the dimension, and \(\Gamma\) is the width parameter. The relationship between the width parameter, \(\Gamma\), and the full width at half maximum for the reciprocal domain Lorentzian function follows

()\[\text{FWHM} = \Gamma.\]
Parameters
  • FWHM (Union[float, str]) – The full width at half maximum, FWHM, of the reciprocal domain Lorentzian function given as a string with a value and a unit. The default value is 0.

  • dim_index (Union[int, list, tuple]) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

  • dv_index (Union[int, list, tuple]) – The index of the CSDM dependent variable, where the operation is applied. If not provided, the operation will be applied to every dependent variable.

Example

>>> operation5 = sp.apodization.Exponential(FWHM='143.4 m', dim_index=0, dv_index=0)
class mrsimulator.signal_processor.apodization.SkewedGaussian(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'FWHM': <Quantity 1.>}, dim_index: ~typing.Union[int, list, tuple] = 0, dv_index: ~typing.Union[int, list, tuple] = None, skew: ~typing.Union[float, str] = 0, FWHM: ~typing.Union[float, str] = '2.354820045030949 Hz')

Apodize dependent variables of CSDM dataset with skewed Gaussian function.

The apodization function is derived from the skewed Gaussian distribution

()\[f(x) = 2\phi(x)\Phi(\alpha x),\]

where \(x\) are the coordinates of the dimension, and \(\phi\) is the standard normal probability density function, \(\Phi\) is the cumulative distribution function, and \(\alpha\) is a skewing parameter. The apodization function is the fourier transform of the above function which gives another skewed Gaussian function and is given by

()\[f(x) = e^{-2 (\pi x)^2} \left(1 + i\text{Erfi}\left(\frac{\text{skew}\cdot x}{\sqrt{2}}\right)\right),\]

where skew is given by

()\[\text{skew} = \frac{\alpha}{\sqrt{1+\alpha^2}}\]

See https://en.wikipedia.org/wiki/Skew_normal_distribution

Parameters
  • sigma – The full width at half maximum, FWHM, of the reciprocal domain Gaussian function given as a string with a value and a unit. The default value is 0.

  • skew (Union[float, str]) – The skewness defining the asymmetry of the Gaussian distribution

  • dim_index (Union[int, list, tuple]) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

  • dv_index (Union[int, list, tuple]) – The index of the CSDM dependent variable, where the operation is applied. If not provided, the operation will be applied to every dependent variable.

Example

>>> operation6 = sp.apodization.SkewedGaussian(skew=2, dim_index=0, dv_index=0)
class mrsimulator.signal_processor.apodization.TopHat(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'falling_edge': <Quantity 1.>, 'rising_edge': <Quantity 1.>}, dim_index: ~typing.Union[int, list, tuple] = 0, dv_index: ~typing.Union[int, list, tuple] = None, rising_edge: ~typing.Optional[~typing.Union[float, str]] = -inf, falling_edge: ~typing.Optional[~typing.Union[float, str]] = inf)

Apodize dependent variables of CSDM object by top hat function.

The apodization function follows

()\[f(x) = 1 \text{if rising_edge} <= x <= \text{falling_edge} , \text{else} f(x) = 0\]

where \(x\) are the coordinates of the dimension, rising_edge is the start of the function window, and falling_edge is the end of the function window.

Parameters
  • rising_edge (Optional[Union[float, str]]) – The lowest value in the time domain from which to start the function window. The default value is None which will take the lowest possible value for the supplied dataset.

  • falling_edge (Optional[Union[float, str]]) – The highest value in the time domain from which to end the function window. The default value is None which will take the largest possible value for the supplied dataset.

  • dim_index (Union[int, list, tuple]) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

  • dv_index (Union[int, list, tuple]) – The index of the CSDM dependent variable, where the operation is applied. If not provided, the operation will be applied to every dependent variable.

Example

>>> operation7= sp.apodization.TopHat(rising_edge = "-1 s", falling_edge = "1 s")
class mrsimulator.signal_processor.apodization.Mask(*, name: str = None, description: str = None, label: str = None, property_units: Dict = {}, dim_index: Union[int, list, tuple] = 0, dv_index: Union[int, list, tuple] = None, mask: Union[List[float], Array, float, int] = None)

Apodize dependent variables of CSDM object by user defined mask.

The apodization function follows

()\[f(x) = \text{mask}\]

where mask is a user-supplied numpy array containing an apodization mask to apply to the dataset.

Parameters
  • mask (Union[List[float], mrsimulator.signal_processor.apodization.Array, float, int]) – mask.

  • dim_index (Union[int, list, tuple]) – The index of the CSDM dimension along which the operation is applied. The default is the dimension at index 0.

  • dv_index (Union[int, list, tuple]) – The index of the CSDM dependent variable, where the operation is applied. If not provided, the operation will be applied to every dependent variable.

Example

class mrsimulator.signal_processor.affine.Shear(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'factor': <Quantity 1.>}, dim_index: int = 0, dv_index: ~typing.Union[int, list, tuple] = None, factor: ~typing.Union[float, str] = 0, parallel: int = 1)

Apply a shear parallel to dimension at index parallel and normal to dimension at index dim_index.

The shear function is an apodization with the following form

()\[f(x) = e^{-i 2\pi x_0 x_1 a_0},\]

where \(x_0\) are the coordinates of the dimension at index parallel, \(x_1\) are the coordinates of the dimension at index dim_index, and \(a_0\) is the shear constant.

Parameters
  • factor (str) – The shear factor is given as a string with a value and a unit. The default value is 0.

  • dim_index (int) – The shear is applied normal to the CSDM dimension at this index. The default is the dimension at index 0.

  • parallel (int) – The shear is applied parallel to the CSDM dimension at this index. The default is the dimension at index 1.

  • dv_index (int) – The index of the CSDM dependent variable where the operation is applied. If the value is None, the operation will be applied to every dependent variable.

Example

>>> operation = sp.affine.Shear(factor='143.4 Hz', dim_index=0, parallel=1)
class mrsimulator.signal_processor.affine.Scale(*, name: str = None, description: str = None, label: str = None, property_units: ~typing.Dict = {'factor': <Quantity 1.>}, dim_index: int = 0, dv_index: ~typing.Union[int, list, tuple] = None, factor: ~typing.Union[float, str] = 1)

Scale the dimension along the specified dimension index.

Parameters
  • factor (str) – The scaling factor. The default is 1.

  • dim_index (int) – The index of the CSDM dimension to scale. The default is the dimension at index 0.

Example

>>> operation = sp.affine.Scale(factor=2.14, dim_index=0)