Python port of longCombat (Beer et al. 2020): longitudinal ComBat harmonization in a linear mixed-effects model framework.
Project description
longcombat-py
Python port of jcbeer/longCombat.
The API mirrors neuroCombat where
concepts overlap so the two can be used side-by-side.
Longitudinal ComBat uses an empirical Bayes method to harmonize the means and variances of the residuals across batches in a linear mixed-effects model framework. See:
Beer JC, Tustison NJ, Cook PA, Davatzikos C, Sheline YI, Shinohara RT, Linn KA (2020). Longitudinal ComBat: A method for harmonizing longitudinal multi-scanner imaging data. NeuroImage, 220:117129. https://doi.org/10.1016/j.neuroimage.2020.117129
Deviations from the R original — this port is not bit-identical to the R package. Please read
DIFFERENCES_FROM_R.mdbefore using, especially if comparing results to the R output.
Install
pip install longcombat-py # core
pip install "longcombat-py[plot]" # + matplotlib for visualization helpers
Quick start
Long-format pandas.DataFrame with one row per (subject, visit):
import pandas as pd
from longcombat import long_combat
result = long_combat(
data=df,
batch_col="scanner",
id_col="subid",
time_col="visit",
features=["feature1", "feature2", "feature3"],
formula="age + diagnosis*visit", # Patsy RHS, fixed effects
ranef="(1|subid)", # lme4-style random effects
)
harmonized = result.data_combat
long_combat returns a LongCombatResult with:
.data_combat— harmonized DataFrame ([id_col, time_col, batch_col, feature1.combat, ...]).gammahat,.delta2hat— method-of-moments estimates of additive and multiplicative batch effects on the standardized residuals.gammastarhat,.delta2starhat— empirical-Bayes shrunk estimates
API surface
| Function | R analog |
|---|---|
long_combat |
longCombat |
add_test |
addTest (LRT only — see DIFFERENCES_FROM_R.md) |
mult_test |
multTest |
batch_time_viz |
batchTimeViz |
batch_boxplot |
batchBoxplot |
traj_plot |
trajPlot |
Parameter naming mirrors neuroCombat where the concept exists
(batch_col, eb, mean_only). Additional concepts from longCombat
(id_col, time_col, ranef, formula, niter, method) preserve the
R names.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file longcombat_py-0.1.1.tar.gz.
File metadata
- Download URL: longcombat_py-0.1.1.tar.gz
- Upload date:
- Size: 27.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aa02e9dee1413285ad345a4cc60ea5c2b1c241563daf7c4b685c5c3375bf113b
|
|
| MD5 |
da3e8ad22f11de96a4320483818d221a
|
|
| BLAKE2b-256 |
bbe59ce3d5abf178aaceb1068d24b634fec6885b06e9213a2eb08a0afac64054
|
Provenance
The following attestation bundles were made for longcombat_py-0.1.1.tar.gz:
Publisher:
publish.yml on NoiseFilterT/longcombat-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
longcombat_py-0.1.1.tar.gz -
Subject digest:
aa02e9dee1413285ad345a4cc60ea5c2b1c241563daf7c4b685c5c3375bf113b - Sigstore transparency entry: 1767680153
- Sigstore integration time:
-
Permalink:
NoiseFilterT/longcombat-py@2e838c72fe1dbece22b702dcc0b69c53aca82c13 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NoiseFilterT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e838c72fe1dbece22b702dcc0b69c53aca82c13 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file longcombat_py-0.1.1-py3-none-any.whl.
File metadata
- Download URL: longcombat_py-0.1.1-py3-none-any.whl
- Upload date:
- Size: 23.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fcd38374c13fc6b6996cf98e67eb31a6fb33e2935609795b50263b2d603c6568
|
|
| MD5 |
0d6d00e717a3eb4d2f2a50a111c2253d
|
|
| BLAKE2b-256 |
471e3bc79ce12f576b3dde6836a4b49d2715c554cc690646d0e6e3bbd7e52f88
|
Provenance
The following attestation bundles were made for longcombat_py-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on NoiseFilterT/longcombat-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
longcombat_py-0.1.1-py3-none-any.whl -
Subject digest:
fcd38374c13fc6b6996cf98e67eb31a6fb33e2935609795b50263b2d603c6568 - Sigstore transparency entry: 1767681057
- Sigstore integration time:
-
Permalink:
NoiseFilterT/longcombat-py@2e838c72fe1dbece22b702dcc0b69c53aca82c13 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/NoiseFilterT
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@2e838c72fe1dbece22b702dcc0b69c53aca82c13 -
Trigger Event:
workflow_dispatch
-
Statement type: