A null model for comparing two sets of edges, written in Matlab.
Many edge matrices appear similar. nulledge is a null model for edge matrix similarity. It generates randomized edge matrices conformant to the natural clustering structure of brain connectivity.
- Generates randomized edge matrices conformant to clustered network structure.
- Accounts for correlation between variables
$x_1$ and$x_2$ . - If
$x_2$ is not available, it can be inferred from the connectivity matrix$b_2$ . - Readable, object-oriented Matlab code.
Clone the git repository and start Matlab.
git clone https://github.com/DosenbachGreene/nulledge.git
cd nulledge
matlab
Create a new NullEdgeModel
, permute it, plot a histogram, and calculate a p-value.
model = NullEdgeModel;
model.Y = Y; % edge
model.Z = Z; % covariates
model.x1 = x1; % 1st variable (e.g. NIH Toolbox)
model.x2 = x2; % 2nd variable (e.g. income)
r = model.similarity() % correlation between b1 and b2
rnull = model.permute(); % generate null model
histogram(abs(rnull)); xline(abs(r));
p_value = sum(abs(rnull) > abs(r)) / length(rnull);
See the comments/help information in NullEdgeModel.m
for more information.
The experienced neuroimaging scientist recognizes that many edge matrices resemble one another, therefore when comparing two edge matrices (e.g. using Pearson linear correlation) the threshold for significance is not
nulledge randomizes edges with respect to the clustered network structure. The clustering is automatically estimated from the observed edges
For a given study participant, the voxel, parcel, or node-wise connectivity, or edge matrix can be flattened into a row vector of its edges.
Given some predictor variables
Solving
Instead of forward-projecting in one step using the pseudoinverse
Covariates are additional columns in
We may have additional "nuisance" covariates whose edge matrices we are not interested in, e.g. head motion. These can be included as additional columns in
We are not interested in
Then by multiplying both sides of the equation by
Back-projection is solving for
- Note that a unique solution for
$X$ only exists when there are more columns than rows in$Y$ , i.e. there are more edges than participants in the study (nearly always true in neuroimaging studies). - Note that since
$\Sigma$ is diagonal its inverse is simplydiag(1./diag(S))
. - When there are no covariates then
$\zeta$ can simply be omitted from the equation, which then reduces to:$X = U\beta_u^\intercal\left(\beta_u^+\right)^\intercal\beta_u^+$ - Note that
$\hat{X_\zeta}$ has$n-p$ rows where$p$ is the number of columns in$Z$ . If one wishes to obtain all the rows of$X$ (orthogonalized to the columns of$Z$ ) then simply left-multiply by$\zeta$ .
In the special case where
As proof, we begin with the forward model. Since
$U$ is orthogonal,$UU^\intercal=I$ , and since$\zeta^\intercal$ is orthogonal,$\zeta^\intercal\zeta=I$ . Thus:
$\beta_u = \left(\zeta^\intercal X\right)^+ \zeta^\intercal U$ $\beta_u U^\intercal\zeta = \left(\zeta^\intercal X\right)^+\zeta^\intercal UU^\intercal\zeta = \left(\zeta^\intercal X\right)^+\zeta^\intercal I\zeta$ $\beta_u U^\intercal\zeta = \left(\zeta^\intercal X\right)^+\zeta^\intercal\zeta = \left(\zeta^\intercal X\right)^+I = \left(\zeta^\intercal X\right)^+$ $\left(\beta_u U^\intercal\zeta\right)^\intercal = \zeta^\intercal U\beta_u^\intercal = \left[\left(\zeta^\intercal X\right)^+\right]^\intercal$ Next we apply the identity
$\left(X^+\right)^\intercal X^\intercal X = X$ .
$\zeta^\intercal U\beta_u^\intercal \left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X = \left[\left(\zeta^\intercal X\right)^+\right]^\intercal \left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X = \zeta^\intercal X$ We can use the identity
$\left(X^\intercal X\right)^{-1}=X^+\left(X^+\right)^\intercal$ and substitute:Proving:
$\left[\left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X\right]^{-1} = \left(\zeta^\intercal X\right)^+\left[\left(\zeta^\intercal X\right)^+\right]^\intercal = \left(\beta_u U^\intercal\zeta\right)\left(\beta_u U^\intercal\zeta\right)^\intercal$ $\left[\left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X\right]^{-1} = \left(\zeta^\intercal U\beta_u^\intercal\right)^\intercal\left(\zeta^\intercal U\beta_u^\intercal\right)$ $\left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X = \left[\left(\zeta^\intercal U\beta_u^\intercal\right)^\intercal\left(\zeta^\intercal U\beta_u^\intercal\right)\right]^{-1}$ $\left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X = \left(\zeta^\intercal U\beta_u^\intercal\right)^+\left[\left(\zeta^\intercal U\beta_u^\intercal\right)^+\right]^\intercal$
$\hat{X_\zeta} = \zeta^\intercal X = \zeta^\intercal U\beta_u^\intercal \left(\zeta^\intercal X\right)^\intercal \zeta^\intercal X$ $\hat{X_\zeta} = \zeta^\intercal X = \zeta^\intercal U\beta_u^\intercal \left(\zeta^\intercal U\beta_u^\intercal\right)^+\left[\left(\zeta^\intercal U\beta_u^\intercal\right)^+\right]^\intercal$
First we compute the un-randomized similarity between the edge vectors
- Compute the singular value decomposition of
$Y = U\Sigma V^\intercal$ .[U,S,V] = svd(Y, 'econ');
- Compute
$\zeta$ , the null space of$Z$ , such that$\zeta^\intercal\zeta=I, \zeta^\intercal Z = \mathbf{0}$ .Znull = null(Z');
- Controlling for
$Z$ using its null space, forward-project$X=\left[x_1\ x_2\right]$ to obtain$\hat{\beta} = \left[\hat{b_1}\ \hat{b_2}\right]$ . Forward-projecting$X$ together controls for the correlation between$x_1$ and$x_2$ .BU = pinv(Znull' * X) * Znull' * U;
B = BU * S * V';
- Compute the similarity between
$\hat{b_1}$ and$\hat{b_2}$ .r = corr(B(1,:)', B(2,:)');
Next, prepare for randomization.
- Forward-project
$X$ into the space of$U$ to obtain$\hat{B_u} = \left[\hat{b_{1u}}\ \hat{b_{2u}}\right]$ .BU = pinv(Znull' * X) * Znull' * U;
Now we can randomize and permute.
- Randomly sign-flip the entries of
$\hat{B_u}$ .BU_rand = BU .* ((randi(2, size(BU,1), size(BU,2))-1).*2-1);
- Back-project the randomized
$\hat{B_u}$ to obtain randomized$\hat{X_\zeta} = \left[\hat{x_{1\zeta}}\ \hat{x_{2\zeta}}\right]$ .zub = this.Znull' * this.U * BU_rand';
zub_pinv = pinv(zub);
Xnull_rand = zub * (zub_pinv * zub_pinv');
- Forward-project the randomized
$X_\zeta$ to obtain a randomized$\hat{\beta} = \left[\hat{b_1}\ \hat{b_2}\right]$ . This step controls for coincidental correlations between the randomized$x_{1\zeta}$ and$x_{2\zeta}$ .BU_rand = pinv(Xnull_rand) * Znull' * U;
B_rand = BU_rand * S * V';
- Compute the similarity betweent the randomized
$\hat{b_1}$ and$\hat{b_2}$ .rnull = corr(B_rand(1,:)', B_rand(2,:)');
- Repeat steps 6-9 many times to obtain a null distribution for the similarity computed in step 4.
Suppose John collects resting-state fMRI data and NIH Toolbox score on 5,000 participants. In a separate study, Alice collects resting-state fMRI data and demographic information, including income, on 4,000 different participants. John has a hypothesis that NIH Toolbox score and income have similar effects on resting-state connectivity. He persuades Alice to share the edge vector
The backprojection step in nulledge provides John with a mechanism to test his hypothesis. Assuming Alice used a similar set of nuisance covariates to John, John can do:
model = NullEdgeModel;
model.Y = Y; % John's brain data
model.Z = Z; % Nuisance covariates
model.x1 = NIH_Toolbox_score; % John's behavior data
model.x2 = model.backproject(b2); % Using Alice's data
r = model.similarity();
rnull = model.permute();
p_value = p = sum(abs(rnull) > abs(r)) / length(rnull);