Repository navigation
FSE trains: design Busse and PD schedules with blochsim.trains - #228
Merged
Merged
Conversation
The NumPy phase graph in _busse.py, _pd.py and _fse_contrast.py is removed. make_busse_schedule, make_pd_schedule, calc_fse_effective_te and the effective-TE centre search call blochsim.trains (blochsim>=0.0.18, the design extra), which inverts the phase graph in a C++ kernel and tries every centre echo in one batch. blochsim is imported when a schedule is designed, and importing blochsim.trains does not import PyTorch. The trains two 3D FSE acquisitions played are frozen as a fixture and reproduced in angle, signal, centre echo and effective TE. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…9 deg The API tables name the design extra for the three functions blochsim computes, the played trains are held to 1e-9 degrees, and a design without blochsim is tested to raise an ImportError naming the extra. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
mcencini
marked this pull request as ready for review
November 11, 2026 02:20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The NumPy extended phase graph that #224 added for the Busse and PD refocusing schedules is removed.
make_busse_schedule,make_pd_schedule,calc_fse_effective_teand the effective-TE centre search offse3D_sequencenow callblochsim.trains(pulserver/blochsim#56), which inverts the phase graph in a C++ kernel.Depends on blochsim 0.0.18, which is pulserver/blochsim#56 merged and released. Until that version is on PyPI the
Installstep of the test jobs cannot resolveblochsim>=0.0.18and CI fails; that is expected. Merge order: blochsim#56, tag blochsimv0.0.18, wait for PyPI, re-run CI here, merge, release pypulseqpp.Changes
_busse.py: the forward and inverse EPG, the pseudo-steady-state function and both shooting solvers are gone (372 to 180 lines).make_busse_schedulekeeps its signature, validation and cache and callsblochsim.trains.busse_flips;_make_busse_schedulescalls it once for the batch._fse_contrast.py:calc_fse_effective_tecallsblochsim.trains.effective_te._select_busse_centrecallsbusse_centre_echo, which designs the train for every candidate centre in one batch and returns the nearest; the Python bisection and its per-candidate cache are gone._pd.py:_inverse_pdcallsblochsim.trains.prescribed_flipswith relaxation. The PD signal family and its solver are unchanged.import pypulseqpp, andblochsim.trainsdoes not import PyTorch. Without blochsim they raiseImportErrornaming thedesignextra.design = ["blochsim>=0.0.18"]; the test jobs install.[dev,design]with the CPU build of PyTorch on Linux.AGENTS.md, the build-and-test skill, and the docstrings of the four functions and offse3D_sequencesay which paths need blochsim.Parity
tests/fixtures/fse3d_busse_trains.jsonfreezes the trains of two 3D FSE acquisitions as 0.0.62 designed and played them (60 echoes after 6 startup echoes, effective TE 60 ms and 44 ms).The tests hold these to 1e-7 deg in angle, 1e-9 in the relaxation-free echo signal (isochromat summation of both trains), an identical centre echo, and 1e-9 s in effective TE. PD schedules of 26 to 166 pulses differ from 0.0.62 by at most 6.6e-12 deg.
Sequence structure is untouched: the same flip angles go into the same blocks, so segmentation, waveform memory and played time are unchanged.
Timing
Laptop under load (load average about 30); centre search plus schedule for the ETL 60 train, median of 5 fresh processes:
make_pd_schedule, 26-166 pulsesNot measured on the scanner host or the simulator image.
Tests
With blochsim built from pulserver/blochsim#56: full suite
pytest -n 8, 5184 passed, 37 skipped (reference toolbox absent), plustests/test_sequence_docstrings.py(140 passed) once sphinx was installed in the environment.ruff checkandruff format --checkclean.A decision for the maintainer: blochsim stays an optional extra, so a plain
pip install pypulseqppcan no longer design Busse or PD trains or compute the effective TE. Making it a hard dependency would bring PyTorch into every install.🤖 Generated with Claude Code