neuroharmony.ComBat

class neuroharmony.ComBat(features, covariates, eliminate_variance)[source]

ComBat model for harmonization.

A wrapper to the NeuroCombat harmonization as described by Fortin et al., (2018).

Parameters
featureslist

List of features to be harmonized with ComBat.

covariates

List of covariates for which the variance needs to be conserved.

eliminate_variance

List of variables for which the variance needs to be eliminated.

Attributes
harmonized_NDFrame of shape [n_subjects, n_features]

ComBat harmonized DataFrame.

fit(df)[source]

Fit the model.

Fit all the transforms one after the other and transform the data, then fit the transformed data using the final estimator.

Parameters
df: NDFrame of shape [n_subjects, n_features]

Training data. Must fulfil input requirements of first step of the pipeline.

Returns
selfComBat

This estimator

fit_transform(df)[source]

Fit to data, then transform it.

Fits transformer to df and y with optional parameters fit_params and returns a transformed version of df.

Parameters
df: NDFrame of shape [n_subjects, n_features]

Training set.

Returns
harmonized_: NDFrame of shape [n_samples, n_features_new]

Transformed array.

transform(df, y=None)[source]

Run ComBat normalization.

Applies trained model.

Parameters
df: NDFrame of shape [n_subjects, n_features]

Dataframe with data for each subject. The dataframe has to contain the features to be harmonized pandas the covariates which you want to use to harmonization.

Returns
harmonized: NDFrame of shape [n_subjects, n_features]

Dataframe with the harmonized data.

Raises
ValueError:

If there are missing features among the covariates or the features.

Examples

>>> ixi = DataSet('data/raw/IXI').data
>>> features = ['Left-Lateral-Ventricle', 'Left-Inf-Lat-Vent', ]
>>> covariates = ['Gender', 'Dataset', 'Age']
>>> combat = ComBat(features, covariates)
>>> harmonized = combat(ixi)
>>> harmonized

subject_id

Left-Lateral-Ventricle

Left-Inf-Lat-Vent

Gender

Dataset

Age

sub-002-00-2

0.007666

0.000134

0

2

31

sub-012-00-1

0.003778

0.000064

1

1

14

sub-013-00-1

0.012818

0.000464

1

1

17

sub-014-00-1

0.006289

0.000167

0

1

19

sub-015-00-1

0.003310

0.000154

1

1

26