I have a similar question. I have three groups. I would like to perform one-way ANOVA followed by t-test. I am not sure if my model is correct or not. Maybe you can help me out.

Decided to move this to a separate topic: if things stray too far from the original content of a topic it makes it harder for subsequent readers to find. Can always add links to other topics if you think they are related.

I would like to perform one-way ANOVA followed by t-test.

We need to be very careful here up-front before we even get to the matrices. When you say “followed by”, are you referring to a post hoc test to identify source / direction of effect only where the ANOVA assigned statistical significance? Because that can be done, but:

It involves running the command twice, not once.

To do it “properly” (at least as far as I can ascertain) requires utilising a software feature that is implemented but not published and not yet part of a tagged MRtrix3 release.

I am not sure if my model is correct or not.

The “model” in terms of combination of design and contrast matrices is fine; there are multiple possible solutions and this is one of them.

However you are currently performing two t-tests, corresponding to the two rows of your contrast matrix. The first tests the hypothesis that group 1 is greater than group 2; the second tests the hypothesis that group 2 is greater than group 3. In neuroimaging-GLM-speak, an ANOVA is achieved using an F-test. You need two additions:

-ftests option, where you provide a text file specifying the set of F-tests you wish to perform and how to construct each. In your case the content of that file should simply be “1 1”: A single row for a single F-test, and that F-test incorporates both of the two rows of the contrast matrix.

-fonly option, since you don’t actually want to perform those two t-tests, you’re only specifying them to facilitate construction of the F-test.

I have a question about the text file for -ftests. When you want to run a ANOVA, we usually use a two-line contast matrix [1 -1 0 ; 0 1 -1]. I did not understand how it is [1 1 0]. Can you please explain it to me?

Each row of the F-test file corresponds to a single F-test. Here, there’s one F-test, so there’s one row.

Each column of the F-test file corresponds to a row in the contrast matrix, and contains a 0 or 1 to indicate if that row is or is not included in this F-test.

This is intended to mimic the FSL GLM GUI, where each t-test appears on a row, and each F-test is a column of checkboxes controlling which contrast matrix rows are a part of that F-test.

If you find this confusing, that’s more motivation for me to make the proposed interface change linked above (and external comments are quite welcome):