Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 71 additions & 28 deletions .github/workflows/preview-pages.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
name: Preview simulation branch on GitHub Pages
name: Preview feature branches on GitHub Pages

# GitHub Pages serves one site per repository, and a deployment replaces all
# of it. This workflow therefore deploys the production site built from main
# at the root, unchanged for visitors, and this branch's build under
# /preview/simulation/, so the branch can be checked on github.io before it is
# merged. A deployment from main (deploy-pages.yml) removes the preview again;
# re-run this workflow from the Actions tab to restore it.
# at the root, unchanged for visitors, and every branch in PREVIEW_BRANCHES
# under /preview/<branch without "feature/">/, so a branch can be checked on
# github.io before it is merged. Each run rebuilds all of them, so one
# branch's preview does not wipe another's.
#
# Requires feature/simulation in the github-pages environment's deployment
# branch policy (Settings → Environments → github-pages).
# A deployment from main (deploy-pages.yml) removes the previews again; re-run
# this workflow from the Actions tab, on any listed branch, to restore them.
#
# Every listed branch needs an entry in the github-pages environment's
# deployment branch policy (Settings → Environments → github-pages), and its
# own copy of this file must list it under on.push.branches.

on:
push:
branches: ['feature/simulation']
branches: ['feature/measurement-markers']
workflow_dispatch:

permissions:
Expand All @@ -24,51 +28,90 @@ concurrency:
group: "pages"
cancel-in-progress: false

env:
# Space-separated. The branch that triggers a run must be one of them.
PREVIEW_BRANCHES: feature/measurement-markers

jobs:
build-and-deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}preview/simulation/
url: ${{ steps.deployment.outputs.page_url }}preview/${{ steps.assemble.outputs.slug }}/
runs-on: ubuntu-latest
steps:
- name: Only listed branches deploy
run: |
case " $PREVIEW_BRANCHES " in
*" $GITHUB_REF_NAME "*) ;;
*) echo "::error::$GITHUB_REF_NAME is not in PREVIEW_BRANCHES ($PREVIEW_BRANCHES)"; exit 1 ;;
esac

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Checkout main (production root)
uses: actions/checkout@v4
with:
ref: main
path: main

- name: Checkout this branch (preview)
# deploy-pages.yml validates main on every push; here it is only rebuilt.
- name: Build the production site
working-directory: main
run: |
npm ci
npm run build:web

- name: Checkout this branch
uses: actions/checkout@v4
with:
path: branch

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '24'

- name: Build the production site exactly as deploy-pages.yml does
working-directory: main
- name: Validate and build this branch
working-directory: branch
run: |
npm ci
npm run check

- name: Validate and build the branch site
working-directory: branch
# Their own pushes validate them; here they are only rebuilt.
- name: Build the other preview branches
run: |
npm ci
npm run check
for b in $PREVIEW_BRANCHES; do
[ "$b" = "$GITHUB_REF_NAME" ] && continue
s="${b#feature/}"; s="${s//\//-}"
if ! git -C branch fetch --no-tags --depth 1 origin "refs/heads/$b"; then
echo "::warning::$b could not be fetched; its preview is left out"
continue
fi
git -C branch worktree add --detach "$PWD/previews/$s" FETCH_HEAD
(cd "previews/$s" && npm ci && npm run build:web)
done

