Skip to content
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

Add information to pp.calc_duration return #239

Open
dornstto opened this issue Jan 20, 2025 · 2 comments
Open

Add information to pp.calc_duration return #239

dornstto opened this issue Jan 20, 2025 · 2 comments

Comments

@dornstto
Copy link

I think it would be useful to have the type of event and in case of the type beeing some type of gradient the gradient channel to be returned with the duration.
This makes sense to me when using pp.calc_duration with multiple blocks running at the same time and wanting to find out which one is actually responsible for the max length of the block.
This could be added in the if statements without much hussle.
E.g.:
if event.type == "delay":
duration_temp = max(duration, event.delay)
if duration_temp != duration:
event_info = event.type
duration = duration_temp

or for gradients:
elif event.type == "grad":
duration_temp = max(duration, event.delay + event.shape_dur)
if duration_temp != duration:
event_info = (event.type, event.channel)
duration = duration_temp

@FrankZijlstra
Copy link
Collaborator

FrankZijlstra commented Jan 23, 2025

I see how this could be useful in certain situations, though probably only in an interactive notebook/ipython environment while debugging. I can not think of many situations where you'd use this information as part of the actual sequence design, and where it isn't already obvious which events may be the longest:
i.e. if pp.calc_duration(gx,gy)[1].channel == 'x':
vs
if pp.calc_duration(gx) > pp.calc_duration(gy)

We cannot just add another return value without breaking backwards compatibility though. And this a function that is very likely to be used in most sequences. To avoid this, there is the possibility of adding a keyword argument: pp.calc_duration(adc, gx, gy, return_longest=True) -> (<duration>, <event>)

@dornstto
Copy link
Author

To avoid this, there is the possibility of adding a keyword argument: pp.calc_duration(adc, gx, gy, return_longest=True) -> (duration, event) <

This would also be feasible for me, my usecase was a block where a read spoiler gradient was played at the same time, in the same block as rephasing gradients and I wanted to determine which one was crucial for the block length.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants