calc_ramp and add_ramp incorrect usage of max_grad and max_slew?
Describe the bug
calc_ramp specifies that you can give max_grad and slew_rate as a [3,1] array, but inside the function, max_grad and slew_rate is set as
if np.all(np.where(max_grad <= 0)):
max_grad = [system.max_grad]
if np.all(np.where(max_slew <= 0)):
max_slew = [system.max_slew]
But if max_grad is an array this won't work since (same for max_slew)
>>> max_grad = np.ones((3,1))
>>> np.all(np.where(max_grad <= 0))
True
Also, for add_ramp, the docs specifies that max_grad and max_slew should be ints? This seems strange since they are floats everywhere else. Also, for add_ramps the option to use max_grad and max_slew for each gradient axis is not an option as it is for calc_ramps?
This whole thing made me think about what max_grad and max_slew means in the system settings? The most reasonable thing is that they denote the max_grad and max_slew every gradient channel can produce right? But if this is the case, passing just this number to add_ramps does not make sense either because then you end up here in calc_ramps
if mode == 0:
if np.linalg.norm(G0) > max_grad or np.linalg.norm(G_end) > max_grad:
break
success, k_out = __joinleft0(
k0=k0, k_end=k_end, G0=G0, G_end=G_end, use_points=use_points
)
And if each gradient channel are close to, but still smaller than max_grad then
np.linalg.norm(G0) > max_grad or np.linalg.norm(G_end) > max_grad:
will still evaluate to true
Expected behavior I either expect the ramp functions to ignore per channel max_grad and max_slew and just take these as numbers and assume they are all the same for each axis. Or properly handle the per axis behaviour. Also I expect max_grad and max_slew should be given as a float as everywhere else
- OS: Ubuntu
- OS Version: 24.04
pypulseqversion: 1.4.2