Skip to content

Commit

Permalink
add parameterize ids
Browse files Browse the repository at this point in the history
  • Loading branch information
fzimmermann89 committed Oct 27, 2024
1 parent 1a7b29b commit bd01971
Show file tree
Hide file tree
Showing 5 changed files with 189 additions and 166 deletions.
3 changes: 2 additions & 1 deletion tests/algorithms/test_cg.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
(1, 32, False),
(4, 32, True),
(4, 32, False),
]
],
ids=['complex_single', 'real_single', 'complex_batch', 'real_batch'],
)
def system(request):
"""Generate data for creating a system Hx=b with linear and self-adjoint
Expand Down
294 changes: 148 additions & 146 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,11 @@ def create_traj(k_shape, nkx, nky, nkz, sx, sy, sz):
random_generator = RandomGenerator(seed=0)
k_list = []
for spacing, nk in zip([sz, sy, sx], [nkz, nky, nkx], strict=True):
if spacing == 'nuf':
if spacing == 'non-uniform':
k = random_generator.float32_tensor(size=nk)
elif spacing == 'uf':
elif spacing == 'uniform':
k = create_uniform_traj(nk, k_shape=k_shape)
elif spacing == 'z':
elif spacing == 'zero':
k = torch.zeros(nk)
k_list.append(k)
trajectory = KTrajectory(k_list[0], k_list[1], k_list[2], repeat_detection_tolerance=None)
Expand All @@ -252,159 +252,161 @@ def create_traj(k_shape, nkx, nky, nkz, sx, sy, sz):
COMMON_MR_TRAJECTORIES = pytest.mark.parametrize(
('im_shape', 'k_shape', 'nkx', 'nky', 'nkz', 'sx', 'sy', 'sz', 's0', 's1', 's2'),
[
# (0) 2d cart mri with 1 coil, no oversampling
(
(1, 1, 1, 96, 128), # img shape
(1, 1, 1, 96, 128), # k shape
(1, 1, 1, 128), # kx
(1, 1, 96, 1), # ky
(1, 1, 1, 1), # kz
'uf', # kx is uniform
'uf', # ky is uniform
'z', # zero so no Fourier transform is performed along that dimension
'uf', # k0 is uniform
'uf', # k1 is uniform
'z', # k2 is singleton
( # (0) 2d cart mri with 1 coil, no oversampling
(1, 1, 1, 96, 128), # im_shape
(1, 1, 1, 96, 128), # k_shape
(1, 1, 1, 128), # nkx
(1, 1, 96, 1), # nky
(1, 1, 1, 1), # nkz
'uniform', # sx
'uniform', # sy
'zero', # sz
'uniform', # s0
'uniform', # s1
'zero', # s2
),
# (1) 2d cart mri with 1 coil, with oversampling
(
(1, 1, 1, 96, 128),
(1, 1, 1, 128, 192),
(1, 1, 1, 192),
(1, 1, 128, 1),
(1, 1, 1, 1),
'uf',
'uf',
'z',
'uf',
'uf',
'z',
( # (1) 2d cart mri with 1 coil, with oversampling
(1, 1, 1, 96, 128), # im_shape
(1, 1, 1, 128, 192), # k_shape
(1, 1, 1, 192), # nkx
(1, 1, 128, 1), # nky
(1, 1, 1, 1), # nkz
'uniform', # sx
'uniform', # sy
'zero', # sz
'uniform', # s0
'uniform', # s1
'zero', # s2
),
# (2) 2d non-Cartesian mri with 2 coils
(
(1, 2, 1, 96, 128),
(1, 2, 1, 16, 192),
(1, 1, 16, 192),
(1, 1, 16, 192),
(1, 1, 1, 1),
'nuf', # kx is non-uniform
'nuf',
'z',
'nuf',
'nuf',
'z',
( # (2) 2d non-Cartesian mri with 2 coils
(1, 2, 1, 96, 128), # im_shape
(1, 2, 1, 16, 192), # k_shape
(1, 1, 16, 192), # nkx
(1, 1, 16, 192), # nky
(1, 1, 1, 1), # nkz
'non-uniform', # sx
'non-uniform', # sy
'zero', # sz
'non-uniform', # s0
'non-uniform', # s1
'zero', # s2
),
# (3) 2d cart mri with irregular sampling
(
(1, 1, 1, 96, 128),
(1, 1, 1, 1, 192),
(1, 1, 1, 192),
(1, 1, 1, 192),
(1, 1, 1, 1),
'uf',
'uf',
'z',
'uf',
'z',
'z',
( # (3) 2d cart mri with irregular sampling
(1, 1, 1, 96, 128), # im_shape
(1, 1, 1, 1, 192), # k_shape
(1, 1, 1, 192), # nkx
(1, 1, 1, 192), # nky
(1, 1, 1, 1), # nkz
'uniform', # sx
'uniform', # sy
'zero', # sz
'uniform', # s0
'zero', # s1
'zero', # s2
),
# (4) 2d single shot spiral
(
(1, 2, 1, 96, 128),
(1, 1, 1, 1, 192),
(1, 1, 1, 192),
(1, 1, 1, 192),
(1, 1, 1, 1),
'nuf',
'nuf',
'z',
'nuf',
'z',
'z',
( # (4) 2d single shot spiral
(1, 2, 1, 96, 128), # im_shape
(1, 1, 1, 1, 192), # k_shape
(1, 1, 1, 192), # nkx
(1, 1, 1, 192), # nky
(1, 1, 1, 1), # nkz
'non-uniform', # sx
'non-uniform', # sy
'zero', # sz
'non-uniform', # s0
'zero', # s1
'zero', # s2
),
# (5) 3d nuFFT mri, 4 coils, 2 other
(
(2, 4, 16, 32, 64),
(2, 4, 16, 32, 64),
(2, 16, 32, 64),
(2, 16, 32, 64),
(2, 16, 32, 64),
'nuf',
'nuf',
'nuf',
'nuf',
'nuf',
'nuf',
( # (5) 3d nuniformFT mri, 4 coils, 2 other
(2, 4, 16, 32, 64), # im_shape
(2, 4, 16, 32, 64), # k_shape
(2, 16, 32, 64), # nkx
(2, 16, 32, 64), # nky
(2, 16, 32, 64), # nkz
'non-uniform', # sx
'non-uniform', # sy
'non-uniform', # sz
'non-uniform', # s0
'non-uniform', # s1
'non-uniform', # s2
),
# (6) 2d nuFFT cine mri with 8 cardiac phases, 5 coils
(
(8, 5, 1, 64, 64),
(8, 5, 1, 18, 128),
(8, 1, 18, 128),
(8, 1, 18, 128),
(8, 1, 1, 1),
'nuf',
'nuf',
'z',
'nuf',
'nuf',
'z',
( # (6) 2d nuniformFT cine mri with 8 cardiac phases, 5 coils
(8, 5, 1, 64, 64), # im_shape
(8, 5, 1, 18, 128), # k_shape
(8, 1, 18, 128), # nkx
(8, 1, 18, 128), # nky
(8, 1, 1, 1), # nkz
'non-uniform', # sx
'non-uniform', # sy
'zero', # sz
'non-uniform', # s0
'non-uniform', # s1
'zero', # s2
),
# (7) 2d cart cine mri with 9 cardiac phases, 6 coils
(
(9, 6, 1, 96, 128),
(9, 6, 1, 128, 192),
(9, 1, 1, 192),
(9, 1, 128, 1),
(9, 1, 1, 1),
'uf',
'uf',
'z',
'uf',
'uf',
'z',
( # (7) 2d cart cine mri with 9 cardiac phases, 6 coils
(9, 6, 1, 96, 128), # im_shape
(9, 6, 1, 128, 192), # k_shape
(9, 1, 1, 192), # nkx
(9, 1, 128, 1), # nky
(9, 1, 1, 1), # nkz
'uniform', # sx
'uniform', # sy
'zero', # sz
'uniform', # s0
'uniform', # s1
'zero', # s2
),
# (8) radial phase encoding (RPE), 8 coils, with oversampling in both FFT and nuFFT directions
(
(2, 8, 64, 32, 48),
(2, 8, 8, 64, 96),
(2, 1, 1, 96),
(2, 8, 64, 1),
(2, 8, 64, 1),
'uf',
'nuf',
'nuf',
'uf',
'nuf',
'nuf',
( # (8) radial phase encoding (RPE), 8 coils, with oversampling in both FFT and nuniformFT directions
(2, 8, 64, 32, 48), # im_shape
(2, 8, 8, 64, 96), # k_shape
(2, 1, 1, 96), # nkx
(2, 8, 64, 1), # nky
(2, 8, 64, 1), # nkz
'uniform', # sx
'non-uniform', # sy
'non-uniform', # sz
'uniform', # s0
'non-uniform', # s1
'non-uniform', # s2
),
# (9) radial phase encoding (RPE) , 8 coils with non-Cartesian sampling along readout
(
(2, 8, 64, 32, 48),
(2, 8, 8, 64, 96),
(2, 1, 1, 96),
(2, 8, 64, 1),
(2, 8, 64, 1),
'nuf',
'nuf',
'nuf',
'nuf',
'nuf',
'nuf',
( # (9) radial phase encoding (RPE) , 8 coils with non-Cartesian sampling along readout
(2, 8, 64, 32, 48), # im_shape
(2, 8, 8, 64, 96), # k_shape
(2, 1, 1, 96), # nkx
(2, 8, 64, 1), # nky
(2, 8, 64, 1), # nkz
'non-uniform', # sx
'non-uniform', # sy
'non-uniform', # sz
'non-uniform', # s0
'non-uniform', # s1
'non-uniform', # s2
),
# (10) stack of stars, 5 other, 3 coil, oversampling in both FFT and nuFFT directions
(
(5, 3, 48, 16, 32),
(5, 3, 96, 18, 64),
(5, 1, 18, 64),
(5, 1, 18, 64),
(5, 96, 1, 1),
'nuf',
'nuf',
'uf',
'nuf',
'nuf',
'uf',
( # (10) stack of stars, 5 other, 3 coil, oversampling in both FFT and nuniformFT directions
(5, 3, 48, 16, 32), # im_shape
(5, 3, 96, 18, 64), # k_shape
(5, 1, 18, 64), # nkx
(5, 1, 18, 64), # nky
(5, 96, 1, 1), # nkz
'non-uniform', # sx
'non-uniform', # sy
'uniform', # sz
'non-uniform', # s0
'non-uniform', # s1
'uniform', # s2
),
],
ids=[
'2d_cart_mri_1_coil_no_oversampling',
'2d_cart_mri_1_coil_with_oversampling',
'2d_non_cartesian_mri_2_coils',
'2d_cart_mri_irregular_sampling',
'2d_single_shot_spiral',
'3d_nuniformFT_mri_4_coils_2_other',
'2d_nuniformFT_cine_mri_8_cardiac_phases_5_coils',
'2d_cart_cine_mri_9_cardiac_phases_6_coils',
'radial_phase_encoding_8_coils_with_oversampling',
'radial_phase_encoding_8_coils_non_cartesian_sampling',
'stack_of_stars_5_other_3_coil_with_oversampling',
],
)
20 changes: 19 additions & 1 deletion tests/operators/models/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
SHAPE_VARIATIONS_SIGNAL_MODELS = pytest.mark.parametrize(
('parameter_shape', 'contrast_dim_shape', 'signal_shape'),
[
((1, 1, 10, 20, 30), (5,), (5, 1, 1, 10, 20, 30)), # single map with different inversion times
((1, 1, 10, 20, 30), (5,), (5, 1, 1, 10, 20, 30)), # single map with different contrast times
((1, 1, 10, 20, 30), (5, 1), (5, 1, 1, 10, 20, 30)),
((4, 1, 1, 10, 20, 30), (5, 1), (5, 4, 1, 1, 10, 20, 30)), # multiple maps along additional batch dimension
((4, 1, 1, 10, 20, 30), (5,), (5, 4, 1, 1, 10, 20, 30)),
Expand All @@ -25,6 +25,24 @@
((1,), (5,), (5, 1)), # single voxel
((4, 3, 1), (5, 4, 3), (5, 4, 3, 1)),
],
ids=[
'single_map_diff_contrast_times',
'single_map_diff_contrast_times_2',
'multiple_maps_additional_batch_dim',
'multiple_maps_additional_batch_dim_2',
'multiple_maps_additional_batch_dim_3',
'multiple_maps_other_dim',
'multiple_maps_other_dim_2',
'multiple_maps_other_dim_3',
'multiple_maps_other_and_batch_dim',
'multiple_maps_other_and_batch_dim_2',
'multiple_maps_other_and_batch_dim_3',
'multiple_maps_other_and_batch_dim_4',
'multiple_maps_other_and_batch_dim_5',
'different_value_each_voxel',
'single_voxel',
'multiple_voxels',
],
)


Expand Down
Loading

0 comments on commit bd01971

Please sign in to comment.