99from vesskel .features import compute_tortuosity , extract_node_features
1010
1111if TYPE_CHECKING :
12- from napari .types import LayerDataTuple
12+ from napari .types import LayerDataTuple # noqa: F401
1313
1414
1515def extract_skeleton_layers (
@@ -20,7 +20,7 @@ def extract_skeleton_layers(
2020 config : ExtractionConfig | None = None ,
2121 features : dict [str , float ] | None = None ,
2222 radius_matrix : np .ndarray | None = None ,
23- ) -> list ["napari.types.LayerDataTuple" ]:
23+ ) -> list ["napari.types.LayerDataTuple" ]: # noqa: F821
2424 """Extract visualization layers from a binary skeleton.
2525
2626 Parameters
@@ -56,15 +56,15 @@ def extract_skeleton_layers(
5656 layers .append (text_layer )
5757
5858 if config .nodes :
59- node_layer = _extract_node_features_layer (base_name , graph , branch_data , radius_matrix = radius_matrix )
59+ node_layer = _extract_node_features_layer (
60+ base_name , graph , branch_data , radius_matrix = radius_matrix
61+ )
6062 if node_layer is not None :
6163 layers .append (node_layer )
6264
6365 if config .summary :
6466 if features is None :
65- raise ValueError (
66- "features is required when summary is enabled"
67- )
67+ raise ValueError ("features is required when summary is enabled" )
6868 summary_layer = _extract_summary_features_layer (
6969 skeleton ,
7070 base_name ,
@@ -84,7 +84,7 @@ def _extract_radius_layer(
8484 radius_matrix : np .ndarray ,
8585 skeleton : np .ndarray ,
8686 base_name : str ,
87- ) -> "napari.types.LayerDataTuple | None" :
87+ ) -> "napari.types.LayerDataTuple | None" : # noqa: F821
8888 """Create an image layer showing per-pixel vessel radius on the skeleton."""
8989 if not np .any (radius_matrix ):
9090 return None
@@ -103,7 +103,7 @@ def _extract_branch_features_layer(
103103 base_name : str ,
104104 graph : Skeleton ,
105105 branch_data ,
106- ) -> "napari.types.LayerDataTuple | None" :
106+ ) -> "napari.types.LayerDataTuple | None" : # noqa: F821
107107 """Extract branch features and generate paths layer.
108108
109109 Parameters
@@ -161,9 +161,9 @@ def _extract_branch_features_layer(
161161
162162
163163def _extract_branch_text_layer (
164- branch_layer : "napari.types.LayerDataTuple" ,
164+ branch_layer : "napari.types.LayerDataTuple" , # noqa: F821
165165 base_name : str ,
166- ) -> "napari.types.LayerDataTuple" :
166+ ) -> "napari.types.LayerDataTuple" : # noqa: F821
167167 path_data = branch_layer [0 ]
168168 branch_data = branch_layer [1 ]["properties" ]
169169
@@ -197,7 +197,7 @@ def _extract_summary_features_layer(
197197 skeleton : np .ndarray ,
198198 base_name : str ,
199199 features : dict [str , float ],
200- ) -> "napari.types.LayerDataTuple" :
200+ ) -> "napari.types.LayerDataTuple" : # noqa: F821
201201 """Create a summary point layer displaying global skeleton features.
202202
203203 Parameters
@@ -242,17 +242,24 @@ def _extract_node_features_layer(
242242 graph : Skeleton ,
243243 branch_data ,
244244 radius_matrix : np .ndarray | None = None ,
245- ) -> "napari.types.LayerDataTuple | None" :
245+ ) -> "napari.types.LayerDataTuple | None" : # noqa: F821
246246 """Create a points layer showing graph nodes colored by degree."""
247- node_records = extract_node_features (graph , branch_data , radius_matrix = radius_matrix )
247+ node_records = extract_node_features (
248+ graph , branch_data , radius_matrix = radius_matrix
249+ )
248250 if not node_records :
249251 return None
250252
251253 ndim = graph .coordinates .shape [1 ]
252- points = np .array ([tuple (r [f"coord_{ d } " ] for d in range (ndim )) for r in node_records ], dtype = float )
253-
254- props = {k : [r [k ] for r in node_records ] for k in node_records [0 ].keys ()
255- if not k .startswith ("coord_" )}
254+ points = np .array (
255+ [tuple (r [f"coord_{ d } " ] for d in range (ndim )) for r in node_records ], dtype = float
256+ )
257+
258+ props = {
259+ k : [r [k ] for r in node_records ]
260+ for k in node_records [0 ].keys ()
261+ if not k .startswith ("coord_" )
262+ }
256263
257264 meta = {
258265 "name" : f"{ base_name } _nodes" ,
0 commit comments