-
Notifications
You must be signed in to change notification settings - Fork 69
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
Sequence.gradient_waveforms() does not interpolate trapezoids with gradient raster time. #72
Comments
Workaround: Passing |
Hi @bilal-tasdelen . Will take a look soon at the two issues you've opened, thanks! |
If you are interested, I can send PRs? |
Yes PRs are most welcome! Definitely easier to maintain this framework with more helping hands :) |
@sravan953 I see that both arbitrary gradients and extended trapezoids have the same type, 'grad'. Arbitrary grads assumed to be in GRT, whereas extended trapezoids are not. To fix the issue, I see two options.
|
Thus far I have tried to keep PyPulseq identical to Pulseq in terms of code and structure so that users who use both platforms, or come from MATLAB to Python, don't find it jarring. Therefore, I would prefer method #2. However, I believe |
Got it. I agree that overall waveforms_and_times() is more useful, but there are a couple of cases where gradients directly returned on GRT is more convenient. One such example is detecting gradient resonance frequencies, where we take the FT of the entire waveform and check if there are peaks near the forbidden frequencies. Another case is gradient moment calculations. I will check how it is implemented in the Pulseq, and make necessary changes accordingly. Edit: I realized that function is dysfunctional in Pulseq. I believe the correct way to implement this function is to call However, if you also want to keep the implementations the same, as well as the interface, I will understand. In that case, users can create their own convenience functions as I described. |
Thank you for sharing example use cases, I was not aware. Your suggestion sounds like a good idea -- and I agree with reusing code to reduce the risk of introducing bugs. Have you tried chaining the two methods and does it fix the issue? |
I already did that for my fork. I did not observe any issues with my implementation yet. Creating a PR soon. |
Describe the bug
The issue arises when a trapezoid is defined by time points and amplitudes.
gradient_waveforms()
function directly puts gradient's waveform variable into the gradient axis without considering the timings, which results in incorrect rendering of the gradient. The responsible part seems to be in Sequence.py line 667:Ideally, there should be a code that interpolates the waveform using grad.tt to gradient raster time before the aforementioned line.
To Reproduce
Here is a minimal sequence that reproduces the bug:
Expected behavior
The function should return correct gradient waveforms.
Screenshots
Here is a figure showing how the gradient is rendered. This also causes incorrect calculation of slew rate.
Desktop (please complete the following information):
pypulseq
version: dev branchThe text was updated successfully, but these errors were encountered: