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

Cannot generate trapezoidal gradient only specifying amplitude and duration. #145

Closed
wtclarke opened this issue Nov 1, 2023 · 1 comment
Assignees

Comments

@wtclarke
Copy link
Contributor

wtclarke commented Nov 1, 2023

Describe the bug
If you run make_trapezoid(channel='x', amplitude=1, duration=1) (ignore the not sensible values) an unhandled exception is thrown.

            if rise_time == 0:
                rise_time = (
>                   math.ceil(abs(amplitude2) / max_slew / system.grad_raster_time)
                    * system.grad_raster_time
                )
E               UnboundLocalError: cannot access local variable 'amplitude2' where it is not associated with a value

pypulseq/make_trapezoid.py:174: UnboundLocalError

This is because within the if statement elif duration > 0: on line 146 there is a case for amplitude == 0 line 147 but not an else ( for amplitude !=0). Within this statement amplitude2 is declared.

To Reproduce

  • Run make_trapezoid(channel='x', amplitude=1, duration=1)

Expected behavior
It's indicated in the documentation that this should work and it isn't handled explicitly.

Additional context
I'll make a PR with a fix and some tests.

@wtclarke
Copy link
Contributor Author

Fixed with the merge of #146

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