diff --git a/src/mrpro/data/KTrajectory.py b/src/mrpro/data/KTrajectory.py index 7ce99c60..2a0a2892 100644 --- a/src/mrpro/data/KTrajectory.py +++ b/src/mrpro/data/KTrajectory.py @@ -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 diff --git a/tests/data/_PulseqRadialTestSeq.py b/tests/data/_PulseqRadialTestSeq.py index 82cab557..0cd9b603 100644 --- a/tests/data/_PulseqRadialTestSeq.py +++ b/tests/data/_PulseqRadialTestSeq.py @@ -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) diff --git a/tests/data/test_traj_calculators.py b/tests/data/test_traj_calculators.py index 7ddcb30a..8ac3d0b7 100644 --- a/tests/data/test_traj_calculators.py +++ b/tests/data/test_traj_calculators.py @@ -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) torch.testing.assert_close(trajectory.ky.to(torch.float32), ky_test.to(torch.float32), atol=1e-2, rtol=1e-3)