# imaging.m

Fokker-Planck imaging simulation context. Generates the Hamiltonian, the relaxation superoperator, the kinetics superoperator, the Fokker-Planck spatial dynamics generator (including diffusion and flow), gradient operators, and passes all of that to the pulse sequence, which should be supplied as a handle.

## Syntax

    answer=imaging(spin_system,pulse_sequence,parameters)


## Arguments

  pulse_sequence     - pulse sequence function handle. See the
experiments directory for the list of
pulse sequences that ship with Spinach.

parameters.u       - X components of the velocity vectors
for each point in the sample, m/s

parameters.v       - Y components of the velocity vectors
for each point in the sample, m/s

parameters.w       - Z components of the velocity vectors
for each point in the sample, m/s

parameters.diff    - diffusion coefficient or 3x3 tensor, m^2/s
for situations when this parameter is the
same in every voxel

parameters.dxx     - Cartesian components of the diffusion
parameters.dxy       tensor for each voxel of the sample
...
parameters.dzz

parameters.dims    - dimensions of the 3D box, meters

parameters.npts    - number of points in each dimension
of the 3D box

parameters.deriv   - {'fourier'} uses Fourier diffe-
rentiation matrices; {'period',n}
requests n-point central finite-
difference matrices with periodic
boundary conditions


Three types of phantoms must be specified. The relaxation theory phantom contains relaxation superoperators and their coefficients in each voxel, specified in the following way:

                parameters.rlx_ph={Ph1,Ph2,...,PhN}
parameters.rlx_op={R1,R2,...,RN}


where PhN have the same dimension as the sample voxel grid and RN are relaxation superoperators. The initial condition phantom reflects the fact that different voxels might start off in a different spin state. It must be specified in the following way:

                parameters.rho0_ph={Ph1,Ph2,...,PhN}
parameters.rho0_op={rho1,rho2,...,rhoN}


where PhN have the same dimension as the sample voxel grid and rhoN are spin states obtained from state() function. The detection state phantom reflects the fact that different voxels might be detected at different ngles and with different sensitivity. It must be specified in the following way:

                parameters.coil_ph={Ph1,Ph2,...,PhN}
parameters.coil_op={rho1,rho2,...,rhoN}


where PhN have the same dimension as the sample voxel grid and rhoN are spin states obtained from state() function.

## Outputs

This function returns whatever the pulse sequence returns.

## Examples

All MRI, ultrafast NMR, and spatially encoded NMR experiments use this context. Representative examples are:

imaging/dpfgse_select.m - DPFGSE signal selection

imaging/echo_planar_2d.m - 2D echo planar MRI image

imaging/phase_enc_3d.m - phase encoded MRI image of a 2D slice through a 3D phantom

imaging/diff_weighted_2d.m - 2D diffusion weighted MRI image

nmr_spen/psyche_two_spin.m - PSYCHE pure shift experiment

nmr_spen/ufdosy_test_1.m - ultrafast DOSY experiment

## Notes

1. The direct product order is Z(x)Y(x)X(x)Spin, this corresponds to a column-wise vectorization of a 3D array with dimensions ordered as [X Y Z].
2. Very large imaging calculations always benefit from Tesla cards (add 'gpu' to sys.enable) and may benefit from polyadic array processing (add 'polyadic' to sys.enable).
3. Fourier derivatives are precise but expensive. If your accuracy requirements are not seven decimal places, consider using finite difference derivatives.