Skip to content

Add atlas annotation rule for vessel nodes parquet#170

Open
Copilot wants to merge 1 commit into
mainfrom
copilot/add-atlas-annotation-rule
Open

Add atlas annotation rule for vessel nodes parquet#170
Copilot wants to merge 1 commit into
mainfrom
copilot/add-atlas-annotation-rule

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 21, 2026

Vessel nodes lacked atlas region labels, making it impossible to aggregate vessel metrics by brain region. This adds a Snakemake rule and script to annotate vessel node parquets with atlas ROI labels using ZarrNiiAtlas.label_region_properties.

Changes

  • vessels.smk — new rule map_atlas_to_vessel_nodes

    • Inputs: nodes.parquet (from vessel_graph_to_nodes_edges), subject-space atlas dseg (datatype="parc", from_="{template}"), and label TSV
    • Outputs: atlas-annotated nodes.parquet and nodecounts.tsv, with seg and from_ wildcards appended to the filename — mirroring the wildcard strategy of map_regionprops_to_atlas_rois
    • Uses physical coordinate columns ["x", "y", "z"] from the nodes schema
  • scripts/map_atlas_to_vessel_nodes.py — new script following the same pattern as map_atlas_to_regionprops.py:

    nodes = pd.read_parquet(snakemake.input.nodes_parquet).to_dict(orient="list")
    atlas = ZarrNiiAtlas.from_files(snakemake.input.dseg, snakemake.input.label_tsv)
    df_nodes, df_counts = atlas.label_region_properties(
        nodes,
        coord_column_names=snakemake.params.coord_column_names,
        include_names=True,
    )
    df_nodes.to_parquet(snakemake.output.nodes_parquet, index=False)
    df_counts.to_csv(snakemake.output.counts_tsv, sep="\t", index=False)

@akhanf akhanf marked this pull request as ready for review May 21, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants