Skip to content

Conversation

@mcencini
Copy link
Contributor

This PR partially addresses #258.

This only handles changes to RF storage format. The most substantial updates concerns sequence.py , block.py and read_seq.py/write_seq.py modules. Other changes are either very minor updates to include the new attributes in the pulse design routines (make_*.py) or are re-generation of the expected output for the test cases.

For the moment, I excluded a few tests failing due to some inconsistencies in gradient storage format when writing and reading again. I am planning to re-enabling them when bumping gradient storage format.

@btasdelen do you think this is small enough or should I try to further divide this? Thanks!

@github-actions
Copy link

github-actions bot commented Jun 19, 2025

Coverage

Coverage Report
FileStmtsMissCoverMissing
/home/runner/.local/lib/python3.12/site-packages/pypulseq
   add_gradients.py1239820%44, 52, 58, 61, 65–241
   add_ramps.py36360%1–89
   align.py352917%39–77
   calc_duration.py25196%37
   calc_ramp.py2182142%45–353
   calc_rf_bandwidth.py352626%45–78, 82–86
   check_timing.py872769%72, 76, 101, 194, 201, 211–255
   compress_shape.py30197%28
   convert.py40880%42, 48, 66, 72–73, 82, 88–89
   event_lib.py961584%6–9, 48–51, 70–71, 205–210, 247
   make_adc.py921485%63, 69, 72–76, 79, 128, 131, 135, 141, 145, 184, 186, 188, 196
   make_adiabatic_pulse.py1323970%202–206, 226–230, 238–239, 262, 268, 337–356, 460–469, 507–515
   make_arbitrary_grad.py37781%68, 71, 74, 77, 81, 83, 103
   make_arbitrary_rf.py756316%93–179
   make_block_pulse.py48394%119–123, 126
   make_delay.py9189%27
   make_digital_output_pulse.py16288%39, 47
   make_extended_trapezoid.py561279%67, 70, 76, 82, 85, 88, 91, 94, 116, 134, 136, 139
   make_extended_trapezoid_area.py93397%52, 227, 230
   make_gauss_pulse.py722171%109, 136–140, 143–167, 174, 177
   make_label.py19384%36, 41, 43
   make_sigpy_pulse.py1193075%12–13, 119, 122, 126, 163–167, 171, 174–175, 178–179, 194, 201, 206, 218, 221, 246–256, 270, 273, 303–313
   make_sinc_pulse.py701086%100, 106, 134–138, 142, 145–146, 149–150, 172
   make_trapezoid.py111794%177, 190, 196, 214, 232, 237, 255
   make_trigger.py16288%44, 52
   opts.py66986%78, 83, 102, 142, 166–170
   points_to_waveform.py9189%27
   rotate.py691480%15, 55, 66–69, 85–90, 112, 119–120
   scale_grad.py14471%28–30, 33
   sigpy_pulse_opts.py26773%34–41
   split_gradient.py393121%46–103
   split_gradient_at.py706211%48–158
   traj_to_grad.py13931%26–40
/home/runner/.local/lib/python3.12/site-packages/pypulseq/SAR
   SAR_calc.py1139813%33–40, 55–62, 89–108, 129–132, 168–212, 242–246, 264–306
/home/runner/.local/lib/python3.12/site-packages/pypulseq/Sequence
   block.py3716283%59, 62, 70, 76, 91, 99, 105, 108, 116, 119, 122, 130, 135, 144, 197, 246, 250, 266, 310–313, 319, 331–359, 403–404, 409, 415, 435, 499, 504, 540, 546, 573, 611, 645, 682, 706
   calc_grad_spectrum.py81766%68–190
   calc_pns.py403122%45–96
   ext_test_report.py1401391%23, 58, 61, 65, 135, 200, 227–233
   install.py754244%31, 52, 69, 71, 112–131, 148, 181–184, 200–212, 254–278
   parula.py4250%19–86
   read_seq.py37112467%43–44, 91, 94, 106, 111, 117, 124–125, 129, 138, 146–153, 155–158, 161, 169–171, 204, 209, 217–274, 281–296, 311–381, 386–403, 466, 469, 504, 512, 550, 574, 613, 655–659, 774, 785
   sequence.py74623269%11–14, 102–112, 133–146, 184, 249–252, 299, 326, 343, 391, 419, 446–451, 488, 504, 595, 617, 658–661, 715, 753, 764–765, 771, 782, 788, 790, 798, 831–839, 860–882, 925, 927, 930, 956–957, 960–963, 999–1009, 1018–1020, 1064–1076, 1091–1092, 1128–1129, 1155, 1158, 1161, 1164, 1198–1201, 1333–1346, 1376, 1404, 1426–1428, 1449, 1480, 1491–1504, 1514–1539, 1573–1574, 1585–1603, 1627, 1657–1665, 1697–1807, 1836, 1850–1860, 1872
   write_seq.py1761989%44, 68, 71–78, 126–142
