-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Sphinx build info version 1 | ||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. | ||
config: b683366407baf893adbd59b1e1506c71 | ||
tags: 645f666f9bcd5a90fca523b33c5a78b7 |
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
# Bloch Simulation | ||
|
||
```{eval-rst} | ||
.. automodule:: deepmr.bloch | ||
``` | ||
|
||
## Numerical Models | ||
```{eval-rst} | ||
.. currentmodule:: deepmr.bloch | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.bloch.mprage | ||
deepmr.bloch.memprage | ||
deepmr.bloch.bssfpmrf | ||
deepmr.bloch.ssfpmrf | ||
deepmr.bloch.fse | ||
deepmr.bloch.t1t2shuffling | ||
``` | ||
|
||
## Custom signal models | ||
|
||
DeepMR also contains helper classes to define custom signal models. The main class for analytical and numerical models are `deepmr.bloch.AnalyticalSimulator` | ||
and `deepmr.bloch.EPGSimulator`, respectively. | ||
|
||
Users can define a custom signal model by subclassing it and overloading ``sequence`` method. Base class already handle spin parameters (e.g., ``T1``, ``T2``, ...) | ||
as well as simulation properties (e.g., computational ``device``, maximum ``number of batches``...) so the user has only to care about specific sequence arguments (e.g., ``flip angle``, ``TR``, ... for GRE or ``flip angle``, ``ETL``, for FSE). In order to work properly, ``sequence`` method must be a ``staticmethod`` and the arguments must follow this order: | ||
|
||
1. sequence parameters (``flip angle``, ``TE``, ``TR``, ``nrepetitions``, ...) | ||
2. spin parameters (``T1``, ``T2``, ``B1``, ...) | ||
3. (mandatory) buffer for output signal (analytical) or EPG states and output signal (numerical): ``signal`` / `` states``, ``signal`` | ||
|
||
```python | ||
from deepmr import bloch | ||
from deepmr.bloch import ops | ||
|
||
class SSFP(bloch.EPGSimulator): | ||
|
||
@staticmethod | ||
def signal(flip, TR, T1, T2, states, signal): | ||
|
||
# get device and sequence length | ||
device = flip.device | ||
npulses = flip.shape[-1] | ||
|
||
# define operators | ||
T = ops.RFPulse(device, alpha=flip) # RF pulse | ||
E = ops.Relaxation(device, TR, T1, T2) # relaxation until TR | ||
S = ops.Shift() # gradient spoil | ||
|
||
# apply sequence | ||
for n in range(npulses): | ||
states = T(states) | ||
signal[n] = ops.observe(states) | ||
states = E(states) | ||
states = S(states) | ||
|
||
# return output | ||
return signal | ||
``` | ||
|
||
The resulting class can be used to perform simulation by instantiating an object (spin properties as input)and using the ``__call__`` method (sequence properties as input): | ||
|
||
```python | ||
ssfp = SSFP(device=device, T1=T1, T2=T2) # build simulator | ||
signal = ssfp(flip=flip, TR=TR) # run simulation | ||
``` | ||
|
||
For convenience, simulator instantiation and actual simulation can (and should) be wrapped in a wrapper function: | ||
|
||
```python | ||
def simulate_ssfp(flip, TR, T1, T2, device="cpu"): | ||
mysim = SSFP(device=device, T1=T1, T2=T2) | ||
return ssfp(flip=flip, TR=TR) | ||
``` | ||
|
||
The class also enable automatic forward differentiation wrt to input spin parameters via ``diff`` argument: | ||
|
||
```python | ||
import numpy as np | ||
|
||
def simulate_ssfp(flip, TR, T1, T2, diff=None, device="cpu"): | ||
ssfp = SSFP(device=device, T1=T1, T2=T2, diff=diff) | ||
return ssfp(flip=flip, TR=TR) | ||
|
||
# this will return signal only (evolution towards steady state of unbalanced SSFP sequence) | ||
signal = simulate_ssfp(flip=10.0*np.ones(1000, dtype=np.float32), TR=4.5, T1=500.0, T2=50.0) | ||
|
||
# this will also return derivatives | ||
signal, dsignal = simulate_ssfp(flip=10.0*np.ones(1000, dtype=np.float32), TR=8.5, T1=500.0, T2=50.0, diff=("T1", "T2")) | ||
|
||
# dsignal[0] = dsignal / dT1 (derivative of signal wrt T1) | ||
# dsignal[1] = dsignal / dT2 (derivative of signal wrt T2) | ||
``` | ||
|
||
This is useful e.g. for nonlinear fitting and for calculating objective functions (CRLB) for sequence optimization. | ||
|
||
To facilitate the development of signal models, we include basic sequence building blocks (e.g., Inversion Preparation, SSFP Propagator) and low-level Extended Phase Graphs operators: | ||
|
||
|
||
## Sequence Blocks | ||
|
||
```{eval-rst} | ||
.. currentmodule:: deepmr.bloch | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.bloch.InversionPrep | ||
deepmr.bloch.T2Prep | ||
deepmr.bloch.ExcPulse | ||
deepmr.bloch.bSSFPStep | ||
deepmr.bloch.SSFPFidStep | ||
deepmr.bloch.SSFPEchoStep | ||
deepmr.bloch.FSEStep | ||
``` | ||
|
||
## Low-level Operators | ||
|
||
```{eval-rst} | ||
.. currentmodule:: deepmr.bloch | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.bloch.EPGstates | ||
deepmr.bloch.RFPulse | ||
deepmr.bloch.AdiabaticPulse | ||
deepmr.bloch.Relaxation | ||
deepmr.bloch.Shift | ||
deepmr.bloch.Spoil | ||
deepmr.bloch.DiffusionDamping | ||
deepmr.bloch.FlowDephasing | ||
deepmr.bloch.FlowWash | ||
deepmr.bloch.observe | ||
deepmr.bloch.susceptibility | ||
deepmr.bloch.t1sat | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Fourier Transform | ||
|
||
```{eval-rst} | ||
.. automodule:: deepmr.fft | ||
``` | ||
|
||
## Centered FFT | ||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.fft.fft | ||
deepmr.fft.ifft | ||
``` | ||
|
||
## Sparse FFT | ||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.fft.sparse_fft | ||
deepmr.fft.sparse_ifft | ||
deepmr.fft.plan_toeplitz_fft | ||
deepmr.fft.apply_sparse_fft_selfadj | ||
``` | ||
|
||
## Non-Uniform FFT (NUFFT) | ||
```{eval-rst} | ||
.. autosummary:: | ||
:toctree: generated | ||
:nosignatures: | ||
deepmr.fft.nufft | ||
deepmr.fft.nufft_adj | ||
deepmr.fft.plan_toeplitz_nufft | ||
deepmr.fft.apply_nufft_selfadj | ||
``` |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.b0field | ||
============== | ||
|
||
.. currentmodule:: deepmr | ||
|
||
.. autofunction:: b0field |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.b1field | ||
============== | ||
|
||
.. currentmodule:: deepmr | ||
|
||
.. autofunction:: b1field |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
deepmr.bloch.AdiabaticPulse | ||
=========================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: AdiabaticPulse | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~AdiabaticPulse.__init__ | ||
~AdiabaticPulse.apply | ||
~AdiabaticPulse.prepare_rotation | ||
~AdiabaticPulse.prepare_saturation | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
deepmr.bloch.DiffusionDamping | ||
============================= | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: DiffusionDamping | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~DiffusionDamping.__init__ | ||
~DiffusionDamping.apply | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.bloch.EPGstates | ||
====================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autofunction:: EPGstates |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.bloch.ExcPulse | ||
===================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autofunction:: ExcPulse |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.bloch.FSEStep | ||
==================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autofunction:: FSEStep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
deepmr.bloch.FlowDephasing | ||
========================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: FlowDephasing | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~FlowDephasing.__init__ | ||
~FlowDephasing.apply | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
deepmr.bloch.FlowWash | ||
===================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: FlowWash | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~FlowWash.__init__ | ||
~FlowWash.apply | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.bloch.InversionPrep | ||
========================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autofunction:: InversionPrep |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
deepmr.bloch.RFPulse | ||
==================== | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: RFPulse | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~RFPulse.__init__ | ||
~RFPulse.apply | ||
~RFPulse.prepare_rotation | ||
~RFPulse.prepare_saturation | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
deepmr.bloch.Relaxation | ||
======================= | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autoclass:: Relaxation | ||
|
||
|
||
.. automethod:: __init__ | ||
|
||
|
||
.. rubric:: Methods | ||
|
||
.. autosummary:: | ||
|
||
~Relaxation.__init__ | ||
~Relaxation.apply | ||
|
||
|
||
|
||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
deepmr.bloch.SSFPEchoStep | ||
========================= | ||
|
||
.. currentmodule:: deepmr.bloch | ||
|
||
.. autofunction:: SSFPEchoStep |