Method

class mrsimulator.Method(*, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, name: str = None, label: str = None, description: str = None, channels: List[str] = [], spectral_dimensions: List[mrsimulator.method.spectral_dimension.SpectralDimension] = [SpectralDimension(property_units={'spectral_width': 'Hz', 'reference_offset': 'Hz', 'origin_offset': 'Hz'}, count=1024, spectral_width=25000.0, reference_offset=0.0, origin_offset=None, label=None, description=None, events=[])], affine_matrix: Union[numpy.ndarray, List] = None, simulation: Union[csdmpy.csdm.CSDM, numpy.ndarray] = None, experiment: Union[csdmpy.csdm.CSDM, numpy.ndarray] = None)

Bases: mrsimulator.utils.parseable.Parseable

Base Method class. A method class represents the NMR method.

channels

The value is a list of isotope symbols over which the given method applies. An isotope symbol is given as a string with the atomic number followed by its atomic symbol, for example, ‘1H’, ‘13C’, and ‘33S’. The default is an empty list. The number of isotopes in a channel depends on the method. For example, a BlochDecaySpectrum method is a single channel method, in which case, the value of this attribute is a list with a single isotope symbol, [‘13C’].

Example

>>> bloch = Method()
>>> bloch.channels = ['1H']
Type

list (optional)

spectral_dimensions

The number of spectral dimensions depends on the given method. For example, a BlochDecaySpectrum method is a one-dimensional method and thus requires a single spectral dimension. The default is a single default SpectralDimension object.

Example

>>> bloch = Method()
>>> bloch.spectral_dimensions = [SpectralDimension(count=8, spectral_width=50)]
>>> # or equivalently
>>> bloch.spectral_dimensions = [{'count': 8, 'spectral_width': 50}]
Type

list of SpectralDimension or dict objects (optional).

simulation

An object holding the result of the simulation. The initial value of this attribute is None. A value is assigned to this attribute when you run the simulation using the run() method.

Type

CSDM or ndarray (N/A)

experiment

An object holding the experimental measurement for the given method, if available. The default value is None.

Example

>>> bloch.experiment = my_data 
Type

CSDM or ndarray (optional)

name

The value is the name or id of the method. The default value is None.

Example

>>> bloch.name = 'BlochDecaySpectrum'
>>> bloch.name
'BlochDecaySpectrum'
Type

str (optional)

label

The value is a label for the method. The default value is None.

Example

>>> bloch.label = 'One pulse acquired spectrum'
>>> bloch.label
'One pulse acquired spectrum'
Type

str (optional)

description

The value is a description of the method. The default value is None.

Example

>>> bloch.description = 'Huh!'
>>> bloch.description
'Huh!'
Type

str (optional)

Method Documentation

classmethod parse_dict_with_units(py_dict)

Parse the physical quantity from a dictionary representation of the Method object, where the physical quantity is expressed as a string with a number and a unit.

Parameters

py_dict (dict) – A python dict representation of the Method object.

Returns

A Method object.

json()

Parse the class object to a JSON compliant python dictionary object where the attribute value with physical quantity is expressed as a string with a value and a unit.

Returns

A python dict object.

update_spectral_dimension_attributes_from_experiment()

Update the spectral dimension attributes of the method to match the attributes of the experiment from the experiment attribute.

get_transition_pathways(spin_system) → list

Return a list of transition pathways from the given spin system that satisfy the query selection criterion of the method.

Parameters

spin_system (SpinSystem) – A SpinSystem object.

Returns

An array of TransitionPathway objects. Each TransitionPathway object is an ordered collection of Transition objects.

SpectralDimension

class mrsimulator.SpectralDimension(*, property_units: Dict = {'origin_offset': 'Hz', 'reference_offset': 'Hz', 'spectral_width': 'Hz'}, count: mrsimulator.method.spectral_dimension.ConstrainedIntValue = 1024, spectral_width: mrsimulator.method.spectral_dimension.ConstrainedFloatValue = 25000.0, reference_offset: float = 0.0, origin_offset: float = None, label: str = None, description: str = None, events: List[mrsimulator.method.event.Event] = [])

Bases: mrsimulator.utils.parseable.Parseable

Base SpectralDimension class defines a spectroscopic dimension of the method.

count

The number of points, \(N\), along the spectroscopic dimension. The default value is 1024.

