Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 committed Dec 16, 2024
1 parent ef0564a commit 2450509
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/mrpro/data/KTrajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def from_tensor(
kz, ky, kx = (ks[axes_order.index(axis)] for axis in 'zyx')

def normalize(k: torch.Tensor, encoding_size: int) -> torch.Tensor:
max_abs_range = 2 * k.max().abs()
max_abs_range = 2 * k.abs().max()
if encoding_size == 1 or max_abs_range < 1e-6:
# a single encoding point should be at zero
# avoid division by zero
Expand Down
4 changes: 3 additions & 1 deletion tests/data/_PulseqRadialTestSeq.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ def __init__(self, seq_filename: str, n_x=256, n_spokes=10):

system = pypulseq.Opts()
rf, gz, _ = pypulseq.make_sinc_pulse(flip_angle=0.1, slice_thickness=1e-3, system=system, return_gz=True)
gx = pypulseq.make_trapezoid(channel='x', flat_area=n_x * delta_k, flat_time=2e-3, system=system)
gx = pypulseq.make_trapezoid(
channel='x', flat_area=n_x * delta_k, flat_time=n_x * system.grad_raster_time, system=system
)
adc = pypulseq.make_adc(num_samples=n_x, duration=gx.flat_time, delay=gx.rise_time, system=system)
gx_pre = pypulseq.make_trapezoid(channel='x', area=-gx.area / 2 - delta_k / 2, duration=2e-3, system=system)
gz_reph = pypulseq.make_trapezoid(channel='z', area=-gz.area / 2, duration=2e-3, system=system)
Expand Down
8 changes: 4 additions & 4 deletions tests/data/test_traj_calculators.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,11 @@ def test_KTrajectoryPulseq_validseq_random_header(pulseq_example_rad_seq, valid_
trajectory_calculator = KTrajectoryPulseq(seq_path=pulseq_example_rad_seq.seq_filename)
trajectory = trajectory_calculator(kheader=valid_rad2d_kheader)

kx_test = pulseq_example_rad_seq.traj_analytical.kx.squeeze(0).squeeze(0)
kx_test *= valid_rad2d_kheader.encoding_matrix.x / (2 * torch.max(torch.abs(kx_test)))
kx_test = pulseq_example_rad_seq.traj_analytical.kx.squeeze()
kx_test = kx_test * valid_rad2d_kheader.encoding_matrix.x / (2 * kx_test.abs().max())

ky_test = pulseq_example_rad_seq.traj_analytical.ky.squeeze(0).squeeze(0)
ky_test *= valid_rad2d_kheader.encoding_matrix.y / (2 * torch.max(torch.abs(ky_test)))
ky_test = pulseq_example_rad_seq.traj_analytical.ky.squeeze()
ky_test = ky_test * valid_rad2d_kheader.encoding_matrix.y / (2 * ky_test.abs().max())

torch.testing.assert_close(trajectory.kx.to(torch.float32), kx_test.to(torch.float32), atol=1e-2, rtol=1e-3)

Check failure on line 269 in tests/data/test_traj_calculators.py

View workflow job for this annotation

GitHub Actions / Run Tests and Coverage Report (mrpro_py311)

test_KTrajectoryPulseq_validseq_random_header[random_kheader0-random_full_ismrmrd_header0-random_acquisition0] AssertionError: Tensor-likes are not close! Mismatched elements: 2261 / 2560 (88.3%) Greatest absolute difference: 1.00787353515625 at index (0, 0) (up to 0.01 allowed) Greatest relative difference: 0.008026312105357647 at index (3, 131) (up to 0.001 allowed)

Check failure on line 269 in tests/data/test_traj_calculators.py

View workflow job for this annotation

GitHub Actions / Run Tests and Coverage Report (mrpro_py310)

test_KTrajectoryPulseq_validseq_random_header[random_kheader0-random_full_ismrmrd_header0-random_acquisition0] AssertionError: Tensor-likes are not close! Mismatched elements: 2261 / 2560 (88.3%) Greatest absolute difference: 1.00787353515625 at index (0, 0) (up to 0.01 allowed) Greatest relative difference: 0.008026312105357647 at index (3, 131) (up to 0.001 allowed)

Check failure on line 269 in tests/data/test_traj_calculators.py

View workflow job for this annotation

GitHub Actions / Run Tests and Coverage Report (mrpro_py312)

test_KTrajectoryPulseq_validseq_random_header[random_kheader0-random_full_ismrmrd_header0-random_acquisition0] AssertionError: Tensor-likes are not close! Mismatched elements: 2261 / 2560 (88.3%) Greatest absolute difference: 1.00787353515625 at index (0, 0) (up to 0.01 allowed) Greatest relative difference: 0.008026312105357647 at index (3, 131) (up to 0.001 allowed)
torch.testing.assert_close(trajectory.ky.to(torch.float32), ky_test.to(torch.float32), atol=1e-2, rtol=1e-3)

0 comments on commit 2450509

Please sign in to comment.