Basics of Image acquisition
===========================

Topics overview
---------------

- **k‑space trajectories**: Cartesian, radial, spiral, PROPELLER, 3‑D shells
- **Encoding**: frequency‑encode, phase‑encode, slice‑select; partial Fourier
- **Sampling parameters**: FOV, matrix size, receiver bandwidth, dwell time, echo train length
- **Readout schemes**: single‑shot, segmented, turbo factor / ETL
- **Averaging & noise**: NEX/NSA, parallel‑receive SNR behavior
- **Reconstruction**: Fourier transform, gridding, NUFFT, density compensation
- **Coil combination**: sum‑of‑squares, adaptive combine, ESPIRiT maps
- **Parallel imaging**: SENSE, GRAPPA, CAIPIRINHA
- **Compressed sensing / low‑rank**: k‑t, XD‑GRASP
- **Corrections**: motion/phase, eddy‑currents, :math:`B_0` drift
- **Artifact mitigation & QC**: ghosts, Gibbs ringing, geometric distortion; basic checks


Historical notes (FID and early NMR)
------------------------------------

- **1946 (CW NMR)** — Bloch, Purcell et al. used fixed‑frequency :math:`B_1` and **swept** :math:`B_0` through resonance, observing “resonance absorption” / “nuclear induction signal.”
- **1948** — Bloembergen, Purcell, Pound reported small oscillations (“**wiggles**”) flanking the main absorption after passing resonance.
- **Hahn (pulsed NMR)** — Held :math:`B_0` constant, applied pulsed :math:`B_1` at the Larmor frequency; observed the **free induction decay (FID)**.

MRI differs from other modalities because the **signal is generated by the patient**; localization identifies **where** signals originate.


Spatial localization
--------------------

Three components:

- **Slice selection (SS)**
- **Frequency encoding (FE)**
- **Phase encoding (PE)**

.. important::

   Having two gradients **on at the same time** means the **vector sum** of gradients; it is not equivalent to turning them on independently.

Slice selection
^^^^^^^^^^^^^^^

- Apply :math:`G_{\text{slice}}` during the RF pulse. RF **bandwidth** and gradient **strength** set the **slice thickness**:
  - Wider RF bandwidth or weaker gradient → **thicker** slice.
  - Narrower RF bandwidth or stronger gradient → **thinner** slice.
- After the RF, apply an **opposite‑polarity rephasing lobe** on :math:`G_{\text{slice}}` to undo slice‑selection dephasing within the slice.

Frequency encoding (readout)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- During signal acquisition at :math:`\mathrm{TE}`, apply :math:`G_{\text{read}}` so position maps to frequency.
- The ADC samples with **dwell time** :math:`\Delta t`; receiver bandwidth :math:`\mathrm{RBW} \approx 1/\Delta t` (per complex sample).
- **1‑D Fourier transform** along readout reconstructs the spatial profile in the read direction.

Phase encoding
^^^^^^^^^^^^^^

- A brief gradient :math:`G_{\text{phase}}` before readout imparts a **position‑dependent phase** that persists (spins see the same :math:`B_0` before/after the lobe).
- Repeating the sequence with **different PE amplitudes** fills different **rows of k‑space**.

k‑space formalism
-----------------

Define k‑space coordinates from gradients:

.. math::

   \mathbf{k}(t) = \frac{\gamma}{2\pi} \int_0^{t} \mathbf{G}(\tau)\, d\tau
   \quad\Rightarrow\quad
   s(t) = \int \rho(\mathbf{r})\, e^{-i 2\pi \mathbf{k}(t)\cdot \mathbf{r}}\, d\mathbf{r}

Key properties:

- **Central k‑space** (low spatial frequencies) encodes **contrast**; acquired with smaller PE amplitudes, higher signal coherence.
- **Outer k‑space** (high spatial frequencies) encodes **edges / resolution**; larger PE amplitudes.
- **Symmetries** permit **partial Fourier** (half‑scan) if conjugate symmetry holds after phase correction (e.g., homodyne, POCS).

