Closed btasdelen closed 2 years ago
Workaround: Passing convert_to_arbitrary=True
to make_extended_trapezoid()
seems to work around the issue, naturally, but kind of defeats the purpose of extended trapezoids. Also, that parameter is not exposed to make_extended_trapezoid_area()
.
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 waveforms_and_times()
would be the more appropriate method to use here? It returns gradient values and their respective timepoints.
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 waveforms_and_times()
, and then call points_to_waveform()
on the output to raster the waveforms. It is best this way because it will reuse the existing functions and reduce the risk of introducing bugs.
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 branch