
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "generated/gallery/13-fast-spin-echo/fse3D_sequence.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_generated_gallery_13-fast-spin-echo_fse3D_sequence.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_generated_gallery_13-fast-spin-echo_fse3D_sequence.py:


==============================
Conventional 3D fast spin echo
==============================

A slab-selective excitation is followed by a CPMG fast-spin-echo refocusing
train, with one Cartesian ``(line, partition)`` view acquired at each echo.
Refocusing angles below 180 degrees add stimulated-echo pathways to the echo
signal [HEN88]_, and variable refocusing angles modulate the T2-dependent
signal evolution along the train [BUS08a]_. Radial view ordering maps this
evolution onto the ``(k_y, k_z)`` plane and therefore determines the
modulation transfer function and image blurring [BUS08a]_. 3D FSE is used for
T2- and proton-density-weighted structural imaging.

.. GENERATED FROM PYTHON SOURCE LINES 15-109

.. code-block:: Python



    from pypulseqpp import sequences

    Fse3DApp = sequences.fse3D_sequence.Fse3DApp

    DIAGRAM = {
        "n_x": 64,
        "n_y": 24,
        "n_z": 8,
        "fov_x": 0.20,
        "fov_y": 0.20,
        "fov_z": 0.12,
        "etl": 6,
        "te": None,
        "tr": None,
        "n_dummy": 0,
        "ordering": "radial",
        "flip_modulation": "optimized",
        "wave_amplitude": 0.0,
    }
    diagram_app = Fse3DApp(**DIAGRAM)
    diagram = diagram_app.design()

    ANALYSIS = {
        "n_x": 96,
        "n_y": 64,
        "n_z": 20,
        "fov_x": 0.20,
        "fov_y": 0.20,
        "fov_z": 0.12,
        "etl": 48,
        "te": 120e-3,
        "tr": 1.2,
        "n_dummy": 0,
        "ordering": "radial",
        "flip_modulation": "optimized",
        "wave_amplitude": 0.0,
    }
    app = Fse3DApp(**ANALYSIS)
    seq = app.design()
    print(
        f"{len(app.trains)} shots; {app.fse.esp * 1e3:.2f} ms echo spacing; "
        f"{seq.get_definition('TE')[0] * 1e3:.1f} ms effective TE"
    )





.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    21 shots; 10.84 ms echo spacing; 120.8 ms effective TE




.. GENERATED FROM PYTHON SOURCE LINES 110-116

Sequence diagram
----------------

Each echo comprises a variable-angle refocusing pulse, phase and partition
prephasing, one frequency-encoded ADC event, and rephasing. The effective TE
is the echo assigned to k-space centre.

.. GENERATED FROM PYTHON SOURCE LINES 116-118

.. code-block:: Python

    diagram.paper_plot()




.. image-sg:: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_001.png
   :alt: fse3D sequence
   :srcset: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_001.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 119-131

Refocusing schedule and echo signal
-----------------------------------

The refocusing schedule has the form of [BUS08a]_: the angle decreases from
a maximum to a minimum over the first five echoes, increases to the
prescribed angle at the effective-TE echo and returns to the maximum at the
end of the train. The minimum and maximum angles, bounded by the prescribed
angle, are optimized with the extended phase graph (EPG) FSE simulator of ``torchsim`` [HEN88]_ [WEI15]_.
The cost combines an echo-to-echo signal-variation measure of blurring, the
contrast between two of the sequence's design tissues at the effective-TE
echo, and a penalty on RF power above that of the initial schedule. The same
simulator evaluates the resulting T2-dependent echo envelope.

.. GENERATED FROM PYTHON SOURCE LINES 131-147

.. code-block:: Python

    import torchsim

    angles = np.asarray(app.flips[0, : app.lengths[0]])
    signal = np.abs(
        np.asarray(torchsim.fse_sim(flip=angles, ESP=app.fse.esp * 1e3, T1=1200.0, T2=60.0))
    )




.. image-sg:: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_002.png
   :alt: fse3D sequence
   :srcset: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_002.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 148-155

Echo and shot order
-------------------

Radial ordering [BUS08a]_ assigns views near k-space centre to the
effective-TE echo and progressively larger radii to echoes farther from it. Echo index records
position within a train; shot index identifies views acquired after the same
excitation.

.. GENERATED FROM PYTHON SOURCE LINES 155-160




.. image-sg:: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_003.png
   :alt: fse3D sequence
   :srcset: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_003.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 161-168

K-space weighting
-----------------

The echo envelope weights each acquired view according to its echo index.
Radial assignment converts temporal signal evolution into a predominantly
radial modulation transfer function; its Fourier transform contributes to
image blurring along both phase-encode axes.

.. GENERATED FROM PYTHON SOURCE LINES 168-178




.. image-sg:: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_004.png
   :alt: fse3D sequence
   :srcset: /generated/gallery/13-fast-spin-echo/images/sphx_glr_fse3D_sequence_004.png
   :class: sphx-glr-single-img





.. GENERATED FROM PYTHON SOURCE LINES 179-194

References
----------

.. [HEN88] Hennig J. Multiecho imaging sequences with low refocusing flip
   angles. *Journal of Magnetic Resonance*. 1988;78(3):397-407.
   https://doi.org/10.1016/0022-2364(88)90128-X

.. [WEI15] Weigel M. Extended phase graphs: dephasing, RF pulses, and
   echoes - pure and simple. *Journal of Magnetic Resonance Imaging*.
   2015;41(2):266-295. https://doi.org/10.1002/jmri.24619

.. [BUS08a] Busse RF, Brau ACS, Vu A, Michelich CR, Bayram E, Kijowski R,
   Reeder SB, Rowley HA. Effects of refocusing flip angle modulation and
   view ordering in 3D fast spin echo. *Magnetic Resonance in Medicine*.
   2008;60(3):640-649. https://doi.org/10.1002/mrm.21680


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 1.205 seconds)


.. _sphx_glr_download_generated_gallery_13-fast-spin-echo_fse3D_sequence.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: fse3D_sequence.ipynb <fse3D_sequence.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: fse3D_sequence.py <fse3D_sequence.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: fse3D_sequence.zip <fse3D_sequence.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