Sampling & imaging relations
----------------------------

Let readout **matrix** be :math:`N_x`, **FOV** be :math:`\mathrm{FOV}_x`, and read gradient be constant during acquisition.

- k‑space sample spacing: :math:`\Delta k_x = 1/\mathrm{FOV}_x`
- Resolution: :math:`\Delta x \approx \mathrm{FOV}_x / N_x`
- Maximum spatial frequency: :math:`k_{x,\max} \approx N_x/(2\,\mathrm{FOV}_x)`
- Dwell time vs bandwidth: :math:`\Delta t \approx 1/\mathrm{RBW}` (per complex sample)

Readout schemes
---------------

- **Single‑shot**: entire k‑space (or a plane/segment) in one shot (e.g., EPI); fast, sensitive to distortions and :math:`T_2^*`.
- **Segmented**: k‑space split across shots; reduced distortion, longer scan.
- **Turbo/fast spin echo (FSE/TSE)**: multiple echoes per TR; **echo train length (ETL)** / turbo factor is number of k‑space lines per TR.

Averaging & noise
-----------------

- **NEX/NSA** (number of excitations / signal averages): SNR scales as :math:`\sqrt{\text{NEX}}`.
- **Parallel receive arrays**: SNR depends on coil geometry and **g‑factor**; combination method matters.

Coil combination
----------------

- **Sum‑of‑squares (SoS)**: simple, robust magnitude combination.
- **Adaptive combine**: SNR‑optimal with estimated noise covariance / sensitivity.
- **ESPIRiT / sensitivity maps**: explicit coil sensitivity modeling for parallel imaging.

Parallel imaging
----------------

- **SENSE**: image‑domain unfolding using sensitivity maps.
- **GRAPPA**: k‑space interpolation using autocalibration lines (ACS).
- **CAIPIRINHA**: controlled aliasing pattern to improve conditioning / g‑factor in 2‑D/3‑D.

Compressed sensing & low‑rank
-----------------------------

- **CS (k‑t)**: incoherent undersampling + sparsity (e.g., temporal TV, wavelets).
- **Low‑rank / subspace**: e.g., **XD‑GRASP** for motion‑resolved reconstruction.

Non‑Cartesian recon
-------------------

- **Radial / spiral / PROPELLER / 3‑D shells** require **gridding** or **NUFFT** with **density compensation** before FFT.
- Trajectory calibration and system delays affect image quality; correct with field probes, trajectory measurement, or self‑navigation.

Corrections & QC
----------------

- **Motion/phase correction**: navigator echoes, PROPELLER, retrospective registration, phase stabilization.
- **Eddy‑current correction**: pre‑emphasis, post‑hoc modeling, bipolar gradients.
- **:math:`B_0` drift correction**: reference navigators, field monitoring.
- **Artifacts**:
  - **Ghosting** (EPI Nyquist): odd/even echo phase mismatch; calibrate/phase‑correct.
  - **Gibbs ringing**: insufficient high‑frequency sampling; mitigate with apodization or higher matrix.
  - **Geometric distortion**: :math:`B_0` inhomogeneity in EPI; reduce bandwidth per pixel in phase‑encode, use parallel imaging, field maps.
- **Basic QC**: check noise level, ghost‑to‑signal ratio, NPS/PSF behavior, gradient timing, and k‑space center stability.

Workflow summary
----------------

1. **Design** trajectory and encoding (SS, PE table, readout).
2. **Acquire** data with appropriate sampling (dwell time, RBW, FOV, matrix).
3. **Preprocess** (DC/phase corrections, eddy/:math:`B_0` drift fixes).
4. **Reconstruct**:
   - Cartesian: FFT (with coil combine / parallel imaging).
   - Non‑Cartesian: gridding/NUFFT + FFT (then coil combine, PI, CS/low‑rank as needed).
5. **Validate/QC** and mitigate artifacts where necessary.