/home/runner/.local/lib/python3.12/site-packages/pypulseq/utils
   cumsum.py14193%17
   safe_pns_prediction.py12611310%50–87, 102–189, 197–214, 222, 244–250, 279–286, 310–336, 344–383, 396–411, 415
   tracing.py16662%33–34, 42, 54–55, 75
/home/runner/.local/lib/python3.12/site-packages/pypulseq/utils/siemens
   asc_to_hw.py58539%21–28, 48–106
   readasc.py48456%25–100
TOTAL4479172661% 

Tests Skipped Failures Errors Time
1265 14 💤 0 ❌ 0 🔥 1m 53s ⏱️

@btasdelen
Copy link
Collaborator

Yes, this is great, thank you! I will have a look at this in detail, soon. Meanwhile a thought: should we have tests that also checks the sequences written in v1.4.1 format (using write_v141() function) to make sure we are not breaking backwards compatibility?

@mcencini
Copy link
Contributor Author

Good idea! I guess we'll need multiple expected output files for the different storage formats

@mcencini
Copy link
Contributor Author

mcencini commented Jun 19, 2025

On a second thought, do we really want to support writing to older formats? I know MATLAB toolbox does, but doesn't that introduce a lot of maintainance overhead? After all, we do not have, let's say, write_131().

Just thinking out loud here, if we decide it is worth to support older revisions I am happy to include the corresponding tests.

@mcencini mcencini changed the base branch from master to v1.5.0_dev June 19, 2025 18:55
@mcencini mcencini marked this pull request as ready for review June 19, 2025 18:56
@btasdelen
Copy link
Collaborator

I see what you mean. People who did not migrate their interpreters to 1.5 can stick with an older version of PyPulseq. I guess it boils down to the question, if we want people to use a newer version PyPulseq regardless, for them to have access to bug fixes and some of the new features.

We can also decide this down the line, probably.

@btasdelen btasdelen requested review from btasdelen and Copilot June 23, 2025 15:20
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR bumps the RF storage format to v1.5.0 and updates the internal representation of RF pulses by adding new fields (center, freq_ppm, phase_ppm) in key modules such as sequence.py, block.py, and read_seq.py. Additional changes include updates to expected output files and modifications to various pulse‐creation routines and helper functions to accommodate the new RF event tuple format.

  • Updated RF library tuple structure and its handling in sequence, block, and read_seq modules.
  • Added new parameters (freq_ppm, phase_ppm) and default values (e.g. use='undefined') to pulse‐creation routines.
  • Minor updates to test outputs and examples to include the new attributes.

Reviewed Changes

Copilot reviewed 46 out of 46 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/* Expected output files updated to reflect new RF event format changes
src/pypulseq/supported_labels_rf_use.py Updated supported RF use labels by including 'other' and 'undefined'
src/pypulseq/make_*_pulse.py Added new parameters (freq_ppm, phase_ppm) and updated docstrings accordingly
src/pypulseq/Sequence/(sequence.py, block.py, read_seq.py) Modified RF storage handling and tuple mappings to support v1.5.0 format
pyproject.toml Bumped project version from 1.4.2.post1 to 1.5.0
examples/scripts/* Updated examples to pass explicit use parameters
Comments suppressed due to low confidence (3)

src/pypulseq/make_block_pulse.py:20

  • The RF use validation logic is repeated across several pulse‐creation functions. Consider factoring this out into a shared helper function to ensure consistency and simplify future updates.
    system: Union[Opts, None] = None,

src/pypulseq/Sequence/sequence.py:1286

  • The TODO comment suggests that the RF use mapping should be derived from get_supported_rf_uses() instead of being hardcoded. Please update or remove the TODO once a dedicated mapping mechanism is implemented.
        # TODO: fixme : use map built from pp.get_supported_rf_uses()

src/pypulseq/make_gauss_pulse.py:70

  • The function's docstring should be updated to include and explain the new parameters (freq_ppm and phase_ppm) added to the RF event structure.
        slice select event.

Copy link
Collaborator

@btasdelen btasdelen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just added two minor comments to be addressed, other than that looks good. Can be merged afterward.

@btasdelen btasdelen merged commit d0f9b27 into imr-framework:v1.5.0_dev Jun 23, 2025
7 checks passed
@mcencini mcencini deleted the v1.5.0-rf branch July 11, 2025 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants