Bug Description
The helper function calculate_shortest_params_for_area raises an AssertionError for a shortest possible trapezoid (well triangle) when make_trapezoid is given area and duration that is the shortest possible.
To Reproduce
Use the EPI example in the documentation, https://github.com/imr-framework/pypulseq/blob/master/examples/scripts/write_epi.py
and only change the FOV to fov = 240e-3 m and max slew rate to max_slew=200 T/m/s. With just these two reasonable changes, the calculate_shortest_params_for_area raises an AssertionError:
Requested area is too large for this gradient. Minimum required duration is 60 us. The passed duration is 50 us.
Expected behavior
The EPI example calculates the shorted possible gradient triangle using the same method as the calculate_shortest_params_for_area, however it only rounds the duration up to system.grad_raster_time once, at the end of the calculation for total duration of the triangle; whereas calculate_shortest_params_for_area rounds up the rise_time on its own, then sets the fall_time equal to the rise_time, effectively rounding up twice, and leading to a longer than shortest possible duration and the error.
Desktop (please complete the following information):
- OS: macOS Sequoia
- OS Version: 15.3.1 (24D70)
- python version: 3.9.10
pypulseq version: 1.4.2.post1
I'd be happy to help with a PR at some point when I have availability, but not sure the preferred approach.
Bug Description
The helper function
calculate_shortest_params_for_arearaises an AssertionError for a shortest possible trapezoid (well triangle) whenmake_trapezoidis givenareaanddurationthat is the shortest possible.To Reproduce
Use the EPI example in the documentation, https://github.com/imr-framework/pypulseq/blob/master/examples/scripts/write_epi.py
and only change the FOV to
fov = 240e-3m and max slew rate tomax_slew=200T/m/s. With just these two reasonable changes, thecalculate_shortest_params_for_arearaises an AssertionError:Requested area is too large for this gradient. Minimum required duration is 60 us. The passed duration is 50 us.Expected behavior
The EPI example calculates the shorted possible gradient triangle using the same method as the
calculate_shortest_params_for_area, however it only rounds the duration up tosystem.grad_raster_timeonce, at the end of the calculation for total duration of the triangle; whereascalculate_shortest_params_for_arearounds up therise_timeon its own, then sets thefall_timeequal to therise_time, effectively rounding up twice, and leading to a longer than shortest possible duration and the error.Desktop (please complete the following information):
pypulseqversion: 1.4.2.post1I'd be happy to help with a PR at some point when I have availability, but not sure the preferred approach.