Skip to content

Commit 3651bde

Browse files
authored
Updated documentation
1 parent f6d4444 commit 3651bde

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,61 @@ neuroCombat is hosted on PyPI, and the easiest way to install neuroCombat is to
1515
```
1616
pip install neuroCombat
1717
```
18+
19+
## Usage
20+
21+
The ```neuroCombat``` function performs harmonization
22+
23+
```python
24+
from neuroCombat import neuroCombat
25+
import pandas as pd
26+
import numpy as np
27+
28+
# Getting example data
29+
# 200 rows (features) and 10 columns (scans)
30+
data = np.genfromtxt('testdata/testdata.csv', delimiter=",", skip_header=1)
31+
32+
# Specifying the batch (scanner variable) as well as a biological covariate to preserve:
33+
covars = {'batch':[1,1,1,1,1,2,2,2,2,2],
34+
'gender':[1,2,1,2,1,2,1,2,1,2]}
35+
covars = pd.DataFrame(covars)
36+
37+
# To specify names of the variables that are categorical:
38+
categorical_cols = ['gender']
39+
40+
# To specify the name of the variable that encodes for the scanner/batch covariate:
41+
batch_col = 'batch'
42+
43+
#Harmonization step:
44+
data_combat = neuroCombat(dat=data,
45+
covars=covars,
46+
batch_col=batch_col,
47+
categorical_cols=categorical_cols)["data"]
48+
```
49+
50+
## Optional arguments
51+
52+
- `eb` : `True` or `False`. Should Empirical Bayes be performed? If `False`, 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).
53+
54+
- `parametric` : `True` or `False`. Should parametric adjustements be performed? `True` by default.
55+
56+
- `mean_only` : `True` or `False`. Should only be means adjusted (no scaling)? `False` by default
57+
58+
- `ref_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.
59+
60+
## Output
61+
62+
Since version 0.2.10, the `neuroCombat` function outputs a dictionary with 3 elements:
63+
- `data`: A numpy array of the harmonized data, with the same dimension (shape) as the input data.
64+
- `estimates`: A dictionary of the neuroCombat estimates; useful for visualization and understand scanner effects.
65+
- `info`: A dictionary of the inputs needed for ComBat harmonization (batch/scanner information, etc.)
66+
67+
To simply return the harmonized data, one can use the following:
68+
69+
```
70+
data_combat = neuroCombat(dat=dat, ...)["data"]
71+
```
72+
73+
where `...` are the user-specified arguments needed for harmonization.
74+
75+

0 commit comments

Comments
 (0)