# When a group contrast isn't [0 1] because of unbalanced covariate?

I have a group level contrast with [task, subject group].
Subject group is binary coded 0/1 for control/depressed.
design matrix, matlab: [1 0 ; 1 0; 1 1 ; 1 1; 1 1;]
design matrix, python: [ [1, 0], [1, 0], [1, 1], [1, 1], [1, 1] ]

If I want to look at the depressed > control contrast, I use [0 1].
Where does this come from? mean_depressed - mean_control.
mean_control = [1 0] contrast
mean_depressed = [1 1] contrast
mean_depressed - mean_control = [1 1] - [1 0] = [0 1].

For the above case, follow along the second example in this video:

Now, let’s say I have the scanner as a covariate. I think that means my contrast is no longer quite so simple.
task// scanner (binary coded) // group
python: [[ 1, 0, 0], [1, 1, 0], [1, 0, 1], [1, 1, 1], [1, 0,1]]
I still want mean_depressed - mean_control.

mean_control = take the column wise mean for the controls = [1 1/2 0].
mean_depressed = column wise mean for the depressed = [1 1/3 1].
mean_dep - mean_control = [0, -1/6, 1].

Important aside: I actually orthogonalize the scanner and group columns relative to the task column, which means I subtract the mean of the whole column for scanner from the scanner column, and same for the group column. This won’t change the final result for the mean_dep - mean_control contrast.

It will give the variance from the scanner and group regressors to the task variable. I think this is justified because 90% of my subjects are one scanner, and splitting variance between the task and the scanner so neither gets credit means the speech production network is really weak. Based on prior knowledge, it doesn’t make sense to say that the ‘scanner’ is generating the speech network.

Orthogonalizing the group contrast relative to the task is mean centering the covariate (mathematically, like I said, it’s the same operation as applied to the scanner regressor but a different rationale). In this case, I want to know the task regressor activation for the average subject among my subjects rather than the task activation for the control group.
To see this, y = beta0 * (1) + beta_group * x_group. y = cope from L1.
If x_group is not demeaned, then beta0 <==> y when x_group = 0.
If x_group is demeaned, then beta0 <==> y when x_group = mean(x_group) because the equation becomes y = beta0 * (1) + beta_group * (x_group - mean(x_group)).