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

BF: Minor bug fixes in sequence.py and make_gauss_pulse.py #147

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pypulseq/Sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ def plot(
if show_blocks:
for sp in [sp11, sp12, sp13, *fig2_subplots]:
sp.set_xticks(t_factor * block_edges_in_range)
sp.set_xticklabels(rotation=90)
sp.set_xticklabels(sp.get_xticklabels(), rotation=90)

for block_counter in range(len(self.block_events)):
block = self.get_block(block_counter + 1)
Expand Down
10 changes: 5 additions & 5 deletions pypulseq/make_gauss_pulse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from pypulseq.make_delay import make_delay
from pypulseq.make_trapezoid import make_trapezoid
from pypulseq.opts import Opts
from pypulseq.supported_labels_rf_use import get_supported_rf_uses


def make_gauss_pulse(
Expand Down Expand Up @@ -73,7 +74,7 @@ def make_gauss_pulse(
time_bw_product : int, default=4
Time-bandwidth product.
use : str, default=str()
Use of radio-frequency gauss pulse event. Must be one of 'excitation', 'refocusing' or 'inversion'.
Use of radio-frequency gauss pulse event. Must be one defined in pypulseq.supported_labels_rf_use.get_supported_rf_uses.

Returns
-------
Expand All @@ -89,13 +90,12 @@ def make_gauss_pulse(
Raises
------
ValueError
If invalid `use` is passed. Must be one of 'excitation', 'refocusing' or 'inversion'.
If invalid `use` is passed.
If `return_gz=True` and `slice_thickness` was not passed.
"""
valid_use_pulses = ["excitation", "refocusing", "inversion"]
if use != "" and use not in valid_use_pulses:
if use != "" and use not in get_supported_rf_uses():
raise ValueError(
f"Invalid use parameter. Must be one of 'excitation', 'refocusing' or 'inversion'. Passed: {use}"
f"Invalid use parameter. Must be one of {get_supported_rf_uses()}. Passed: {use}"
)

if dwell == 0:
Expand Down
22 changes: 22 additions & 0 deletions pypulseq/tests/test_make_gauss_pulse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""Tests for the make_gauss_pulse module

Will Clarke, University of Oxford, 2023
"""

from types import SimpleNamespace

import pytest

from pypulseq import make_gauss_pulse
from pypulseq.supported_labels_rf_use import get_supported_rf_uses


def test_use():

with pytest.raises(
ValueError,
match=r"Invalid use parameter. Must be one of"):
make_gauss_pulse(flip_angle=1, use='invalid')

for use in get_supported_rf_uses():
assert isinstance(make_gauss_pulse(flip_angle=1, use=use), SimpleNamespace)
23 changes: 23 additions & 0 deletions pypulseq/tests/test_sequence.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""Tests for the make_gauss_pulse module

Will Clarke, University of Oxford, 2023
"""


from types import SimpleNamespace

import pytest
from unittest.mock import patch

from pypulseq import Sequence
from pypulseq import make_gauss_pulse


@patch("matplotlib.pyplot.show")
def test_plot(mock_show):
seq = Sequence()
seq.add_block(
make_gauss_pulse(flip_angle=1))
assert seq.plot() is None

assert seq.plot(show_blocks=True) is None
Loading