@@ -52,60 +52,35 @@ def cross_image(self):
5252 return img
5353
5454 @pytest .fixture
55- def default_config (self ):
55+ def analysis_config (self ):
56+ """Shared config with branches and summary enabled."""
5657 return PipelineConfig (
57- extraction = ExtractionConfig (),
58+ extraction = ExtractionConfig (branches = True , summary = True ),
5859 output = OutputConfig (),
5960 )
6061
61- def test_empty_image_returns_empty_result (self , default_config ):
62+ def test_empty_image_returns_empty_result (self , analysis_config ):
6263 img = np .zeros ((32 , 32 ), dtype = np .uint8 )
63- result = analyze_binary_image (img , "test" , default_config )
64+ result = analyze_binary_image (img , "test" , analysis_config )
6465 assert not result .skeleton .any ()
6566 assert result .layers == []
6667 assert result .summary_features == {}
6768 assert result .branch_records == []
6869 assert result .radius_matrix is None
6970
70- def test_all_zero_image_is_empty (self , default_config ):
71- result = analyze_binary_image (np .zeros ((8 , 8 )), "z" , default_config )
72- assert not result .skeleton .any ()
73-
74- def test_cross_produces_skeleton (self , cross_image , default_config ):
75- result = analyze_binary_image (cross_image , "cross" , default_config )
71+ def test_cross_produces_skeleton (self , cross_image , analysis_config ):
72+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
7673 assert result .skeleton .any ()
7774 assert result .skeleton .dtype == np .uint8
7875 assert result .skeleton .shape == cross_image .shape
7976
80- def test_non_binary_input_is_binarized (self , default_config ):
77+ def test_non_binary_input_is_binarized (self , analysis_config ):
8178 img = np .zeros ((20 , 20 ), dtype = np .int32 )
8279 img [10 , 5 :15 ] = 200
83- result = analyze_binary_image (img , "test" , default_config )
80+ result = analyze_binary_image (img , "test" , analysis_config )
8481 assert result .skeleton .any ()
8582 assert set (np .unique (result .skeleton )) <= {0 , 1 }
8683
87- def test_layers_have_three_element_tuples (self , cross_image , default_config ):
88- result = analyze_binary_image (cross_image , "test" , default_config )
89- assert len (result .layers ) > 0
90- for layer in result .layers :
91- assert len (layer ) == 3
92- assert isinstance (layer [1 ], dict )
93- assert isinstance (layer [2 ], str )
94-
95- def test_base_name_in_layer_metadata (self , cross_image , default_config ):
96- result = analyze_binary_image (cross_image , "myimage" , default_config )
97- found = False
98- for layer in result .layers :
99- if "name" in layer [1 ]:
100- found = True
101- break
102- assert found , "No layer has a 'name' key in metadata"
103-
104- def test_summary_features_not_empty (self , cross_image , default_config ):
105- result = analyze_binary_image (cross_image , "cross" , default_config )
106- assert len (result .summary_features ) > 0
107- assert "num_endpoints" in result .summary_features
108-
10984 def test_summary_disabled_returns_empty_features (self , cross_image ):
11085 config = PipelineConfig (
11186 extraction = ExtractionConfig (summary = False ),
@@ -114,18 +89,8 @@ def test_summary_disabled_returns_empty_features(self, cross_image):
11489 result = analyze_binary_image (cross_image , "cross" , config )
11590 assert result .summary_features == {}
11691
117- def test_summary_disabled_in_pipeline_config (self ):
118- img = np .zeros ((16 , 16 ), dtype = np .uint8 )
119- img [8 , 4 :12 ] = 1
120- config = PipelineConfig (
121- extraction = ExtractionConfig (summary = False ),
122- output = OutputConfig (),
123- )
124- result = analyze_binary_image (img , "line" , config )
125- assert result .summary_features == {}
126-
127- def test_branches_enabled_by_default (self , cross_image , default_config ):
128- result = analyze_binary_image (cross_image , "cross" , default_config )
92+ def test_branches_enabled (self , cross_image , analysis_config ):
93+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
12994 assert len (result .branch_records ) > 0
13095 assert isinstance (result .branch_records [0 ], dict )
13196
@@ -139,7 +104,7 @@ def test_branches_disabled_returns_empty_records(self, cross_image):
139104
140105 def test_vessel_radius_enabled (self , cross_image ):
141106 config = PipelineConfig (
142- extraction = ExtractionConfig (vessel_radius = True ),
107+ extraction = ExtractionConfig (vessel_radius = True , summary = True ),
143108 output = OutputConfig (),
144109 )
145110 result = analyze_binary_image (cross_image , "cross" , config )
@@ -148,13 +113,13 @@ def test_vessel_radius_enabled(self, cross_image):
148113 assert result .radius_matrix .any ()
149114 assert result .summary_features ["mean_radius" ] > 0
150115
151- def test_vessel_radius_disabled_radius_none (self , cross_image , default_config ):
152- result = analyze_binary_image (cross_image , "cross" , default_config )
116+ def test_vessel_radius_disabled_radius_none (self , cross_image , analysis_config ):
117+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
153118 assert result .radius_matrix is None
154119
155120 def test_radius_stats_in_summary_when_enabled (self , cross_image ):
156121 config = PipelineConfig (
157- extraction = ExtractionConfig (vessel_radius = True ),
122+ extraction = ExtractionConfig (vessel_radius = True , summary = True ),
158123 output = OutputConfig (),
159124 )
160125 result = analyze_binary_image (cross_image , "cross" , config )
@@ -172,13 +137,13 @@ def test_radius_stats_in_summary_when_enabled(self, cross_image):
172137 assert key in result .summary_features
173138 assert result .summary_features [key ] > 0
174139
175- def test_fractal_dimension_disabled_by_default (self , cross_image , default_config ):
176- result = analyze_binary_image (cross_image , "cross" , default_config )
140+ def test_fractal_dimension_disabled_by_default (self , cross_image , analysis_config ):
141+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
177142 assert result .summary_features ["fractal_dimension" ] == 0.0
178143
179144 def test_fractal_dimension_enabled (self , cross_image ):
180145 config = PipelineConfig (
181- extraction = ExtractionConfig (fractal_dimension = True ),
146+ extraction = ExtractionConfig (fractal_dimension = True , summary = True ),
182147 output = OutputConfig (),
183148 )
184149 result = analyze_binary_image (cross_image , "cross" , config )
@@ -225,7 +190,9 @@ def test_3d_image(self):
225190 vol = np .zeros ((16 , 16 , 16 ), dtype = np .uint8 )
226191 vol [8 , 8 , :] = 1
227192 vol [8 , :, 8 ] = 1
228- config = PipelineConfig (extraction = ExtractionConfig (), output = OutputConfig ())
193+ config = PipelineConfig (
194+ extraction = ExtractionConfig (summary = True ), output = OutputConfig ()
195+ )
229196 result = analyze_binary_image (vol , "vol" , config )
230197 assert result .skeleton .any ()
231198 assert len (result .summary_features ) > 0
@@ -234,18 +201,20 @@ def test_3d_image_with_radius(self):
234201 vol = np .zeros ((12 , 12 , 12 ), dtype = np .uint8 )
235202 vol [6 , 6 , :] = 1
236203 config = PipelineConfig (
237- extraction = ExtractionConfig (vessel_radius = True , fractal_dimension = True ),
204+ extraction = ExtractionConfig (
205+ vessel_radius = True , fractal_dimension = True , summary = True
206+ ),
238207 output = OutputConfig (),
239208 )
240209 result = analyze_binary_image (vol , "vol3d" , config )
241210 assert result .radius_matrix is not None
242211 assert result .radius_matrix .shape == vol .shape
243212 assert result .summary_features ["mean_radius" ] > 0
244213
245- def test_cross_topology_num_endpoints (self , cross_image , default_config ):
246- result = analyze_binary_image (cross_image , "cross" , default_config )
214+ def test_cross_topology_num_endpoints (self , cross_image , analysis_config ):
215+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
247216 assert result .summary_features ["num_endpoints" ] == 4
248217
249- def test_cross_topology_num_bifurcations (self , cross_image , default_config ):
250- result = analyze_binary_image (cross_image , "cross" , default_config )
218+ def test_cross_topology_num_bifurcations (self , cross_image , analysis_config ):
219+ result = analyze_binary_image (cross_image , "cross" , analysis_config )
251220 assert result .summary_features ["num_bifurcations" ] == 1
0 commit comments