harmonization-tool

Removes site and scanner batch effects from neuroimaging features using ComBat, ComBat-GAM, and CovBat harmonization methods.

89|5|Updated Mar 25, 2026
One-click install
npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill harmonization-tool-cuhk-aim-group
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: harmonization-tool
Source: https://github.com/CUHK-AIM-Group/NeuroDiscovery/tree/main/skills/harmonization-tool
Command: npx skills add https://github.com/CUHK-AIM-Group/NeuroDiscovery --skill harmonization-tool-cuhk-aim-group

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires numpy, pandas, scikit-learn, nilearn, nibabel, torch, requests, neuroHarmonize, neuroCombat, covbat, and includes scripts (resource) components.

What problem does it solve? Multi-site neuroimaging studies suffer from site, scanner, and batch effects that confound downstream machine learning models and inflate benchmark results through site leakage. This skill removes technical variance from subject-level features while preserving biological covariates like age, sex, and diagnosis, enabling honest mega-analysis and cross-site evaluation. ## Core Features & Use Cases - Multiple harmonization methods: ComBat, ComBat-GAM (for wide age ranges), CovBat (for connectome covariance structure), and site-as-covariate regression, selected based on feature granularity and cohort structure. - Site-aware evaluation protocols: Leave-site-out and site-stratified 80/10/10 splitters that fit harmonization on training data only, preventing information leakage into validation and test sets. - Before/after diagnostics: Quantifies per-feature site R² before and after harmonization so you can verify the batch effect was actually removed, with a manifest.json audit trail for provenance. - Use Case: Pool ABIDE I and ADHD-200 connectomes for autism/ADHD classification, run the three-way pilot (random split vs site-stratified vs harmonized) to measure your cohort's site-leakage budget before trusting any accuracy number. ## Quick Start Ask the agent to harmonize my multi-site connectome features with ComBat-GAM using site as the batch variable and age, sex, and diagnosis as protected covariates, then report the site effect before and after.

Frequently Asked Questions about harmonization-tool

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I remove site effects from neuroimaging features with ComBat?

Run the harmonize.py CLI with your features .npy and meta.csv, setting --method combat and --batch site. The script validates the IO schema, quantifies site R² before and after, and writes harmonized features plus a manifest.json to the output directory.

ComBat vs ComBat-GAM vs CovBat: which harmonization method should I use?

Use ComBat-GAM when the cohort age range exceeds 20 years so age effects are modeled non-linearly, plain ComBat otherwise. Choose CovBat for connectome or FC features where covariance structure matters, and site-covariate regression as a quick first pass or LOSO-safe fallback.

Why does harmonization cause data leakage in cross-validation?

Fitting harmonization on the full dataset before splitting leaks site-level information into the test set. The adapters enforce separate fit and transform entry points so harmonization is fit on the training split only, then applied to validation and test data.

Can I use leave-site-out cross-validation with ComBat-GAM?

ComBat-GAM and CovBat cannot harmonize a site unseen during fit, so leave-site-out produces NaNs with them. Use site-stratified 80/10/10 splits for ComBat-GAM, or the site-covariate method for strict leave-site-out evaluation.

What metadata columns are required for multi-site harmonization?

The metadata table must include subject_id, dataset, and site columns, with at least two unique site values. Protected covariates such as age, sex, and dx must also be present if listed in --protected, and the diagnosis column must be protected when it is the prediction target.

When should I not use batch effect harmonization?

Skip harmonization for single-site, single-scanner studies where no batch variable exists. Also avoid it when site and diagnosis are fully confounded, since removing site variance will also remove the diagnosis signal that lives in the site channel.