- Notifications
You must be signed in to change notification settings - Fork36
Harmonization of multi-site imaging data with ComBat (Python)
License
Jfortin1/neuroCombat
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
This is the maintained and official version of neuroCombat (previously hostedhere) introduced in ourour recent paper.
neuroCombat is hosted on PyPI, and the easiest way to install neuroCombat is to use thepip
command:
pip install neuroCombat
TheneuroCombat
function performs harmonization
fromneuroCombatimportneuroCombatimportpandasaspdimportnumpyasnp# Getting example data# 200 rows (features) and 10 columns (scans)data=np.genfromtxt('testdata/testdata.csv',delimiter=",",skip_header=1)# Specifying the batch (scanner variable) as well as a biological covariate to preserve:covars= {'batch':[1,1,1,1,1,2,2,2,2,2],'gender':[1,2,1,2,1,2,1,2,1,2]}covars=pd.DataFrame(covars)# To specify names of the variables that are categorical:categorical_cols= ['gender']# To specify the name of the variable that encodes for the scanner/batch covariate:batch_col='batch'#Harmonization step:data_combat=neuroCombat(dat=data,covars=covars,batch_col=batch_col,categorical_cols=categorical_cols)["data"]
eb
:True
orFalse
. Should Empirical Bayes be performed? IfFalse
, the harmonization model will be fit for each feature separately. This is equivalent to performing a location/shift (L/S) correction to each feature separately (no information pooling across features).parametric
:True
orFalse
. Should parametric adjustements be performed?True
by default.mean_only
:True
orFalse
. Should only be means adjusted (no scaling)?False
by defaultref_batch
: batch name to be used as the reference batch for harmonization.None
by default, in which case the average across scans/images/sites is taken as the reference batch.
Since version 0.2.10, theneuroCombat
function outputs a dictionary with 3 elements:
data
: A numpy array of the harmonized data, with the same dimension (shape) as the input data.estimates
: A dictionary of the neuroCombat estimates; useful for visualization and understand scanner effects.info
: A dictionary of the inputs needed for ComBat harmonization (batch/scanner information, etc.)
To simply return the harmonized data, one can use the following:
data_combat = neuroCombat(dat=dat, ...)["data"]
where...
are the user-specified arguments needed for harmonization.
About
Harmonization of multi-site imaging data with ComBat (Python)