Module Reference#
This section covers backend modules by subsystem for developers.
Core Modules#
Feature config JSON helpers.
- Each feature keeps a JSON file under:
swcstudio/tools/<tool>/configs/<feature>.json
- swcstudio.core.config.merge_config(base, overrides)[source]#
Recursively merge config dictionaries without mutating inputs.
- Parameters:
base (dict[str, Any])
overrides (dict[str, Any] | None)
- Return type:
dict[str, Any]
- swcstudio.core.swc_io.strip_line_bom(line)[source]#
linewithout a byte order mark at its start.A BOM belongs at the start of a file, but the
# @PROVheader lines are spliced in above whatever the file starts with, so after an in-place edit it can sit at the start of a later line; it is dropped there too.- Parameters:
line (str)
- Return type:
str
- swcstudio.core.swc_io.split_swc_lines(text)[source]#
textas(content, line_break)pairs; joined back they givetext.Lines break at
\r\n,\ror\n, as text-modeopen()reads them. The last pair’s line break is""when the text does not end with one.- Parameters:
text (str)
- Return type:
list[tuple[str, str]]
- swcstudio.core.swc_io.parse_swc_data_line(content)[source]#
The seven fields of one SWC node line, or
Nonefor any other line.A node line has at least seven whitespace-separated fields that all parse as numbers (id, type and parent as whole numbers written as integers or floats); comment lines, blank lines, short lines and lines with a field that does not parse are not node lines. Fields after the seventh are ignored. This is the rule the labeler’s parser and auto-labeling’s row parse use, so the node lines found here are the nodes that get labeled.
- Parameters:
content (str)
- Return type:
tuple[int, int, float, float, float, float, int] | None
- swcstudio.core.swc_io.swc_data_rows_from_text(text)[source]#
(comment_lines, rows)of an SWC text, node lines in file order.Each row is a dict with
id,type,x,y,z,radiusandparent; seeparse_swc_data_line()for which lines count.- Parameters:
text (str)
- Return type:
tuple[list[str], list[dict]]
- swcstudio.core.swc_io.rewrite_swc_fields(text, types, radii=None)[source]#
textwith only the type (and radius) field of the given nodes rewritten.typesmaps a node id to its new type;radii, when given, maps a node id to its new radius (a number, or the exact text to write). Every other byte is kept: line endings, a byte order mark, comment lines where they stand, text after a#on a node line, fields after the seventh, and the spacing between fields. A field whose value does not change keeps its text (3.0stays3.0when the new type is 3). Lines that are not node lines (parse_swc_data_line()) are copied unchanged.Raises
ValueErrorwhen a node id appears on more than one node line, or when an id intypesorradiihas no node line, so a label is never written to the wrong line.- Parameters:
text (str)
types (Mapping[int, int])
radii (Mapping[int, float | str] | None)
- Return type:
str
- swcstudio.core.swc_io.decode_swc_bytes(data)[source]#
SWC bytes as text, every byte kept: invalid UTF-8 is carried through as surrogate escapes, so
encode_swc_text()gives the same bytes back.- Parameters:
data (bytes)
- Return type:
str
- swcstudio.core.swc_io.encode_swc_text(text)[source]#
The inverse of
decode_swc_bytes().- Parameters:
text (str)
- Return type:
bytes
- swcstudio.core.swc_io.is_swc_data_file(path, extensions=('.swc',))[source]#
True for a regular, visible file with an SWC extension.
Folder scans use this so they skip hidden files, in particular the
._name.swcAppleDouble files macOS writes next to every file it copies to a USB drive or network share: they hold Finder metadata, not SWC rows, and would otherwise fail as unreadable SWC files.- Parameters:
path (str | PathLike)
extensions (Iterable[str])
- Return type:
bool
Shared text report builders and file writers.
All interfaces (CLI + GUI) should use these helpers so generated log text stays consistent regardless of entry point.
Shared validation engine.
- class swcstudio.core.validation_engine.ValidationContext(swc_text)[source]#
Bases:
objectWhat the checks read.
arr(andids,parents, …) is a working copy with each connected soma group merged into one node, so a complex soma does not trip the other checks. Merging deletes the merged nodes’ IDs and re-roots each soma, so checks about the file’s own IDs, ordering and parent links readoriginal_arr(original_ids,original_parents) instead.- Parameters:
swc_text (str)
- swcstudio.core.validation_engine.consolidate_complex_somas_array(arr)[source]#
Collapse connected soma groups without renumbering surviving node IDs.
Each connected type-1 soma component is reduced to one anchor soma node at the group’s centroid, with the radius of the sphere of equal surface (see
_soma_group_radius). Non-anchor soma nodes are removed, and any child that pointed to a removed soma node is rewired to the surviving anchor ID. Surviving node IDs are preserved; no global reindexing is performed here.- Parameters:
arr (ndarray)
- Return type:
dict[str, Any]
Structured validation result models.
- class swcstudio.core.validation_results.PreCheckItem(key: 'str', label: 'str', source: 'str', severity: 'Severity', params: 'dict[str, Any]' = <factory>, enabled: 'bool' = True)[source]#
Bases:
object- Parameters:
key (str)
label (str)
source (str)
severity (str)
params (dict[str, Any])
enabled (bool)
- class swcstudio.core.validation_results.CheckResult(key: 'str', label: 'str', passed: 'bool', severity: 'Severity', message: 'str', failing_node_ids: 'list[int]' = <factory>, failing_section_ids: 'list[int]' = <factory>, metrics: 'dict[str, Any]' = <factory>, source: 'str' = 'native', params_used: 'dict[str, Any]' = <factory>, thresholds_used: 'dict[str, Any]' = <factory>, status: 'Status' = 'pass')[source]#
Bases:
object- Parameters:
key (str)
label (str)
passed (bool)
severity (str)
message (str)
failing_node_ids (list[int])
failing_section_ids (list[int])
metrics (dict[str, Any])
source (str)
params_used (dict[str, Any])
thresholds_used (dict[str, Any])
status (str)
- class swcstudio.core.validation_results.ValidationReport(profile: 'str', precheck: 'list[PreCheckItem]' = <factory>, results: 'list[CheckResult]' = <factory>)[source]#
Bases:
object- Parameters:
profile (str)
precheck (list[PreCheckItem])
results (list[CheckResult])
Validation check registry.
- class swcstudio.core.validation_registry.CheckDefinition(key: 'str', label: 'str', source: 'str', runner: 'ValidationCheckCallable')[source]#
Bases:
object- Parameters:
key (str)
label (str)
source (str)
runner (Callable[[Any, dict[str, Any]], Any])
- swcstudio.core.validation_registry.register_plugin_check(*, key, label, runner)[source]#
Register custom user-defined checks in the shared validation registry.
- Parameters:
key (str)
label (str)
runner (Callable[[Any, dict[str, Any]], Any])
- Return type:
None
Shared validation label/category catalog used by GUI and CLI.
Auto-typing engine for swcstudio.
This package is the single auto-labeling backend used everywhere in swcstudio.
It runs the SWC auto-labeler (swcstudio.core.labeler, a copy of the released
labeler’s code, with its model set labeler-<version>), which labels every
node of an SWC file as soma, axon, basal dendrite or apical dendrite:
Stage 0: structural checks (one connected cell, a soma, finite geometry).
Stage 1: the cell class, 3-class (axon, basal, apical) or 2-class (axon, dendrite), unless the user chooses it.
Stage 2: a gradient-boosted classifier labels each primary subtree.
Stage 3: topology rules, and for 3-class cells a learned correction of the branches near the soma.
Stage 4: a quality flag per cell class that predicts each cell’s per-cell F1, so a curator can review the riskiest cells first.
End users reach this code through the CLI (swcstudio auto-label,
swcstudio auto-typing) or the GUI’s Auto Label Editing panels and the Flag
Review window. The model folder is resolved by swcstudio.core.model_paths;
name one with --model-dir or the GUI selector, SWCSTUDIO_MODEL_DIR, or
model_dir in the auto-typing configuration, in that order of precedence.
- class swcstudio.core.auto_typing.BatchOptions(soma: 'bool' = True, axon: 'bool' = True, apic: 'bool' = True, basal: 'bool' = True, rad: 'bool' = False, zip_output: 'bool' = False, cell_type: 'str | None' = None, flag_enabled: 'bool' = True, flag_budget: 'float' = 0.1)[source]#
Bases:
object- Parameters:
soma (bool)
axon (bool)
apic (bool)
basal (bool)
rad (bool)
zip_output (bool)
cell_type (str | None)
flag_enabled (bool)
flag_budget (float)
- class swcstudio.core.auto_typing.BatchResult(folder: 'str', out_dir: 'str | None', zip_path: 'str | None', files_total: 'int', files_processed: 'int', files_failed: 'int', total_nodes: 'int', total_type_changes: 'int', total_radius_changes: 'int', failures: 'list[str]', per_file: 'list[str]', log_path: 'str | None', files_flagged: 'int' = 0, files_qc_failed: 'int' = 0, files_with_warnings: 'int' = 0, commits: 'list[dict[str, Any]] | None' = None, flag_records: 'list[dict[str, Any]] | None' = None, flag_review_path: 'str | None' = None, flag_budget: 'float | None' = None, model_record: 'dict[str, Any] | None' = None)[source]#
Bases:
object- Parameters:
folder (str)
out_dir (str | None)
zip_path (str | None)
files_total (int)
files_processed (int)
files_failed (int)
total_nodes (int)
total_type_changes (int)
total_radius_changes (int)
failures (list[str])
per_file (list[str])
log_path (str | None)
files_flagged (int)
files_qc_failed (int)
files_with_warnings (int)
commits (list[dict[str, Any]] | None)
flag_records (list[dict[str, Any]] | None)
flag_review_path (str | None)
flag_budget (float | None)
model_record (dict[str, Any] | None)
- class swcstudio.core.auto_typing.FileResult(input_file: 'str', output_file: 'str | None', nodes_total: 'int', type_changes: 'int', radius_changes: 'int', out_type_counts: 'dict[int, int]', cell_type: 'str | None', cell_type_source: 'str', stage1_confidence: 'float | None', qc_result: 'dict[str, Any] | None', flag_result: 'dict[str, Any] | None', failures: 'list[str]', change_details: 'list[str]', log_path: 'str | None', headers: 'list[str]', rows: 'list[dict[str, Any]]', types: 'list[int]', radii: 'list[float]', stage1_cell_type: 'str | None' = None, class_mismatch: 'bool' = False, notes: 'list[str]' = <factory>, labeler_version: 'str | None' = None, model_record: 'dict[str, Any] | None' = None, warnings: 'list[str]' = <factory>, unlabeled_nodes: 'int' = 0, input_type_counts: 'dict[int, int] | None' = None)[source]#
Bases:
object- Parameters:
input_file (str)
output_file (str | None)
nodes_total (int)
type_changes (int)
radius_changes (int)
out_type_counts (dict[int, int])
cell_type (str | None)
cell_type_source (str)
stage1_confidence (float | None)
qc_result (dict[str, Any] | None)
flag_result (dict[str, Any] | None)
failures (list[str])
change_details (list[str])
log_path (str | None)
headers (list[str])
rows (list[dict[str, Any]])
types (list[int])
radii (list[float])
stage1_cell_type (str | None)
class_mismatch (bool)
notes (list[str])
labeler_version (str | None)
model_record (dict[str, Any] | None)
warnings (list[str])
unlabeled_nodes (int)
input_type_counts (dict[int, int] | None)
- swcstudio.core.auto_typing.cell_class_name(cell_type)[source]#
User-facing name of a cell class:
3-class,2-classorauto.- Parameters:
cell_type (str | None)
- Return type:
str
- swcstudio.core.auto_typing.normalize_cell_class(raw)[source]#
The labeler’s name for a cell class, or
Nonefor automatic (Stage 1 decides).Accepts the user-facing names (
3-class,2-class,auto), the labeler’s names (pyramidal,interneuron) and the oldunknown.- Parameters:
raw (str | None)
- Return type:
str | None
- swcstudio.core.auto_typing.get_config()[source]#
Return the merged auto-typing config (defaults + persisted user overrides). Cached for fast repeat access in batch mode.
- Return type:
dict[str, Any]
- swcstudio.core.auto_typing.save_config(cfg)[source]#
Save user-edited auto-typing config to disk.
- Parameters:
cfg (dict[str, Any])
- Return type:
None
- swcstudio.core.auto_typing.is_available(*, model_dir=None, auto_download=False)[source]#
Return
(ok, reason)describing whether auto-labeling can run now.It needs a complete model folder (see
swcstudio.core.model_paths:model_dir, elseSWCSTUDIO_MODEL_DIR, elsemodel_dirin the auto-typing configuration, else the default search) and the packages the labeler imports: joblib, scikit-learn, XGBoost and pandas.This is a probe: it never downloads models unless
auto_downloadis set.- Parameters:
model_dir (str | PathLike | None)
auto_download (bool)
- Return type:
tuple[bool, str]
- swcstudio.core.auto_typing.resolve_models(model_dir=None, *, auto_download=True)[source]#
The model folder a run uses and where it came from; resolve it once per run.
model_diris the explicit argument; without itSWCSTUDIO_MODEL_DIR, thenmodel_dirin the auto-typing configuration, then the default search decide. RaisesFileNotFoundErrorwith the search report when no complete folder is found.- Parameters:
model_dir (str | PathLike | None)
auto_download (bool)
- Return type:
- swcstudio.core.auto_typing.backend_status(*, model_dir=None)[source]#
Structured status report, for
swcstudio models statusand the GUI.- Parameters:
model_dir (str | None)
- Return type:
dict[str, Any]
- swcstudio.core.auto_typing.labeled_text(text, rows, types, radii)[source]#
textwith the labeling result written in: the type field of each node whose type changed, and the radius field of each node whose radius changed.rowsare the node rows parsed fromtext(asFileResult.rows),typesandradiithe result for each. Every other byte oftextis kept (seeswc_io.rewrite_swc_fields()). RaisesValueErrorwhen the rows are not the node lines oftext.- Parameters:
text (str)
rows (list[dict[str, Any]])
types (list[int])
radii (list[float])
- Return type:
str
- swcstudio.core.auto_typing.run_file(file_path, opts, *, output_path=None, write_output=True, write_log=True, model_dir=None, models=None)[source]#
Run the auto-labeler on one SWC file.
modelsis a folder already resolved withresolve_models(); without it,model_dirand the usual search decide. The input file is not changed. Withwrite_output, a labeled copy is written: the input with only the relabeled type fields rewritten.- Parameters:
file_path (str)
opts (BatchOptions)
output_path (str | None)
write_output (bool)
write_log (bool)
model_dir (str | None)
models (ModelSelection | None)
- Return type:
- swcstudio.core.auto_typing.run_batch(folder, opts, *, model_dir=None, models=None, progress_callback=None)[source]#
Run the auto-labeler on every
.swcfile infolder.Labeled copies go to a new output folder created inside
folder(<folder>_batch_auto_typing_<timestamp>), together with a text report and the flag review (flag_review.json/.csv); the source files are not changed. Each copy is its source with only the relabeled type fields rewritten.progress_callback(index, total, current_filename)is invoked once per file before processing it.- Parameters:
folder (str)
opts (BatchOptions)
model_dir (str | None)
models (ModelSelection | None)
progress_callback (Callable[[int, int, str], None] | None)
- Return type:
- swcstudio.core.auto_typing.run_folder(folder, opts=None)[source]#
Convenience: run the engine on a folder with default options.
- Parameters:
folder (str)
opts (BatchOptions | None)
- Return type:
- swcstudio.core.auto_typing.apply_flag_budget(records, budget)[source]#
Decide
flaggedfor each labeled record of a batch, in place.Each cell class flags its riskiest
budgetshare, ranked by suspicion and rounded to the nearest cell, as the labeler’s flag was evaluated. A class with fewer than1 / budgetcells has no such share, so its cells are flagged by the flag’s fixed cut-off instead. A class mismatch is always flagged.- Parameters:
records (list[dict[str, Any]])
budget (float)
- Return type:
None
- swcstudio.core.auto_typing.write_flag_review(json_path, records, *, budget, folder, timestamp, labeler_version=None)[source]#
Write a batch’s flag review:
json_path(read by the Flag Review window) and a CSV copy beside it with the same name.labeler_versiondefaults to the labeler SWC-Studio runs; a review saved again keeps the one it was made with.- Parameters:
json_path (Path)
records (list[dict[str, Any]])
budget (float)
folder (str)
timestamp (str)
labeler_version (str | None)
- Return type:
Path
Public entry points for the auto-typing engine.
SWC-Studio labels with the SWC auto-labeler: swcstudio.core.labeler is a copy
of the released labeler’s code and labeler-<version> its model set, made by
scripts/sync_labeler.py. For each file:
Stage 0 checks that the file is one connected cell with a soma and finite geometry. Before that, SWC-Studio checks the file’s own node lines: every node id used once, and no node that is its own ancestor (a parent link to itself or a loop of parent links). A file that fails is not labeled.
Stage 1 decides the cell class: 3-class (axon, basal, apical) or 2-class (axon, dendrite). The user may choose the class instead; Stage 1 then still runs, and a cell whose chosen class differs from Stage 1’s prediction is labeled with the chosen class and flagged as a class mismatch.
Stages 2 and 3 label each primary subtree, apply the topology rules and, for 3-class cells, the proximal branch correction.
Stage 4 scores the quality flag: the cell’s predicted per-cell F1. A single file is flagged when that falls below the flag’s fixed cut-off. A batch flags the riskiest share of each cell class (
BatchOptions.flag_budget, 10% by default); a class with too few cells for that share uses the fixed cut-off.
Labeled output (a copy, or the file itself for the in-place paths of the CLI
and GUI) is the input text with only the type field of each relabeled node line
rewritten (labeled_text); every other byte is kept.
Public surface:
run_file(path, opts, ...)returnsFileResultrun_batch(folder, opts, ...)returnsBatchResultresolve_models(model_dir)returns the model folder and its sourceis_available()returns(bool, reason)backend_status()returns a diagnostic dict
- swcstudio.core.auto_typing.runner.is_available(*, model_dir=None, auto_download=False)[source]#
Return
(ok, reason)describing whether auto-labeling can run now.It needs a complete model folder (see
swcstudio.core.model_paths:model_dir, elseSWCSTUDIO_MODEL_DIR, elsemodel_dirin the auto-typing configuration, else the default search) and the packages the labeler imports: joblib, scikit-learn, XGBoost and pandas.This is a probe: it never downloads models unless
auto_downloadis set.- Parameters:
model_dir (str | PathLike | None)
auto_download (bool)
- Return type:
tuple[bool, str]
- swcstudio.core.auto_typing.runner.resolve_models(model_dir=None, *, auto_download=True)[source]#
The model folder a run uses and where it came from; resolve it once per run.
model_diris the explicit argument; without itSWCSTUDIO_MODEL_DIR, thenmodel_dirin the auto-typing configuration, then the default search decide. RaisesFileNotFoundErrorwith the search report when no complete folder is found.- Parameters:
model_dir (str | PathLike | None)
auto_download (bool)
- Return type:
- swcstudio.core.auto_typing.runner.backend_status(*, model_dir=None)[source]#
Structured status report, for
swcstudio models statusand the GUI.- Parameters:
model_dir (str | None)
- Return type:
dict[str, Any]
- swcstudio.core.auto_typing.runner.run_file(file_path, opts, *, output_path=None, write_output=True, write_log=True, model_dir=None, models=None)[source]#
Run the auto-labeler on one SWC file.
modelsis a folder already resolved withresolve_models(); without it,model_dirand the usual search decide. The input file is not changed. Withwrite_output, a labeled copy is written: the input with only the relabeled type fields rewritten.- Parameters:
file_path (str)
opts (BatchOptions)
output_path (str | None)
write_output (bool)
write_log (bool)
model_dir (str | None)
models (ModelSelection | None)
- Return type:
- swcstudio.core.auto_typing.runner.run_batch(folder, opts, *, model_dir=None, models=None, progress_callback=None)[source]#
Run the auto-labeler on every
.swcfile infolder.Labeled copies go to a new output folder created inside
folder(<folder>_batch_auto_typing_<timestamp>), together with a text report and the flag review (flag_review.json/.csv); the source files are not changed. Each copy is its source with only the relabeled type fields rewritten.progress_callback(index, total, current_filename)is invoked once per file before processing it.- Parameters:
folder (str)
opts (BatchOptions)
model_dir (str | None)
models (ModelSelection | None)
progress_callback (Callable[[int, int, str], None] | None)
- Return type:
- swcstudio.core.auto_typing.runner.labeled_text(text, rows, types, radii)[source]#
textwith the labeling result written in: the type field of each node whose type changed, and the radius field of each node whose radius changed.rowsare the node rows parsed fromtext(asFileResult.rows),typesandradiithe result for each. Every other byte oftextis kept (seeswc_io.rewrite_swc_fields()). RaisesValueErrorwhen the rows are not the node lines oftext.- Parameters:
text (str)
rows (list[dict[str, Any]])
types (list[int])
radii (list[float])
- Return type:
str
- swcstudio.core.auto_typing.runner.read_swc_text(path)[source]#
The file’s text with every byte kept (see
swc_io.decode_swc_bytes()).- Parameters:
path (str | PathLike)
- Return type:
str
- swcstudio.core.auto_typing.runner.structural_violations(rows)[source]#
What is wrong with the node lines themselves, before the labeler reads them.
Labels are matched back to the file by node id, and the labeler’s own checks do not see a node detached in a loop of parent links. So a node id used on more than one line, a node that is its own parent, and parent links that form a loop are rejected here. Returns the reasons; empty when the rows pass.
- Parameters:
rows (list[dict[str, Any]])
- Return type:
list[str]
- swcstudio.core.auto_typing.runner.apply_flag_budget(records, budget)[source]#
Decide
flaggedfor each labeled record of a batch, in place.Each cell class flags its riskiest
budgetshare, ranked by suspicion and rounded to the nearest cell, as the labeler’s flag was evaluated. A class with fewer than1 / budgetcells has no such share, so its cells are flagged by the flag’s fixed cut-off instead. A class mismatch is always flagged.- Parameters:
records (list[dict[str, Any]])
budget (float)
- Return type:
None
- swcstudio.core.auto_typing.runner.flag_record(path, out_path, labeled, nodes_total, type_changes, qc_reasons=None, error=None, out_type_counts=None)[source]#
One row of a batch’s flag review.
labeledis aFileResult(or the runner’s internal equivalent) for a labeled file, orNonefor a file that was not labeled, withqc_reasonsorerrorsaying why.out_type_counts(node count per output type) defaults tolabeled.out_type_countsand feedswarnings.- Parameters:
path (Path)
out_path (Path | None)
labeled (Any | None)
nodes_total (int)
type_changes (int)
qc_reasons (list[str] | None)
error (str | None)
out_type_counts (dict[int, int] | None)
- Return type:
dict[str, Any]
- swcstudio.core.auto_typing.runner.label_warnings(cell_type, out_type_counts, input_type_counts=None)[source]#
The compartments a labeled cell of its class should have but has no node of.
The labeler gives each primary subtree one label and does not force an axon, so a cell can come back without one. Saying so in the batch results spares reviewers from finding it by eye. When the input was labeled (
input_type_countshas an axon or dendrite node) and has no node of that compartment either, the warning says so: the tracing may simply not include it.- Parameters:
cell_type (str | None)
out_type_counts (dict[int, int] | None)
input_type_counts (dict[int, int] | None)
- Return type:
list[str]
- swcstudio.core.auto_typing.runner.unlabeled_warning(count)[source]#
The warning for nodes the labeler left unlabeled, or nothing.
- Parameters:
count (int)
- Return type:
list[str]
- swcstudio.core.auto_typing.runner.batch_flag_text(record, *, flag_enabled, flag_result=None)[source]#
The flag part of a batch’s per-file line, from the record’s final decision.
Call it after
apply_flag_budget(), which decidesflagged.- Parameters:
record (dict[str, Any])
flag_enabled (bool)
flag_result (dict[str, Any] | None)
- Return type:
str
- swcstudio.core.auto_typing.runner.batch_file_line(record, *, radius_changes, out_type_counts, flag_enabled, flag_result=None)[source]#
One labeled file’s line in a batch report, after the flag budget is applied.
- Parameters:
record (dict[str, Any])
radius_changes (int)
out_type_counts (dict[int, int] | None)
flag_enabled (bool)
flag_result (dict[str, Any] | None)
- Return type:
str
- swcstudio.core.auto_typing.runner.batch_report_text(*, folder, files_total, files_processed, failed_files, files_with_warnings, per_file, files_flagged=None, flag_review_path=None, model_record=None, totals=None, out_dir=None, zip_path=None, change_details=None)[source]#
The text report of an auto-labeling batch; the GUI, the CLI and
run_batch()write the same one.failed_filesare(file, error).- Parameters:
folder (str | PathLike)
files_total (int)
files_processed (int)
failed_files (list[tuple[str, str]])
files_with_warnings (int)
per_file (list[str])
files_flagged (int | None)
flag_review_path (str | None)
model_record (dict[str, Any] | None)
totals (dict[str, int] | None)
out_dir (str | None)
zip_path (str | None)
change_details (list[str] | None)
- Return type:
str
- swcstudio.core.auto_typing.runner.write_flag_review(json_path, records, *, budget, folder, timestamp, labeler_version=None)[source]#
Write a batch’s flag review:
json_path(read by the Flag Review window) and a CSV copy beside it with the same name.labeler_versiondefaults to the labeler SWC-Studio runs; a review saved again keeps the one it was made with.- Parameters:
json_path (Path)
records (list[dict[str, Any]])
budget (float)
folder (str)
timestamp (str)
labeler_version (str | None)
- Return type:
Path
Public dataclasses for the auto-typing engine.
These describe the user-facing options (which neurite types to assign, the
cell class, the quality flag, radius cleanup, zipping the batch output) and the
result shapes returned by run_file() / run_batch().
- class swcstudio.core.auto_typing.types.BatchOptions(soma: 'bool' = True, axon: 'bool' = True, apic: 'bool' = True, basal: 'bool' = True, rad: 'bool' = False, zip_output: 'bool' = False, cell_type: 'str | None' = None, flag_enabled: 'bool' = True, flag_budget: 'float' = 0.1)[source]#
Bases:
object- Parameters:
soma (bool)
axon (bool)
apic (bool)
basal (bool)
rad (bool)
zip_output (bool)
cell_type (str | None)
flag_enabled (bool)
flag_budget (float)
- class swcstudio.core.auto_typing.types.BatchResult(folder: 'str', out_dir: 'str | None', zip_path: 'str | None', files_total: 'int', files_processed: 'int', files_failed: 'int', total_nodes: 'int', total_type_changes: 'int', total_radius_changes: 'int', failures: 'list[str]', per_file: 'list[str]', log_path: 'str | None', files_flagged: 'int' = 0, files_qc_failed: 'int' = 0, files_with_warnings: 'int' = 0, commits: 'list[dict[str, Any]] | None' = None, flag_records: 'list[dict[str, Any]] | None' = None, flag_review_path: 'str | None' = None, flag_budget: 'float | None' = None, model_record: 'dict[str, Any] | None' = None)[source]#
Bases:
object- Parameters:
folder (str)
out_dir (str | None)
zip_path (str | None)
files_total (int)
files_processed (int)
files_failed (int)
total_nodes (int)
total_type_changes (int)
total_radius_changes (int)
failures (list[str])
per_file (list[str])
log_path (str | None)
files_flagged (int)
files_qc_failed (int)
files_with_warnings (int)
commits (list[dict[str, Any]] | None)
flag_records (list[dict[str, Any]] | None)
flag_review_path (str | None)
flag_budget (float | None)
model_record (dict[str, Any] | None)
- class swcstudio.core.auto_typing.types.FileResult(input_file: 'str', output_file: 'str | None', nodes_total: 'int', type_changes: 'int', radius_changes: 'int', out_type_counts: 'dict[int, int]', cell_type: 'str | None', cell_type_source: 'str', stage1_confidence: 'float | None', qc_result: 'dict[str, Any] | None', flag_result: 'dict[str, Any] | None', failures: 'list[str]', change_details: 'list[str]', log_path: 'str | None', headers: 'list[str]', rows: 'list[dict[str, Any]]', types: 'list[int]', radii: 'list[float]', stage1_cell_type: 'str | None' = None, class_mismatch: 'bool' = False, notes: 'list[str]' = <factory>, labeler_version: 'str | None' = None, model_record: 'dict[str, Any] | None' = None, warnings: 'list[str]' = <factory>, unlabeled_nodes: 'int' = 0, input_type_counts: 'dict[int, int] | None' = None)[source]#
Bases:
object- Parameters:
input_file (str)
output_file (str | None)
nodes_total (int)
type_changes (int)
radius_changes (int)
out_type_counts (dict[int, int])
cell_type (str | None)
cell_type_source (str)
stage1_confidence (float | None)
qc_result (dict[str, Any] | None)
flag_result (dict[str, Any] | None)
failures (list[str])
change_details (list[str])
log_path (str | None)
headers (list[str])
rows (list[dict[str, Any]])
types (list[int])
radii (list[float])
stage1_cell_type (str | None)
class_mismatch (bool)
notes (list[str])
labeler_version (str | None)
model_record (dict[str, Any] | None)
warnings (list[str])
unlabeled_nodes (int)
input_type_counts (dict[int, int] | None)
Persisted user-facing configuration for the auto-typing feature.
The runtime knobs end users edit are a model directory override, the cell class (automatic, 3-class or 2-class), whether the quality flag runs, and the share of each cell class a batch flags for review. They live in the same JSON config the Batch Processing tool already persists, so the GUI / CLI read and write a single file.
- swcstudio.core.auto_typing.config.get_config()[source]#
Return the merged auto-typing config (defaults + persisted user overrides). Cached for fast repeat access in batch mode.
- Return type:
dict[str, Any]
- swcstudio.core.auto_typing.config.save_config(cfg)[source]#
Save user-edited auto-typing config to disk.
- Parameters:
cfg (dict[str, Any])
- Return type:
None
- swcstudio.core.auto_typing.config.reset_cache()[source]#
Drop the in-memory config cache so the next
get_configcall reloads from disk. Used by tests.- Return type:
None
The two cell classes the labeler knows, as SWC-Studio names them.
The labeler has one model set per cell class. SWC-Studio names a class by the neurite labels it assigns rather than by a cell type, because the class fits any cell with that compartment layout:
3-class – axon, basal dendrite and apical dendrite. The labeler calls it
pyramidal, the cells its models were trained on.2-class – axon and dendrite. The labeler calls it
interneuron.
Internally, in saved settings and in result records, the labeler’s names are kept; these helpers translate at the user-facing edges.
- swcstudio.core.auto_typing.cell_class.normalize_cell_class(raw)[source]#
The labeler’s name for a cell class, or
Nonefor automatic (Stage 1 decides).Accepts the user-facing names (
3-class,2-class,auto), the labeler’s names (pyramidal,interneuron) and the oldunknown.- Parameters:
raw (str | None)
- Return type:
str | None
- swcstudio.core.auto_typing.cell_class.cell_class_name(cell_type)[source]#
User-facing name of a cell class:
3-class,2-classorauto.- Parameters:
cell_type (str | None)
- Return type:
str
Train the auto-labeler on your own labeled SWC files.
This runs the labeler’s own trainer (swcstudio.core.labeler.train_pipeline,
the same code that built the shipped models) on your corpus and writes a model
folder SWC-Studio can label with. Point swcstudio at the folder with
--model-dir, the SWCSTUDIO_MODEL_DIR environment variable, or the GUI’s
model selector.
Expected input dataset layout:
<data-dir>/
pyramidal/ 3-class cells (axon, basal, apical)
<files>.swc
interneuron/ 2-class cells (axon, dendrite)
<files>.swc
Each SWC’s type column (soma=1, axon=2, basal=3, apical=4) is the per-node ground truth. The trainer holds out a deterministic 20% of the files (by file name and seed) and fits, in order:
Stage 1, the cell-class classifier.
Stage 2, the subtree classifier for each cell class.
Stage 3, the proximal branch correction (3-class cells).
Stage 4, the quality flag for each cell class, fitted on the held-out files, which it needs; skip it for a labeler without a flag.
The output folder holds cell_type_classifier.pkl, branch_classifier.pkl,
branch_correction.joblib, flag_model.joblib, the split it used
(eval_split.json) and a train_manifest.json with counts and timings.
A full run on the labeler’s own corpus (about 9,500 training cells) takes about
45 minutes; a corpus of a few hundred cells takes minutes.
Usage from Python:
from swcstudio.core.auto_typing_train import train_user_models
train_user_models(data_dir="path/to/labeled/dataset", output_dir="path/to/models")
Usage from the CLI:
swcstudio train auto-typing --data-dir path/to/dataset --output-dir path/to/models
- swcstudio.core.auto_typing_train.train_user_models(data_dir, output_dir, *, seed=None, device='cpu', skip=(), test_size=0.2)[source]#
Train the labeler on
data_dirand write the model folderoutput_dir.A class folder holding a hidden
*.swcfile or a folder named*.swcis refused with aValueErrorthat lists them.seedfixes the held-out split (random when omitted; recorded either way).deviceis where Stages 1 and 2 are fitted:cpu, orcudawith an NVIDIA GPU and a CUDA build of XGBoost.skipnames stages to leave out, fromstage1,stage2,correctionandflag.- Parameters:
data_dir (str | Path)
output_dir (str | Path)
seed (int | None)
device (str)
skip (Iterable[str])
test_size (float)
- Return type:
- class swcstudio.core.auto_typing_train.TrainingResult(output_dir: 'str', seed: 'int', model_paths: 'dict[str, str | None]', counts: 'dict[str, Any]', timings_min: 'dict[str, float]', skipped: 'list[str]')[source]#
Bases:
object- Parameters:
output_dir (str)
seed (int)
model_paths (dict[str, str | None])
counts (dict[str, Any])
timings_min (dict[str, float])
skipped (list[str])
Resolve where the auto-labeler’s model files live on disk.
SWC-Studio labels with the SWC auto-labeler (swcstudio.core.labeler).
Its model set is four files that always travel together in one folder:
cell_type_classifier.pkl– Stage 1, which cell class a file is (3-class: axon, basal and apical; 2-class: axon and dendrite)branch_classifier.pkl– Stage 2, the subtree classifierbranch_correction.joblib– Stage 3, the proximal branch correctionflag_model.joblib– Stage 4, one quality flag per cell class
The first three are required. The flag is optional: a model set without it labels cells but scores no flag. Files are never mixed across folders, because each model in a set was trained against the others.
A model folder is either named for the labeler version (labeler-<version>,
the way SWC-Studio ships and updates its models) inside one of the search
directories, or is a search directory itself, such as a model set you trained.
A folder you name is the only one searched: if it is incomplete, auto-labeling reports what is missing rather than quietly using other models. The first of these that is set names the folder:
the explicit argument (
--model-dir, the GUI selector,model_dir=);the
SWCSTUDIO_MODEL_DIRenvironment variable;model_dirin the auto-typing configuration file (swcstudio/tools/batch_processing/configs/auto_typing.json).
Without a named folder the search order is (the first complete folder wins):
The user data directory, where model updates are installed:
Windows:
%APPDATA%\swcstudio\modelsmacOS:
~/Library/Application Support/swcstudio/modelsLinux:
~/.local/share/swcstudio/models
The desktop runtime’s model directory, supplied by the bootstrap through
SWCSTUDIO_BUNDLED_MODEL_DIR.The directory inside the installed package (
swcstudio/data/models).
Searching never creates or writes anything; an unreadable user data directory is skipped.
Public API:
labeler_info()– version, source commit and model checksums of the labelerselect_model_dir(override=None)– the model folder and where it came fromresolve_model_dir(override=None)– the model folder, orNoneresolve_model_path(name, override=None)– one file of that folder, orNoneavailable_models(override=None)–dict[name -> Path | None]diagnostic_search_report(override=None)– where the resolver lookedmodel_record(folder, source)– the provenance record of a model folderrecorded_model_dir(path)– a folder as history records it (home as~)
- swcstudio.core.model_paths.labeler_info()[source]#
The labeler SWC-Studio runs:
LABELER.jsonwritten byscripts/sync_labeler.py.- Return type:
dict[str, Any]
- swcstudio.core.model_paths.labeler_models_dirname()[source]#
Folder name of the shipped model set, e.g.
labeler-1.0.1.- Return type:
str
- swcstudio.core.model_paths.user_model_dir()[source]#
User data directory for swcstudio models.
Only the path: searching for models never creates it. Model updates create it when they install (
swcstudio.core.updater).- Return type:
Path
- swcstudio.core.model_paths.bundled_model_dir()[source]#
Directory shipped inside the installed swcstudio package.
- Return type:
Path
- swcstudio.core.model_paths.recorded_model_dir(model_dir)[source]#
A model folder as history records it: the home directory written as
~.The history travels with the SWC, so a path under the home folder would carry the username. Model lookup expands
~again, so the commandhistory reproduceprints still finds the folder.- Parameters:
model_dir (str | PathLike | None)
- Return type:
str | None
- swcstudio.core.model_paths.named_model_dir(override=None)[source]#
The folder the user named and how, or
Nonefor the default search.In order of precedence:
override("argument"),SWCSTUDIO_MODEL_DIR("env"),model_dirin the auto-typing configuration ("config").- Parameters:
override (str | PathLike | None)
- Return type:
tuple[Path, str] | None
- swcstudio.core.model_paths.search_dirs(override=None)[source]#
Ordered list of directories that may hold a model set.
A named folder (see
named_model_dir()) is searched alone.- Parameters:
override (str | PathLike | None)
- Return type:
list[Path]
- class swcstudio.core.model_paths.ModelSelection(folder, source)[source]#
Bases:
objectA complete model folder and where it came from (one of
MODEL_SOURCES).- Parameters:
folder (Path)
source (str)
- swcstudio.core.model_paths.select_model_dir(override=None, *, auto_download=False)[source]#
The first complete model folder in search order with its source, or
None.If none is found, no folder is named and
auto_downloadis set, the model set of the latest release is fetched into the user data directory (seeswcstudio.core.updater) and the search runs again. Installed copies carry the model set, so this is a repair path, not a first-run requirement. Status probes leaveauto_downloadoff.- Parameters:
override (str | PathLike | None)
auto_download (bool)
- Return type:
ModelSelection | None
- swcstudio.core.model_paths.resolve_model_dir(override=None, *, auto_download=True)[source]#
The first complete model folder in search order, or
None.See
select_model_dir(); this returns only the folder.- Parameters:
override (str | PathLike | None)
auto_download (bool)
- Return type:
Path | None
- swcstudio.core.model_paths.model_file_sha256(path)[source]#
SHA-256 of one model file, cached by path, size and modification time.
- Parameters:
path (str | PathLike)
- Return type:
str
- swcstudio.core.model_paths.model_record(folder, source)[source]#
The provenance record of the model folder an auto-label run used.
model_dir: the folder, home directory written as~(recorded_model_dir())model_source: where it came from, one ofMODEL_SOURCESmodel_version: the labeler versionmodel_files:{file name: SHA-256}of the set’s model files in the folder (the optional flag model only when present)model_sha: SHA-256 of the lines"<file name> <sha256>\n"ofmodel_files, sorted by file name: one fingerprint for the set
- Parameters:
folder (str | PathLike)
source (str)
- Return type:
dict[str, Any]
- swcstudio.core.model_paths.resolve_model_path(name_or_filename, *, override=None, auto_download=True)[source]#
One file of the resolved model folder, by short name or file name.
- Parameters:
name_or_filename (str)
override (str | PathLike | None)
auto_download (bool)
- Return type:
Path | None
- swcstudio.core.model_paths.available_models(override=None)[source]#
{short_name: Path | None}for every model file of the resolved folder.- Parameters:
override (str | PathLike | None)
- Return type:
dict[str, Path | None]
- swcstudio.core.model_paths.diagnostic_search_report(override=None)[source]#
Human-readable description of where the resolver looked.
- Parameters:
override (str | PathLike | None)
- Return type:
str
The auto-typing engine runs the SWC auto-labeler, whose code is copied
into swcstudio.core.labeler by scripts/sync_labeler.py. That
package is the labeler’s own code and is not documented here; see the
labeler repository (LazziLab/swc-autolabeler).
SWC-Studio reaches it only through swcstudio.core.auto_typing.
Tool Feature Modules#
Batch Processing#
Batch validation feature for Batch Processing.
SWC splitter feature for Batch Processing.
- swcstudio.tools.batch_processing.features.swc_splitter.refuse_unsafe_split(swc_text)[source]#
Raise ValueError for a file a split would silently corrupt.
With duplicate node IDs a parent ID could mean either row, and nodes on a parent cycle reach no soma, so the split would drop them. Returns the file’s row count, which the trees must add up to.
- Parameters:
swc_text (str)
- Return type:
int
Auto-typing feature for the Batch Processing tool.
Thin wrapper around swcstudio.core.auto_typing, which runs the SWC
auto-labeler. This module registers the feature with the plugin system and
carries the model directory, cell class and quality-flag settings the GUI / CLI
need. A batch labels every file of a folder in place, each with its own history,
then ranks the labeled cells for review: each cell class flags its riskiest
share (flag_budget). The ranking is saved inside the folder as
<folder>_flag_review_<timestamp>.json (and .csv) for the Flag Review
window, and a text report as <folder>_batch_auto_typing_<timestamp>.txt.
The GUI batch and swcstudio auto-typing both run run_folder().
- class swcstudio.tools.batch_processing.features.auto_typing.BatchOptions(soma: 'bool' = True, axon: 'bool' = True, apic: 'bool' = True, basal: 'bool' = True, rad: 'bool' = False, zip_output: 'bool' = False, cell_type: 'str | None' = None, flag_enabled: 'bool' = True, flag_budget: 'float' = 0.1)[source]#
Bases:
object- Parameters:
soma (bool)
axon (bool)
apic (bool)
basal (bool)
rad (bool)
zip_output (bool)
cell_type (str | None)
flag_enabled (bool)
flag_budget (float)
- swcstudio.tools.batch_processing.features.auto_typing.run_folder(folder, *, options=None, config_overrides=None, progress_callback=None, message=None)[source]#
Label every SWC file of
folderin place, each with its own history.config_overrides["model_dir"]is the explicit model folder for this run; without itSWCSTUDIO_MODEL_DIR, thenmodel_dirin the saved configuration, then the default search decide.messageis the history message of each commit.- Parameters:
folder (str)
options (BatchOptions | None)
config_overrides (dict | None)
progress_callback (Callable[[int, int, str], None] | None)
message (str | None)
Radii cleaning feature for Batch Processing.
This module is the shared backend used by: - Batch GUI radii cleaning tab - Validation GUI radii cleaning tab - CLI batch/validation radii-clean commands
Validation#
Structured validation runner feature.
Auto-fix validation feature.
This feature runs the shared validation backend and returns the sanitized SWC content that can be written back to disk.
Single-file auto-typing for the Validation tool.
Thin wrapper around swcstudio.core.auto_typing, which runs the SWC
auto-labeler. The runtime knobs are the model directory override, the cell
class (automatic, 3-class or 2-class) and whether the quality flag runs.
- class swcstudio.tools.validation.features.auto_typing.BatchOptions(soma: 'bool' = True, axon: 'bool' = True, apic: 'bool' = True, basal: 'bool' = True, rad: 'bool' = False, zip_output: 'bool' = False, cell_type: 'str | None' = None, flag_enabled: 'bool' = True, flag_budget: 'float' = 0.1)[source]#
Bases:
object- Parameters:
soma (bool)
axon (bool)
apic (bool)
basal (bool)
rad (bool)
zip_output (bool)
cell_type (str | None)
flag_enabled (bool)
flag_budget (float)
- swcstudio.tools.validation.features.auto_typing.run_file(file_path, *, options=None, config_overrides=None, output_path=None, write_output=True, write_log=True, models=None)[source]#
Run auto-typing on a single file using the configured engine.
The model folder is
modelswhen given (resolved once for a batch); otherwiseconfig_overrides["model_dir"]is the explicit choice, thenSWCSTUDIO_MODEL_DIR, thenmodel_dirin the saved configuration, then the default search. The result carriesmodel_record.- Parameters:
file_path (str)
options (BatchOptions | None)
config_overrides (dict | None)
output_path (str | None)
write_output (bool)
write_log (bool)
models (ModelSelection | None)
- swcstudio.tools.validation.features.auto_typing.auto_label_file(file_path, *, options=None, config_overrides=None, output_path=None, write_output=True, write_log=False, models=None)[source]#
Label one file and return the labeled file’s bytes (
"bytes").The bytes are the input file with only the type field of each relabeled node line rewritten (and the radius field of a node whose radius a radius option changed): comments stay where they are, inline comments, columns after the seventh, spacing, line endings and a byte order mark are kept, and lines that are not node lines are copied unchanged. The in-place writers (CLI, GUI batch) commit these bytes.
- Parameters:
file_path (str)
options (BatchOptions | None)
config_overrides (dict | None)
output_path (str | None)
write_output (bool)
write_log (bool)
models (ModelSelection | None)
- Return type:
dict[str, Any]
Validation radii-cleaning feature.
This is a thin wrapper over the shared Batch Processing radii-clean backend so GUI/CLI/Validation all use exactly the same cleaning implementation.
Visualization#
Mesh editing feature backend.
This module provides a reusable backend payload that both GUI and CLI can use for mesh-related operations without duplicating parsing logic.
Morphology Editing#
Dendrogram editing backend utilities.
Provides data-level operations used by interactive dendrogram editors.
Smart decimation wrapper for morphology editing.
Plugin System Internals#
Plugin contract models for swcstudio.
This module defines a minimal, versioned contract for external plugins.
Provenance requirement (PROVENANCE_SPEC.md M13)#
Any plugin that mutates SWC bytes MUST do so inside a
swcstudio.core.provenance.tracked_op() context (or
tracked_session() for multi-op interactive flows). Direct file
writes bypass the provenance chain and are unsupported.
The canonical pattern:
from swcstudio.core.provenance import tracked_op
def my_plugin_op(swc_path, *, my_param):
with tracked_op(swc_path, kind="plugin_op",
params={"plugin": "my-plugin", "my_param": my_param},
message="my plugin description") as op:
new_bytes = mutate(op.input_bytes, my_param)
op.set_output(new_bytes)
return op.result
The plugin_op op kind is reserved for this purpose and accepts
arbitrary params. Plugins that need a richer typed op kind should
request an addition to OpKind in a future v1.x bump (additive
only per spec §17).
- class swcstudio.plugins.contracts.PluginManifest(plugin_id, name, version, api_version='1', description='', author='', capabilities=(), entrypoint='')[source]#
Bases:
objectStructured plugin metadata required by the swcstudio plugin loader.
- Parameters:
plugin_id (str)
name (str)
version (str)
api_version (str)
description (str)
author (str)
capabilities (tuple[str, ...])
entrypoint (str)
- swcstudio.plugins.contracts.parse_plugin_manifest(raw)[source]#
Validate and normalize a plugin manifest dictionary.
- Parameters:
raw (dict[str, Any])
- Return type:
- swcstudio.plugins.contracts.plugin_manifest_to_dict(manifest)[source]#
Serialize a PluginManifest into JSON-friendly dictionary.
- Parameters:
manifest (PluginManifest)
- Return type:
dict[str, Any]
Dynamic plugin loader for swcstudio.
- class swcstudio.plugins.loader.PluginRegistrar(plugin_id)[source]#
Bases:
objectRegistrar object passed to external plugins during registration.
- Parameters:
plugin_id (str)
- swcstudio.plugins.loader.load_plugin_module(module_name, *, force_reload=False)[source]#
Load one plugin module and register its methods.
Expected plugin contract: 1) PLUGIN_MANIFEST dict (or get_plugin_manifest()) 2) register_plugin(registrar) function OR PLUGIN_METHODS attribute
- Parameters:
module_name (str)
force_reload (bool)
- Return type:
dict[str, Any]
- swcstudio.plugins.loader.load_plugins(modules)[source]#
Load multiple plugin modules and return per-module results.
- Parameters:
modules (Iterable[str])
- Return type:
list[dict[str, Any]]
- swcstudio.plugins.loader.autoload_plugins_from_environment(env_var='SWCSTUDIO_PLUGINS')[source]#
Autoload plugin modules from comma-separated environment variable.
- Parameters:
env_var (str)
- Return type:
list[dict[str, Any]]
Plugin registry for swcstudio.
Supports: 1) Legacy flat keys (register(“name”, func) / get(“name”)) 2) Feature method keys (register_method(“tool.feature”, “method_name”, func)) 3) Plugin-aware registration with versioned manifest metadata
The feature-based API is preferred for modular override of algorithms used by CLI and GUI layers.
- swcstudio.plugins.registry.register(name, func)[source]#
Register a callable under a flat legacy key.
- Parameters:
name (str)
func (Callable)
- Return type:
None
- swcstudio.plugins.registry.get(name)[source]#
Retrieve a flat legacy callable or None.
- Parameters:
name (str)
- Return type:
Callable | None
- swcstudio.plugins.registry.clear()[source]#
Clear all registry content (legacy + feature methods).
- Return type:
None
- swcstudio.plugins.registry.register_builtin_method(feature_key, method_name, func)[source]#
Register an internal builtin method for a feature.
- Parameters:
feature_key (str)
method_name (str)
func (Callable)
- Return type:
None
- swcstudio.plugins.registry.register_plugin_manifest(manifest)[source]#
Register and validate a plugin manifest.
- Parameters:
manifest (PluginManifest | dict[str, Any])
- Return type:
- swcstudio.plugins.registry.unregister_plugin(plugin_id)[source]#
Remove plugin manifest and all methods owned by this plugin.
- Parameters:
plugin_id (str)
- Return type:
None
- swcstudio.plugins.registry.register_plugin_method(plugin_id, feature_key, method_name, func)[source]#
Register a feature method owned by a named plugin.
- Parameters:
plugin_id (str)
feature_key (str)
method_name (str)
func (Callable)
- Return type:
None
- swcstudio.plugins.registry.register_method(feature_key, method_name, func, *, plugin_id=None)[source]#
Register a user/plugin method that overrides builtins with same name.
- Parameters:
feature_key (str)
method_name (str)
func (Callable)
plugin_id (str | None)
- Return type:
None
- swcstudio.plugins.registry.resolve_method(feature_key, method_name, fallback=None)[source]#
Resolve method by priority: plugin override -> builtin -> fallback.
- Parameters:
feature_key (str)
method_name (str)
fallback (Callable | None)
- Return type:
Callable
- swcstudio.plugins.registry.list_feature_methods(feature_key)[source]#
Return plugin + builtin method names for a feature.
- Parameters:
feature_key (str)
- Return type:
dict
- swcstudio.plugins.registry.list_all_feature_methods()[source]#
Return all feature method registrations.
- Return type:
dict