@@ -26,15 +26,15 @@ def read_lung_data():
26
26
class TestSSM (unittest .TestCase ):
27
27
def test_morph_model (self ):
28
28
num_repititions = 10
29
- for _ in range (0 , num_repititions ):
29
+ for test_sample_id in range (0 , num_repititions ):
30
30
landmark_coordinates = read_lung_data ()
31
31
32
32
ssm_obj = pyssam .SSM (landmark_coordinates )
33
33
ssm_obj .create_pca_model (ssm_obj .landmarks_columns_scale )
34
34
mean_shape_columnvector = ssm_obj .compute_dataset_mean ()
35
35
mean_shape = mean_shape_columnvector .reshape (- 1 , 3 )
36
36
37
- test_sample_id = np .random .randint (0 , len (landmark_coordinates ))
37
+ # test_sample_id = np.random.randint(0, len(landmark_coordinates))
38
38
test_shape_columnvec = (
39
39
landmark_coordinates [test_sample_id ] - landmark_coordinates [test_sample_id ].mean (axis = 0 )
40
40
).reshape (- 1 )
@@ -64,7 +64,7 @@ def test_morph_model(self):
64
64
65
65
def test_morph_model_reduced_dimension (self ):
66
66
num_repititions = 10
67
- for _ in range (0 , num_repititions ):
67
+ for test_sample_id in range (0 , num_repititions ):
68
68
landmark_coordinates = read_lung_data ()
69
69
70
70
ssm_obj = pyssam .SSM (landmark_coordinates )
@@ -73,7 +73,7 @@ def test_morph_model_reduced_dimension(self):
73
73
mean_shape_columnvector = ssm_obj .compute_dataset_mean ()
74
74
mean_shape = mean_shape_columnvector .reshape (- 1 , 3 )
75
75
76
- test_sample_id = np .random .randint (0 , len (landmark_coordinates ))
76
+ # test_sample_id = np.random.randint(0, len(landmark_coordinates))
77
77
test_shape_columnvec = (
78
78
landmark_coordinates [test_sample_id ] - landmark_coordinates [test_sample_id ].mean (axis = 0 )
79
79
).reshape (- 1 )
@@ -100,13 +100,12 @@ def test_morph_model_reduced_dimension(self):
100
100
101
101
def test_fit_model_parameters_all_modes (self ):
102
102
num_repititions = 10
103
- for _ in range (0 , num_repititions ):
103
+ for test_sample_id in range (0 , num_repititions ):
104
104
landmark_coordinates = read_lung_data ()
105
105
106
106
ssm_obj = pyssam .SSM (landmark_coordinates )
107
107
ssm_obj .create_pca_model (ssm_obj .landmarks_columns_scale , desired_variance = 0.7 )
108
108
109
- test_sample_id = np .random .randint (0 , len (landmark_coordinates ))
110
109
target_shape = ssm_obj .landmarks_columns_scale [test_sample_id ]
111
110
model_parameters = ssm_obj .fit_model_parameters (target_shape , ssm_obj .pca_model_components )
112
111
model_parameters = np .where (model_parameters < 5 , model_parameters , 3 )
@@ -115,17 +114,16 @@ def test_fit_model_parameters_all_modes(self):
115
114
dataset_mean = ssm_obj .compute_dataset_mean ()
116
115
morphed_shape = ssm_obj .morph_model (dataset_mean , ssm_obj .pca_model_components , model_parameters )
117
116
error = abs (target_shape - morphed_shape )
118
- assert np .isclose (error .mean (), 0 ), f"error is non-zero ({ error .mean ()} )"
117
+ assert np .isclose (error .mean (), 0 ), f"error is non-zero ({ error .mean ()} ) sample { test_sample_id } "
119
118
120
119
def test_fit_model_parameters_reduced_modes (self ):
121
120
num_repititions = 10
122
- for _ in range (0 , num_repititions ):
121
+ for test_sample_id in range (0 , num_repititions ):
123
122
landmark_coordinates = read_lung_data ()
124
123
125
124
ssm_obj = pyssam .SSM (landmark_coordinates )
126
125
ssm_obj .create_pca_model (ssm_obj .landmarks_columns_scale , desired_variance = 0.7 )
127
126
128
- test_sample_id = np .random .randint (0 , len (landmark_coordinates ))
129
127
target_shape = ssm_obj .landmarks_columns_scale [test_sample_id ]
130
128
model_parameters = ssm_obj .fit_model_parameters (target_shape , ssm_obj .pca_model_components , num_modes = 2 )
131
129
dataset_mean = ssm_obj .compute_dataset_mean ()
0 commit comments