« SAM Scripts | Software | runCheck »
3dNormalize3dNormalize replaces the old dozscore program. They are really the same, except for their default behavior; dozscore removes the mean by default, 3dNormalize does not. For differential SAM imaging, which is quite common, it is probably better not to remove the mean.
Normalization of some kind is often useful when comparing across subjects, and when the magnitude of the power change is not as important as where the power change is. If you are interested in the magnitude of the change (as a function of subject, probably), then you don't want to normalize across subjects.
First, you'll need to install the stats program. This little utility just computes statistics from a column of numbers; you might find it useful for other purposes and it also simplified the programming of 3dNormalize.
Download stats.c. Then compile it and
move the resulting executable into your bin directory.
gcc -O2 -s -o stats stats.c -lm mv stats ~/bin
Next, download 3dNormalize. It's just a shell script, so simply make it executable and move it to your bin.
chmod +x 3dNormalize mv 3dNormalize ~/bin
The old dozscore script is also available here, but it doesn't do 3d+time BRIKs.
3dNormalize [-z] [-m subbrik] [-v] in out
Here, in is the input SAM volume or BRIK file you'd like to normalize. It may be a 3d+time BRIK, in which case the statistics are calculated across all subbriks. If a BRIK, it can be either +orig or +tlrc, and optionally compressed. The output is written as a BRIK to out.
The -z option produces z-scores, i.e., it causes the output to have a mean of 0 and a standard deviation of 1. The default is to leave the mean the same, but to scale the SD. The -v option reports both values.
3dNormalize only operates on non-zero voxels. Voxels that are exactly zero are considered to be outside the head. To do this, a mask is generated from the non-zero voxels, by default from the first (or only) subbrik. The subbrik to use to generate the mask can be set with -m.
Q Should I use the -z option?
A Well, the issue is that if you are using -D3, a value of zero has a very precise meaning: equal power levels. If you use -z to subtract the mean from the volume, zero will mean something else, and worse, a positive value, meaning active > control, might become a negative value, meaning control > active. Now, with that said, in general your SAM volumes should have a very normal looking distribution to start with (you can easily check this with 3dhistog), so removing the mean shouldn't hurt, but then, it's not necessary in that case.
Additionally, if you have a state imbalance, removing the mean might be appropriate. Consider what happens if you have many more samples in the active condition than in the control condition. During the calculation of the covariance matrices, more samples means that covariance will converge more. Covariance converges up, so this means that there will be a bias towards more power in the active condition (the one with more samples). You may find that the resulting volume has all positive values, and no negative values at all. If the distribution is still normal (use 3dhistog), -z will fix the state imbalance.