-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug fixes in Sequence and make_trapezoid #128
Conversation
Sequence.waveforms_and_times: - Fixed missing implementation for recompressing trapezoids from arbitrary gradients. Now proceeds without recompressing and added a TODO to implement the MATLAB code. - Fixed issue where rounding errors could create non-monotonically increasing times. Also moved the non-monotonicity check outside the loop. make_trapezoid: - Fixed bug that would give an 'requested area is too large' error when explicitly specifiying a triangular gradient with duration, rise_time, and area. - Fixed check for area == 0, while an unspecified area would be None
- Actually fixed the non-monotonic time problem - Two small fixes in sequence plot() that cut off the start of the sequence when time_range is specified, and coloured labels wrongly.
Hi @FrankZijlstra, thanks for the PR! Would it be possible for you to open a separate PR for Taking the non-monotonicity check out of the loop seems logical, as it is not dependent on the loop variable, but I wonder if the changing variables |
It's possible, but the fixes in make_trapezoid are a few edge cases you have to try pretty hard to run into. So I think they can wait. Maxim Zaitsev already fixed and took the non-monotonicity check out of the loop in the local Pulseq repo here in Freiburg, based on me finding the bug that would give this warning last week (it's a rounding error where a+b+c != a+(b+c)). The reason the check was inside the loop in the first place was because he wanted to find out exactly when it was happening, but as a side effect it was spitting out hundreds of warnings once the check was fixed. The loop is nothing more than a fancy way to concatenate the shape_pieces together. If it wasn't for the check whether the last element of the previous shape_piece has approximately the same timepoint as the first element of the current shape_piece, it could be implemented as: |
@FrankZijlstra That makes sense, got it. Yes, I agree that using numpy array for I am also questioning the time check entirely. I feel like the only reason that check is needed is due to the usage of floating points and adding The only other utility of time check is if the user supplied an out-of-order time vector. In that case, check should be done at the |
Yes, I agree. Because the
That said, I think having the check is still nice to make sure no breaking changes are introduced. But in this case I think it might make more sense to have it as an |
Sequence.waveforms_and_times:
make_trapezoid: