Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 15, 2025

Extends group analysis to generate volumetric maps of averaged segmentation metrics (fieldfrac, density, count, volume) per contrast group, analogous to existing voxel-wise count maps from parquet tables.

Changes

  • New script concat_subj_segstats_contrast.py: Concatenates subject-level segstats.tsv files filtered by contrast, computes region-wise group averages

  • New rule concat_subj_segstats_contrast: Collects mergedsegstats.tsv across subjects, filters by contrast column/value, outputs averaged TSV per region

  • New rule map_groupavg_segstats_to_template_nii: Maps averaged TSV to template NIfTI using existing map_tsv_dseg_to_nii.py

  • Updated all_group_stats target: Generates group-averaged NIfTI maps for all atlas segs × stain metrics × contrast values

Outputs

Per contrast group:

  • *_contrast-<column>+<value>_groupavgsegstats.tsv: Averaged metrics per brain region
  • *_contrast-<column>+<value>_metric-<stain>+<metric>_groupavg.nii.gz: 3D maps of averaged metrics in template space

Complements existing statistical comparison maps (t-stats, p-values) with actual group-averaged values for visualization.

Original prompt

right now we have voxel-wise group-means created from parquet tables e.g.:

    counts_nii=bids(
        root=root,
        datatype="group",
        space="{template}",
        level="{level}",
        desc="{desc}",
        contrast="{contrast_column}+{contrast_value}",
        suffix="coloccount.nii",
    ),

but I would also like segstats.tsv tables to be averaged over groups in the same way, using the script "../scripts/map_tsv_dseg_to_nii.py" to write group avg maps in template space, for each atlas seg. add new rules to the groupstats smk file.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Add averaging of segstats.tsv over groups Add group-averaged segstats maps to template space by contrast Dec 15, 2025
Copilot AI requested a review from akhanf December 15, 2025 14:39
@akhanf akhanf marked this pull request as ready for review December 19, 2025 01:37
@akhanf akhanf merged commit a62eb4e into main Dec 19, 2025
2 checks passed
@akhanf akhanf deleted the copilot/add-group-averaging-segstats branch December 19, 2025 01:54
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