- name: Assemble the site
id: assemble
run: |
mkdir -p _site/preview/simulation
cp -R main/web/. _site/
cp -R branch/web/. _site/preview/simulation/
{
echo "branch: ${GITHUB_REF_NAME}"
echo "commit: ${GITHUB_SHA}"
stamp() {
echo "branch: $1"
echo "commit: $2"
echo "built: $(date -u +%Y-%m-%dT%H:%M:%SZ)"
} > _site/preview/simulation/preview.txt
}
mkdir -p _site
cp -R main/web/. _site/
s="${GITHUB_REF_NAME#feature/}"; s="${s//\//-}"
echo "slug=$s" >> "$GITHUB_OUTPUT"
mkdir -p "_site/preview/$s"
cp -R branch/web/. "_site/preview/$s/"
stamp "$GITHUB_REF_NAME" "$GITHUB_SHA" > "_site/preview/$s/preview.txt"
for d in previews/*/; do
[ -d "$d" ] || continue
o=$(basename "$d")
mkdir -p "_site/preview/$o"
cp -R "$d/web/." "_site/preview/$o/"
stamp "$o" "$(git -C "$d" rev-parse HEAD)" > "_site/preview/$o/preview.txt"
done
find _site/preview -maxdepth 2 -name preview.txt -exec sh -c 'echo "== $1"; cat "$1"' _ {} \;

- name: Setup Pages
uses: actions/configure-pages@v4
Expand Down
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ All the same features as the other versions — interactive waveforms, k‑space
- **Interactive Canvas**: cursor‑anchored time zoom, per‑row y‑axis zoom, drag‑pan, hover tooltips
- **6 built‑in themes**: One Light · One Dark · Dracula · Nord · GitHub Light · GitHub Dark (+ system auto)
- **Vertical cursor** with live time readout
- **Measurement markers**: right-click to drop markers that snap to gradient corners, RF/ADC edges and centres, and block boundaries; read each channel's value at every marker and Δt between them, and copy the table
- **Unit switchers** for time (s / ms / µs) and gradient (Hz/m / mT/m / G/cm)
- **K‑space unit toggle** (1/m ↔ rad/m) with auto‑updating axis ticks
- **Block boundary lines** — toggle in toolbar
Expand Down Expand Up @@ -377,6 +378,7 @@ long, the plan takes a coarser tested spacing and says so. **Not yet**:
| Load an ASC profile | `Load ASC (PNS/Acoustic)`, then choose a scanner ASC. PNS coefficients and acoustic resonances are read independently — a file carrying only one still loads, and the viewer says which it found |
| Toggle block boundaries | Checkbox `☐ Blocks` in toolbar |
| Block details & values | Hover waveform |
| Measure times and values | Right-click (or long-press) the waveform → **Add marker** (see [Measurement markers](#measurement-markers)). Drag a marker to move it; hold `Shift` to place it off the snap points |
| Switch theme | Toolbar `Theme` dropdown |
| Cycle the analysis panel | Toolbar button: closed → **K-Space** → **Spectrogram** → closed. The label always names what the next click does |
| Rotate 3D view | Left‑drag in k‑space panel |
Expand All @@ -396,6 +398,36 @@ long, the plan takes a coarser tested spacing and says so. **Not yet**:
| Play the simulated gradient sound | `▶` at the top-left of the panel. Playback runs from the marker (or the window start) to the end of the visible window |
| Stop remembering settings | ⚙ in the toolbar, then untick **Remember my settings**. **Forget stored settings** deletes what is already there |

## Measurement markers

Right-click the waveform viewer (or long-press it on a touch screen) and
choose **Add marker** to drop a vertical marker. Add as many as you need
(M1, M2, …):

- **Snapping.** Near a gradient corner the menu offers that point instead:
a trapezoid's ramp and flat-top corners, the breakpoints of an extended
trapezoid or the bends of an arbitrary gradient, RF start, centre and end,
ADC start, centre and end, trigger starts, and block boundaries. Once
markers are in use, a ring marks the snap point as the pointer approaches
one. **Add marker at pointer (no snap)**, or `Shift` while dragging, places
a marker exactly where you point; the menu's checkbox turns snapping off.
- **Readouts.** Each marker crosses the RF and gradient rows with a dot and
its value, and Δt is shown between neighbouring markers. The table under
the plot lists every marker: time, block and time within it, Δt to the
previous one, Gx/Gy/Gz in the current gradient unit, RF amplitude and
phase, the ADC sample and the trigger, plus M1 and PNS while those rows
are shown. **Copy** puts it on the clipboard as tab-separated text.
- **Exactness.** Trapezoid corners, RF/ADC edges and block boundaries are
always exact. A long arbitrary waveform is reduced for the whole-sequence
view; values read from those reduced samples are marked ≈ until you zoom
in far enough for the exact samples to load, and its interior bends are
only offered as snap points then.
- **Editing.** Drag a marker to move it (with a finger on a touch screen),
right-click next to one to remove
it, or use the table's × and **Clear**. `Esc` closes the menu or cancels a
drag. Markers belong to the open sequence and are cleared when another one
loads.

## Remembered settings

The viewer comes back the way you left it. Theme, time and gradient units, the
Expand Down
2 changes: 1 addition & 1 deletion matlab/toolboxInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<toolboxInfo>
<name>SeqEyes</name>
<identifier>seqeyes</identifier>
<version>0.4.0</version>
<version>0.4.1</version>
<release>R2022a</release>
<author>
<name>SeqEyes Developers</name>
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "seqeyes-web",
"displayName": "SeqEyes",
"description": "Visualize Pulseq .seq and .bseq MRI sequences inside VS Code with interactive diagrams and k-space trajectories.",
"version": "0.4.0",
"version": "0.4.1",
"publisher": "SeqEyesDeveloper",
"license": "MIT",
"icon": "images/logo.png",
Expand Down
2 changes: 1 addition & 1 deletion python/examples/demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@
"| `show_blocks` | `False` | Show block‑boundary lines |\n",
"| `time_range` | `(0, inf)` | Zoom to `(start_sec, end_sec)` |\n",
"| `time_disp` | `\"s\"` | Time unit: `\"s\"`, `\"ms\"`, `\"us\"` |\n",
"| `grad_disp` | `\"Hz/m\"` | Gradient unit: `\"Hz/m\"`, `\"Hz/m\"`, `\"mT/m\"`, `\"G/cm\"` |\n",
"| `grad_disp` | `\"mT/m\"` | Gradient unit: `\"mT/m\"`, `\"Hz/m\"`, `\"G/cm\"` |\n",
"| `theme` | `\"system\"` | `\"light\"`, `\"dark\"`, `\"dracula\"`, `\"nord\"`, ... |"
]
},
Expand Down
2 changes: 1 addition & 1 deletion python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "seqeyes-python"
version = "0.4.0"
version = "0.4.1"
description = "Interactive Pulseq MRI sequence viewer for Jupyter — lightweight, beautiful, replaces seq.plot() in pypulseq."
readme = "README.md"
license = {text = "MIT"}
Expand Down
2 changes: 1 addition & 1 deletion python/src/seqeyes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
from seqeyes._renderer import SeqEyesViewer

__all__ = ["set", "reset", "SeqEyesViewer"]
__version__ = "0.4.0"
__version__ = "0.4.1"
2 changes: 1 addition & 1 deletion python/src/seqeyes/_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def _seqeyes_plot(
show_blocks: bool = False,
time_range: Any = (0, float("inf")),
time_disp: str = "s",
grad_disp: str = "Hz/m",
grad_disp: str = "mT/m",
**kwargs: Any,
) -> None:
# Merge globals — per‑call args take precedence
Expand Down
11 changes: 6 additions & 5 deletions python/src/seqeyes/_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def _read_viewer_template() -> str:

def _normalize_grad_disp(unit: str) -> str:
"""Return a viewer-supported gradient unit."""
return unit if unit in _VALID_GRAD_UNITS else "Hz/m"
return unit if unit in _VALID_GRAD_UNITS else "mT/m"


def _build_html(
Expand All @@ -88,7 +88,7 @@ def _build_html(
show_blocks: bool = False,
time_range: tuple = (0, float("inf")),
time_disp: str = "s",
grad_disp: str = "Hz/m",
grad_disp: str = "mT/m",
) -> str:
"""Assemble the complete viewer HTML.

Expand All @@ -109,7 +109,8 @@ def _build_html(
time_disp : str
Initial time display unit (``"s"``, ``"ms"``, ``"us"``).
grad_disp : str
Initial gradient display unit (``"Hz/m"``, ``"mT/m"``, ``"G/cm"``).
Initial gradient display unit (``"mT/m"``, the default, ``"Hz/m"``
or ``"G/cm"``).
"""
template = _read_viewer_template()
grad_disp = _normalize_grad_disp(grad_disp)
Expand Down Expand Up @@ -189,7 +190,7 @@ class SeqEyesViewer:
time_disp : str
Time axis unit — ``"s"``, ``"ms"``, or ``"us"``.
grad_disp : str
Gradient axis unit — ``"Hz/m"``, ``"mT/m"``, or ``"G/cm"``.
Gradient axis unit — ``"mT/m"`` (default), ``"Hz/m"``, or ``"G/cm"``.
theme : str or None
Colour theme.
width : str
Expand All @@ -206,7 +207,7 @@ def __init__(
show_blocks: bool = False,
time_range: tuple = (0, float("inf")),
time_disp: str = "s",
grad_disp: str = "Hz/m",
grad_disp: str = "mT/m",
theme: Optional[str] = None,
width: str = "100%",
height: str = "550px",
Expand Down
15 changes: 11 additions & 4 deletions python/src/seqeyes/resources/pulseq-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var Pulseq = (() => {
});

// package.json
var version = "0.4.0";
var version = "0.4.1";

// src/pulseq/decompressor.ts
function decompressShape(compressed, numSamples) {
Expand Down Expand Up @@ -2648,7 +2648,8 @@ var Pulseq = (() => {
if (useM4) reduceM4Range(time, values, clipped.start, clipped.end, this.cap, this.emit);
else reduceUniformRange(time, values, clipped.start, clipped.end, this.cap, this.emit);
this.wrapPhase = false;
return { o: origin, n: this.cursor - origin };
const kept = this.cursor - origin;
return kept < clipped.end - clipped.start ? { o: origin, n: kept, r: true } : { o: origin, n: kept };
}
};
function discard() {
Expand Down Expand Up @@ -2824,9 +2825,11 @@ var Pulseq = (() => {
band.polarFlipDeg,
band.mz
]);
return {
const packed = {
s: rf.startTime,
d: rf.duration,
// Absolute effective centre, the point TE and TR are measured from.
c: rf.centerTime,
// `t`/`m` (magnitude) and `pt`/`p` (phase) buffer spans.
o: magnitude.o,
n: magnitude.n,
Expand All @@ -2845,9 +2848,11 @@ var Pulseq = (() => {
u: rf.use || "u"
// 'e'=excitation, 'r'=refocusing, 'i'=inversion, 's'=saturation, 'u'=undefined
};
if (magnitude.r) packed.r = 1;
return packed;
}
function packGrad(grad, ref) {
return {
const packed = {
s: grad.startTime,
d: grad.duration,
o: ref.o,
Expand All @@ -2856,6 +2861,8 @@ var Pulseq = (() => {
ty: grad.type,
ch: grad.channel
};
if (ref.r) packed.r = 1;
return packed;
}
function waveformMagnitudeMetrics(time, values) {
const count = Math.min(time.length, values.length);
Expand Down
6 changes: 3 additions & 3 deletions python/src/seqeyes/resources/viewer.html
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<span class="ulbl">Theme:</span><select id="theme"><option value="system">System</option><option value="light">Light</option><option value="dark">Dark</option><option value="dracula">Dracula</option><option value="nord">Nord</option><option value="onelight">One Light</option><option value="onedark">One Dark</option><option value="githublight">GitHub Light</option><option value="github">GitHub</option></select>
<div class="sep"></div>
<span class="ulbl">Time:</span><select id="tu"><option value="s">s</option><option value="ms" selected>ms</option><option value="us">µs</option></select>
<span class="ulbl">Grad:</span><select id="gu"><option value="Hz/m" selected>Hz/m</option><option value="mT/m">mT/m</option><option value="G/cm">G/cm</option></select>
<span class="ulbl">Grad:</span><select id="gu"><option value="Hz/m">Hz/m</option><option value="mT/m" selected>mT/m</option><option value="G/cm">G/cm</option></select>
<div class="sep"></div>
<label class="li" id="bbt" title="Toggle block boundary lines"><input type="checkbox" id="bbc" style="margin:0;cursor:pointer"><span style="font-size:11px;color:var(--fg)">Blocks</span></label>
<div class="sep"></div><div class="lg" id="legend"></div>
Expand Down Expand Up @@ -171,7 +171,7 @@
var ox=0,sc=1;
var dr=false,dsx=0,dso=0;
var cursorT=0,cursorActive=false;
var timeUnit='ms',gradUnit='Hz/m';
var timeUnit='ms',gradUnit='mT/m';
var showBB=false;
var GAMMA=42576;
var ampZoom=[1,1,1,1,1,1,1,1,1,1,1,1];
Expand Down Expand Up @@ -201,7 +201,7 @@
// ── Unit conversion ──
function gradConv(v){if(gradUnit==='mT/m')return v/GAMMA;if(gradUnit==='G/cm')return v/(GAMMA*10);return v;}
function gradUnitStr(){return gradUnit;}
function normalizeGradUnit(unit){return(unit==='mT/m'||unit==='G/cm'||unit==='Hz/m')?unit:'Hz/m';}
function normalizeGradUnit(unit){return(unit==='mT/m'||unit==='G/cm'||unit==='Hz/m')?unit:'mT/m';}
function timeConv(t){if(timeUnit==='ms')return t*1e3;if(timeUnit==='us')return t*1e6;return t;}
function timeUnitStr(){return timeUnit;}

Expand Down
Loading
Loading