An Individual Research & Engineering Project
ℹ️ Project Ownership: This repository represents my own individual work. It was designed, coded, and tested independently as a solo project to demonstrate end-to-end capabilities in medical physics sequence compilation and deep-framework signal reconstruction.
An advanced medical physics compilation framework and digital signal processing workspace. This repository acts as an adaptive sequence compiler to program and evaluate Gradient Echo (GRE / FLASH / SPGR) sequences. The engine generates hardware-quantized .seq files compliant with the open-source Pulseq Framework (v1.4.0), which can be executed directly on clinical 3T scanners (Siemens, GE, and Philips) using native vendor interpreters.
This sandbox bypasses rigid, legacy vendor scripting methodologies by utilizing an object-oriented, constraint-solving architecture built entirely from scratch:
[ Clinical Inputs ] ──► [ 1. Sequence Compiler ] ──► [ Hardware Waveforms (.seq) ]
-
FOV, TR, TE, Alpha - 10µs Hardware Raster Clock - Analytical Trapezoids - Dynamic TE Delay Padding - Fixed Dead-Time Padding │ ▼ [ Diagnostic Plots ] ◄── [ 2. PyTorch FFT Engine ] ◄───────────────┘
-
High-Contrast Brain - K-Space Forward Mapping
-
Centered K-Space - Low-Amplitude Noise Floor
- Waveform Compiler (generate_gre_sequence): Translates high-level clinical parameters into microsecond-aligned hardware events. A custom TE Engine dynamically calculates structural delays to guarantee the echo peaks exactly at the requested constraint without breaking physical coil-ramp limits.
- PyTorch Signal Simulator (check_sequence_with_mrirecon): Reads the output text file structure, extracts the active spatial frequency track, applies an inverse-FFT forward mapping of a structural brain model, injects instrumentation white noise, and computes an optimized native 2D Fast Fourier Transform (torch.fft.fft2).
During every individual phase encoding repetition interval (TR), the sequence coordinates a synchronized four-channel hardware dance on the scanner axes:
┌──────────────────┬──────────────────┬──────────────────┬──────────────────┐
Channel │ 1. Excitation │ 2. Phase Encode │3. Echo Readout │4. Rewind & Delay │ ─────────┼──────────────────┼──────────────────┼──────────────────┼──────────────────┤ RF │ ■ Block Pulse │ │ │ │ GZ │ ■ Slice Selection│ ■ Rephasing │ │ │ GY │ │ ■ Phase Step (Ky)│ │ ■ Phase Rewinder │ GX │ │ ■ Pre-phasing │ ■ Readout Flat │ │ ADC │ │ │ ■ Sampling Open │ │ ─────────┴──────────────────┴──────────────────┴──────────────────┴──────────────────┘ ⏰ Time: ◄─── 2.0 ms ───► ◄─── 1.0 ms ───► ◄─── 5.12 ms ───► ◄─── Variable ───►
- Channel Z (
$G_z$ ): Constrains spin excitation to a 2D cross-sectional head slice. - Channel Y (
$G_y$ ): Steps through phase-encoding configurations ($N_y = 256$ ), resetting phase states at the end of each block via an inverted rewinder loop to preserve steady-state magnetization. - Channel X (
$G_x$ ): Winds frequencies to the corner of k-space during pre-phasing, then opens the ADC window during a steady readout flat-top to catch the echo.
Install the required scientific processing core, type-safe arrays, and visualization libraries:
pip install numpy pypulseq torch matplotlib
Modify variables directly inside the script's main operational execution block to experiment with medical physics parameters:
if name == "main": MY_FOV = 400e-3 # 400mm Field of View (Camera Frame Zoom) MY_TR = 60e-3 # 60ms Repetition Interval Time MY_TE = 25e-3 # 25ms Echo Recording Target MY_ALPHA = 25 # 25° Flip Angle (Excitation Tipping Limit)
Execute the script using your local interpreter environment:
python main.py
The compiler acts as an active scanner safety interpreter. If you request a combination of parameters that violates physical boundaries (e.g., trying to read an echo before the gradients finish moving), the execution stops safely to prevent damage to real scanner gradients:
ValueError: ❌ Error: Requested TE (2.0ms) is shorter than the physical hardware limit (4.56ms)!
When execution finishes, a split-screen matrix window will display:
- Left Panel (K-Space Energy Matrix): Mapped low and high spatial frequency energies, proving the structural accuracy of your gradient tracks.
- Right Panel (Sharp Reconstructed Head Scan): A razor-sharp, low-noise clinical Modified Shepp-Logan Head Phantom displaying clear bone layers, grey/white matter regions, and internal ventricle cavities.
This project is open-source and available under the MIT License. Feel free to use, modify, and distribute it for research and educational applications. Now that your individual project README.md file is completely rewritten to show full ownership, let me know if you would like me to draft a LinkedIn spotlight post to help you share your launch with your network!