Global Residualization

Open in Colab

Many datasets and networks contain dominant global patterns that sometimes represent artifactual, trivial, or irrelevant structure. Correspondingly, analyses often seek to remove these patterns to uncover or accentuate interesting underlying structure. We use the term global residualization to describe this removal.

Here, we show approximate equivalence between three variants of global residualization across unsupervised learning, network science, and imaging neuroscience:

Set up and load data

# Install abct and download abct_utils.py
base = "https://github.com/mikarubi/abct/raw/refs/heads/main"
!wget --no-clobber {base}/docs-code/examples/abct_utils.py
%pip install --quiet abct nilearn

# Import modules
import abct
import numpy as np
from abct_utils import W, X, C, ordw, ordc, not_eye, fig_scatter, fig_imshow
File ‘abct_utils.py’ already there; not retrieving.

Note: you may need to restart the kernel to use updated packages.

Show original structural and correlation networks

To show these relationships, we first consider the original structural and correlation networks in our example brain-imaging data. Each network contains 360 nodes (rows and columns) that denote cortical (brain) regions.

fig_imshow(W[np.ix_(ordw, ordw)],
           "Original structural network",
           "inferno").show()

fig_imshow(C[np.ix_(ordc, ordc)],
           "Original correlation network",
           "viridis").show()

Residualize structural and correlation networks

We now apply the three variants of global residualization to these networks. Note that while the degree and first component are removed directly from the networks, the global signal is regressed out of the time series data.

# Residualize structural network
Wd = abct.residualn(W, "degree")
Wr = abct.residualn(W, "rankone")

# Residualize correlation networks
Cd = abct.residualn(C, "degree")
Xg = abct.residualn(X.T, "global").T
Xg = Xg / np.linalg.norm(Xg, axis=0, keepdims=True)
Cg = Xg.T @ Xg

Visualize residual structural and correlation networks

We now visualize variants of the residual structural and correlation networks.

fig_imshow(Wd[np.ix_(ordw, ordw)],
           "Struct. degree correction",
           "inferno").show()

fig_imshow(Wr[np.ix_(ordw, ordw)],
           "Struct. first-component removal",
           "inferno").show()

fig_imshow(Cd[np.ix_(ordc, ordc)],
           "Corr. degree correction",
           "viridis").show()

fig_imshow(Cg[np.ix_(ordc, ordc)],
           "Corr. global signal regression",
           "viridis").show()