-
Notifications
You must be signed in to change notification settings - Fork 74
Software architecture
Below we explain in words the high-level software architecture of the PCNtoolkit as seen in the diagram above. To better separate the classes we split them 5 thematic categories:
It is the orchestrator you interact with. To use it: construct it around a regression model, then fit → predict (or fit_predict). It also exposes transfer, extend, merge (federated learning) and computes Z-scores / centiles. It owns a RegressionModel as its template, plus one fitted model per response variable. It has an Evaluator and a set of Scalers, and it gets the test and train data from NormData.
It is the abstract base which creates a template every model implements (fit, forward, backward, transfer). The model type lives in its two subclasses:
-
BLR(blr.py) -
HBR(hbr.py)
Algorithms used by the regression models. Each is an abstract base + subclasses.
-
BLR(regression_model/blr.py): + usesBasisFunction(separate mean/var basis) and can useWarpBase(w-BLR: fit non-Gaussian distributions). -
HBR(regression_model/hbr.py): uses aLikelihood→ composesBasePrior→ composesBasisFunction(only ifLinearPrioris selected).
Extends xarray's Dataset and carries X (covariates), Y (responses), batch effects, and results (Z, centiles). Can hold arrays with different dimensions. Built via from_dataframe / from_ndarrays / from_paths.
Once you have a fit-predicted NormativeModel, you can move to longitudinal scoring.
It is the abstract base class. It requires a fitted model and rejects cross-sectional data. Two scores supported now:
-
ZDiffScore: BLR-only, exactly two timepoints. -
ZGainScore: works with anyRegressionModel, estimates a correlation matrixR, supports thrive lines. The math behindZGainScoreare invelocity.py(computes correlation matrix, thrive lines, z-gain).
Wraps fit/predict to run parallel / on a cluster (SLURM/Torque) and handle cross-validation. Uses NormativeModel
Computes statistical metrics (R², RMSE, MSLL, ...) on results.
Plot centile curves
Lets you run models from the terminal instead of writing Python. It's a thin layer: it reads a config, then calls the same fit/predict/load_data
