Skip to content

Commit a56256e

Browse files
committed
fixed latex equations in docs
1 parent 998ff83 commit a56256e

6 files changed

Lines changed: 28 additions & 30 deletions

File tree

.github/workflows/build.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,14 @@ jobs:
4646
- name: run tests
4747
run: |
4848
pytest
49-
- name: build docs
49+
- name: build wheel
5050
run: |
51-
cd docs
51+
mkdir dist
52+
cd dist
53+
python -m pip wheel .. --no-deps
54+
- name: generate docs
55+
run: |
56+
cd ../docs
5257
make html
5358
- name: setup pages
5459
uses: actions/configure-pages@v5

docs/adiabatic_pulse_demo.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,15 @@ Adiabatic Pulse Example
99
- numpy
1010
- scipy
1111
- bokeh
12-
- https://github.com/nathanielatom/gigablochs
12+
- gigablochs
1313

1414
.. py-repl::
1515
:output: repl_output
1616

1717
print("hallo world")
1818
import numpy as np
1919
import scipy.signal as sig
20+
from bokeh.plotting import show
2021
from gigablochs import bloch, rf, flow
2122
print(bloch.GAMMA)
2223

docs/conf.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
'cupy': ('https://docs.cupy.dev/en/stable/', None),
3939
'scipy': ('https://docs.scipy.org/doc/scipy/', None),
4040
'pandas': ('http://pandas.pydata.org/pandas-docs/stable/', None),
41+
'sympy': ('https://docs.sympy.org/latest/', None),
4142
'bokeh': ('https://docs.bokeh.org/en/latest/', None),
4243
'matplotlib': ('https://matplotlib.org/stable/', None),
4344
'manim': ('https://docs.manim.community/en/stable/', None),
@@ -52,30 +53,20 @@
5253
autosummary_generate = True
5354
default_role = 'py:obj'
5455

55-
# # TODO: fix latex rendering of \gammabar, physics package not working
56-
# r"""
57-
# % define symbol \gammabar
58-
# \usepackage{stackengine}
59-
# \usepackage{scalerel}
60-
# \newcommand\gammabar{\ThisStyle{\ensurestackMath{%
61-
# \stackengine{-1.5\LMpt}{$$\SavedStyle\gamma$$}{$$\SavedStyle-$$}{O}{c}{F}{F}{L}}}}
62-
# """
63-
64-
# # MathJax Latex equation settings
56+
# MathJax Latex equation settings
6557
mathjax3_config = {
6658
'tex': {
6759
'macros': {
68-
'gammabar': r"""\ThisStyle{\ensurestackMath{\stackengine{-1.5\LMpt}{$$\SavedStyle\gamma$$}{$$\SavedStyle-$$}{O}{c}{F}{F}{L}}}""",
60+
'gammabar': r'{\gamma\kern-0.55em\raise-0.25ex\hbox{--}}',
6961
},
70-
'packages': {'[+]': ['ams', 'newcommand', 'configmacros', 'stackengine', 'scalerel', 'physics']},
62+
'packages': {'[+]': ['physics']},
7163
},
7264
'loader': {
7365
'load': ['[tex]/physics'],
7466
}
7567
}
7668

7769
# -- Options for HTML output -------------------------------------------------
78-
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output
7970

8071
html_theme = 'sphinx_book_theme'
8172
html_logo = "_static/gigablochs_logo_transparent.png"

