Skip to content

Commit ec60b5c

Browse files
committed
refactor: config parsing
1 parent 1039fbb commit ec60b5c

1 file changed

Lines changed: 2 additions & 23 deletions

File tree

vesskel/config.py

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,7 @@ def to_dict(self) -> dict[str, Any]:
7777
@classmethod
7878
def from_dict(cls, data: dict[str, Any]) -> ExtractionConfig:
7979
_warn_unknown_keys({f.name for f in fields(cls)}, data)
80-
return cls(
81-
branches=data.get("branches", False),
82-
branch_color_property=data.get("branch_color_property", "tortuosity"),
83-
branch_text=data.get("branch_text", False),
84-
nodes=data.get("nodes", False),
85-
summary=data.get("summary", False),
86-
fractal_dimension=data.get("fractal_dimension", False),
87-
vessel_radius=data.get("vessel_radius", False),
88-
junction_cleanup=data.get("junction_cleanup", False),
89-
cleanup_threshold_factor=data.get("cleanup_threshold_factor", 2.5),
90-
closing_iterations=data.get("closing_iterations", 0),
91-
fill_holes=data.get("fill_holes", False),
92-
max_hole_size=data.get("max_hole_size", 0),
93-
show_preprocessed=data.get("show_preprocessed", False),
94-
)
80+
return cls(**{f.name: data.get(f.name, f.default) for f in fields(cls)})
9581

9682

9783
@dataclass
@@ -119,14 +105,7 @@ def to_dict(self) -> dict[str, Any]:
119105
def from_dict(cls, data: dict[str, Any] | None) -> OutputConfig:
120106
data = data or {}
121107
_warn_unknown_keys({f.name for f in fields(cls)}, data)
122-
return cls(
123-
write_skeleton_npy=bool(data.get("write_skeleton_npy", True)),
124-
write_skeleton_png=bool(data.get("write_skeleton_png", False)),
125-
write_summary_csv=bool(data.get("write_summary_csv", True)),
126-
write_branch_csv=bool(data.get("write_branch_csv", False)),
127-
write_node_csv=bool(data.get("write_node_csv", False)),
128-
write_radius=bool(data.get("write_radius", False)),
129-
)
108+
return cls(**{f.name: bool(data.get(f.name, f.default)) for f in fields(cls)})
130109

131110

132111
@dataclass

0 commit comments

Comments
 (0)