imr-framework / pypulseq

Pulseq in Python
https://pypulseq.readthedocs.io
GNU Affero General Public License v3.0
125 stars 67 forks source link

Fix inconsistency in "return_delay" argument of RF pulses #206

Closed mavel101 closed 1 week ago

mavel101 commented 3 weeks ago

This PR fixes an inconsistent behaviour of the "return_delay" argument for RF pulses. Currently, delays are returned only, if also "return_gz" is set to True, except for adiabatic pulses. However, sometimes it is useful to return a delay, even when no slice gradient is desired. The behaviour is now the same as in make_adiabatic_pulse.py

This PR also replaces the deprecated zero-filling at the end of an RF pulse for sigpy pulses by returning a delay instead.

FrankZijlstra commented 3 weeks ago

I have a few queries regarding this delay event, most of which isn't so much related to this PR, but worth having a little discussion about:

If there is a purpose for the delay event, I see no problems with the PR. Otherwise, I suggest removing it altogether.

@schuenke @btasdelen What are your thoughts?

btasdelen commented 3 weeks ago

I am for removing it.

mavel101 commented 3 weeks ago

I agree, the ringdown time is already covered in calc_duration. A very specific use case would be to play an RF pulse, which is not aligned to the gradient raster time. However, this is not covered by the current implementation and could easily be done outside.

If you wish, I could remove all return_delay arguments and outputs and update this PR.

FrankZijlstra commented 2 weeks ago

Yes, it would be good if you could remove the delay outputs. Do note that I merged another PR recently, so it's probably easiest to just do a hard reset on your branch.

mavel101 commented 2 weeks ago

I removed the delay outputs and also removed one test, that checked the delay object of the adiabatic pulse.

FrankZijlstra commented 2 weeks ago

Thanks for the fix, looks good to me. One small thing: Could you remove the return type hints that included the delay? E.g. in make_sinc_pulse that would be Tuple[SimpleNamespace, SimpleNamespace, SimpleNamespace, SimpleNamespace],

mavel101 commented 2 weeks ago

I removed them along with some unnecessary imports

btasdelen commented 1 week ago

I think this PR is ready, any other comments @FrankZijlstra?

FrankZijlstra commented 1 week ago

No comments, just forgot 😂. Will merge it now.