gigablochs/bloch.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,14 @@ def construct_B_field(rf_am, G=0, position=0, *, off_resonance=0, B1_sensitivity
5252
.. math::
5353
5454
B_x = \\Delta B_1 \\Re{RF_{AM}}
55+
5556
B_y = \\Delta B_1 \\Im{RF_{AM}}
56-
B_z = G \\cdot r + \\frac{RF_{FM}}{\\gammabar} + \\frac{\\Delta f}{\\gammabar}
57+
58+
B_z = \\vec{G} \\cdot \\vec{r} + \\frac{RF_{FM}}{\\gammabar} + \\frac{\\Delta f}{\\gammabar}
5759
5860
where :math:`B_x`, :math:`B_y`, and :math:`B_z` are the magnetic field components,
5961
:math:`\\Delta B_1` is the unitless B1 sensitivity factor, :math:`RF_{AM}` is the RF amplitude modulation waveform in Tesla,
60-
:math:`G` is the gradient waveform in Tesla/m, :math:`r` is the spin's spatial position waveform in meters,
62+
:math:`\\vec{G}` is the gradient waveform in Tesla/m, :math:`\\vec{r}` is the spin's spatial position waveform in meters,
6163
:math:`RF_{FM}` is the RF frequency modulation waveform in Hz, :math:`\\gammabar` is the reduced gyromagnetic ratio in Hz/T,
6264
and :math:`\\Delta f` is the off-resonance frequency in Hz.
6365

gigablochs/rf.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def sinc_pulse(flip_angle, duration, bandwidth, dt, phase_angle=0, window='hann'
3333
3434
.. math::
3535
36-
\\theta = \\gamma \\int B_1 dt
36+
\\theta = \\gamma \\int_0^T B_1 dt
3737
38-
where :math:`\\theta` is the flip angle, :math:`\\gamma` is the gyromagnetic
39-
ratio, and :math:`B_1` is the pulse amplitude. The sinc pulse is normalized
40-
to achieve the desired flip angle.
38+
where :math:`\\theta` is the flip angle in rads, :math:`\\gamma` is the gyromagnetic
39+
ratio in rads/s/T, :math:`T` is the pulse duration is s, and :math:`B_1` is the pulse
40+
amplitude in T. The sinc pulse is normalized to achieve the desired flip angle.
4141
4242
"""
4343
theta, alpha = np.deg2rad(phase_angle), np.deg2rad(flip_angle)
@@ -73,14 +73,13 @@ def adiabaticity(pulse_am, pulse_fm, dt):
7373
7474
.. math::
7575
76-
K = \\frac{\\left | \\gamma B_{\\mathrm{effective}} \\right |}{\\left | \\dv{\\varphi}{t} \\right |} = \\frac{\\gamma\\sqrt{A^2(t) + \\left ( B_0 - \\frac{\\omega(t)}{\\gamma} \\right )^2}}{\\dv{}{t}\\left ( \\arctan(\\frac{A(t)}{B_0 - \\frac{\\omega(t)}{\\gamma}}) \\right )}
76+
K = \\frac{\\left | \\gamma B_{\\mathrm{effective}} \\right |}{\\left | \\dv{\\varphi}{t} \\right |} = \\frac{\\gamma\\sqrt{A^2(t) + \\left (\\frac{f(t)}{\\gammabar} \\right )^2}}{\\left| \\dv{}{t}\\left ( \\arctan(\\frac{\\gammabar A(t)}{f(t)}) \\right ) \\right|}
7777
78-
where :math:`A(t)` and :math:`\\omega(t)` are the amplitude and frequency
79-
modulation waveforms, respectively, and :math:`B_0` is the static magnetic
80-
field. The adiabaticity is a measure of the ability of the pulse to drive
81-
the magnetization to follow the instantaneous effective magnetic field in
82-
the rotating frame. When the adiabaticity is much greater than 1, for all
83-
time, the pulse is considered adiabatic.
78+
where :math:`A(t)` and :math:`f(t)` are the amplitude and frequency
79+
modulation waveforms, respectively. The adiabaticity is a measure of the
80+
ability of the pulse to drive the magnetization to follow the
81+
instantaneous effective magnetic field in the rotating frame. When the
82+
adiabaticity is much greater than 1, for all time, the pulse is considered adiabatic.
8483
8584
"""
8685
Bz_eff = pulse_fm / bloch.GAMMA_BAR

gigablochs/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def rodrigues_rotation(v, k, theta, *, normalize=True, axis=-1):
109109
110110
.. math::
111111
112-
v_{\\text{rot}} = v \\cos(\\theta) + (k \\times v) \\sin(\\theta) + k (k \\cdot v) (1 - \\cos(\\theta))
112+
v_{\\text{rot}} = v \\cos\\theta + (k \\times v) \\sin\\theta + k (k \\cdot v) (1 - \\cos\\theta)
113113
114114
where :math:`v_{\\text{rot}}` is the rotated vector, :math:`v` is the original vector, :math:`k` is the rotation axis,
115115
and :math:`\\theta` is the rotation angle.

0 commit comments

Comments
 (0)