Type

int (optional)

spectral_width

The spectral width, \(\Delta x\), of the spectroscopic dimension in units of Hz. The default value is 25000.

Type

float (optional)

reference_offset

The reference offset, \(x_0\), of the spectroscopic dimension in units of Hz. The default value is 0.

Type

float (optional)

origin_offset

The origin offset (Larmor frequency) along the spectroscopic dimension in units of Hz. The default value is None. When the value is None, the origin offset is set to the Larmor frequency of the isotope from the channels attribute of the method.

Type

float (optional)

label

The value is a label of the spectroscopic dimension. The default value is None.

Type

str (optional)

description

The value is a description of the spectroscopic dimension. The default value is None.

Type

str (optional)

events

The value describes a series of events along the spectroscopic dimension.

Type

A list of Event or equivalent dict objects (optional).

Method Documentation

classmethod parse_dict_with_units(py_dict: dict)

Parse the physical quantities of a SpectralDimension object from a python dictionary object.

Parameters

py_dict (dict) – Dict object

coordinates_Hz()numpy.ndarray

The grid coordinates along the dimension in units of Hz, evaluated as

(26)\[x_\text{Hz} = \left([0, 1, ... N-1] - T\right) \frac{\Delta x}{N} + x_0\]

where \(T=N/2\) and \(T=(N-1)/2\) for even and odd values of \(N\), respectively.

coordinates_ppm()numpy.ndarray

The grid coordinates along the dimension as dimension frequency ratio in units of ppm. The coordinates are evaluated as

(27)\[x_\text{ppm} = \frac{x_\text{Hz}} {x_0 + \omega_0}\]

where \(\omega_0\) is the Larmor frequency.

json() → dict

Parse the class object to a JSON compliant python dictionary object where the attribute value with physical quantity is expressed as a string with a number and a unit.

to_csdm_dimension() → csdmpy.dimensions.Dimension

Return the spectral dimension as a CSDM dimension object.

Event

class mrsimulator.Event(*, property_units: Dict = {'magnetic_flux_density': 'T', 'rotor_angle': 'rad', 'rotor_frequency': 'Hz'}, fraction: float = 1.0, magnetic_flux_density: mrsimulator.method.event.ConstrainedFloatValue = 9.4, rotor_frequency: mrsimulator.method.event.ConstrainedFloatValue = 0.0, rotor_angle: mrsimulator.method.event.ConstrainedFloatValue = 0.955316618, freq_contrib: List[mrsimulator.method.frequency_contrib.FrequencyEnum] = [<FrequencyEnum.Shielding1_0: 'Shielding1_0'>, <FrequencyEnum.Shielding1_2: 'Shielding1_2'>, <FrequencyEnum.Quad1_2: 'Quad1_2'>, <FrequencyEnum.Quad2_0: 'Quad2_0'>, <FrequencyEnum.Quad2_2: 'Quad2_2'>, <FrequencyEnum.Quad2_4: 'Quad2_4'>], transition_query: mrsimulator.method.transition_query.TransitionQuery = TransitionQuery(P={'channel-1': [[-1.0]]}, D=None, f=None, transitions=None))

Bases: mrsimulator.utils.parseable.Parseable

Base Event class defines the spin environment and the transition query for a segment of the transition pathway.

fraction

A required float containing the weight of the frequency contribution from the event.

magnetic_flux_density

An optional float containing the macroscopic magnetic flux density, \(H_0\), of the applied external magnetic field during the event in units of T. The default value is 9.4.

rotor_frequency

An optional float containing the sample spinning frequency \(\nu_r\), during the event in units of Hz. The default value is 0.

rotor_angle

An optional float containing the angle between the sample rotation axis and the applied external magnetic field, \(\theta\), during the event in units of rad. The default value is 0.9553166, i.e. the magic angle.

transition_query

An optional TransitionQuery object or an equivalent dict object listing the queries used in selecting the active transitions during the event. Only the active transitions from this query contribute to the frequency.

Method Documentation

classmethod parse_dict_with_units(py_dict: dict)

Parse the physical quantities of an Event object from a python dictionary object.

Parameters

py_dict (dict) – Dict object

json()

Parse the class object to a JSON compliant python dictionary object where the attribute value with physical quantity is expressed as a string with a number and a unit.