Skip to content

Commit

Permalink
Edits to t-test tutorials and removed broken link
Browse files Browse the repository at this point in the history
  • Loading branch information
SPMcentral authored Apr 30, 2024
1 parent f67f2a7 commit 13c249c
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion docs/installation/octave.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<https://octave.discourse.group/>
- Octave Bug Tracker: <https://savannah.gnu.org/bugs/?group=octave>
- Octave GitHub: <https://github.com/gnu-octave>
- Octave Space: <https://octave.space/>
- Octave Space: https://octave.space/
- Octave-Forge: <https://octave.sourceforge.net/>
- [GNU Octave and reproducible
research](https://dx.doi.org/10.1016/j.jprocont.2012.04.006) by John W.
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/fmri/group/one_sample_ttest.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# One-sample t-test

In this this tutorial we will perform a one-sample t-test. A one-sample t-test tells us if and where in the brain our group responds to a specific task condition or experimental contrast on average.
In this this tutorial we will perform a one-sample t-test at each voxel in the brain. This will tell us if and where in the brain our group responds to a specific task condition or experimental contrast on average.

Here we will check if there is an overall effect of the task (i.e. contrast `con_0009.nii` - for a reminder of first-level contrasts, check [the previous page](./index.md)).

Expand Down
54 changes: 27 additions & 27 deletions docs/tutorials/fmri/group/two_sample_ttest.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
# Two-sample t-test

In this tutorial we will look at comparing two groups. To do this we will use a two-sample t-test.
In this tutorial we will look at comparing two groups of participants. To do this we will use a two-sample t-test, using the dataset [previously introduced](./index.md).

We will focus on seeing if there is a difference in overall task activation (contrast `con_0009.nii`) depending on whether participants have responded with their left or right hand.
We will focus on testing for a difference in overall task activation (contrast `con_0009.nii`) depending on whether participants responded with their left or right hand.

## Specifying the model

1. Make an empty directory where you will save your results. Navigate to `derivatives/second_level` and make a folder for this analysis. Name it something meanigful to you, e.g. `two_sample_ttest_task`.
2. Select `Specify 2nd level` from the SPM menu.
3. In the pop-up batch editor window, select your newly created output directory by clicking `Directory` and navigating to `derivatives/second_level/two_sample_ttest_task` in the selection box.
4. Define your statistical model by selecting `Design` :material-arrow-right-bold: `Two-sample t-test`
5. We will now define our groups based on the information in `participants.mat`.
6. In your Matlab command window, navigate to your data archive directory and load the file: `load('derivatives/preprocessed/participants.mat')`.
7. You can view the contents of the file in the Matlab window. You will see that there is a variable called `response hand` which codes for which hand the participant used to make task responses. `0` corresponds to left, `1` to right.
8. In the command window, we will define a variable selecting all participants who responses with their left hand:
1. Navigate to `derivatives/second_level` and make an empty directory where you will save your results. Name it something meaningful to you, e.g. `two_sample_ttest_task`.
2. Switch to this new directory in Matlab, using the file navigator (typically on the left hand side of the Matlab window).
3. We will now define our groups based on the information in `participants.mat`.
4. In your Matlab command window, load the file: `load('participants.mat')`.
5. You can view the contents of the file in the Matlab window. You will see that there is a variable called `response hand` which codes for which hand the participant used to make task responses. `0` corresponds to left, `1` to right.
6. We will define a variable selecting all participants who responses with their left hand. Copy and paste the following code into the Matlab command window and press enter:

```Matlab
% identify which rows in the spreadsheet correspond to left-hand responders
Expand All @@ -28,7 +26,7 @@ We will focus on seeing if there is a difference in overall task activation (con
`img_group1` holds all the directories pointing to left-handed responder's `con_0009.nii`.
9. Now we'll do the same for the right-hand responders:
7. Now we'll do the same for the right-hand responders:
```Matlab
% identify which rows in the spreadsheet correspond to right-hand responders
Expand All @@ -42,21 +40,23 @@ We will focus on seeing if there is a difference in overall task activation (con
```
`img_group2` holds all directories pointing to right-hand responder's `con_0009.nii`.
10. Back in your SPM batch window, select `Group 1 scans` :material-arrow-right-bold: `Specify...`. Bring up the edit window by clicking `Ed` in the file selection window.
11. From the edit window, you can now call the variables you have saved in Matlab. Type in `img_group1` and press `Eval`. This should fill the window with full paths to each left-hand responder's `con_0009.nii` file. Click `Accept` :material-arrow-right-bold: `Done`.
12. Let's do the same thing for right-hand responders. `Group 1 scans` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `Ed` :material-arrow-right-bold: `img_group2` :material-arrow-right-bold: `Eval` :material-arrow-right-bold: `Accept` :material-arrow-right-bold: `Done`.
13. From the drop-down menu panel, select `SPM` :material-arrow-right-bold: `Stats` :material-arrow-right-bold: `Model estimation`.
14. Navigate to `Model estimation` in the left-hand panel of the batch window.
15. Press `Select SPM.mat` :material-arrow-right-bold: `Dependency` :material-arrow-right-bold: `Factorial design specification: SPM.mat file` :material-arrow-right-bold: `OK`.
16. From the drop-down menu panel, select `SPM` :material-arrow-right-bold: `Stats` :material-arrow-right-bold: `Contrast manager`.
17. Within the `Contrast manager`, click on `Select SPM.mat` :material-arrow-right-bold: `Dependency` :material-arrow-right-bold: `Model estimation: SPM.mat file` :material-arrow-right-bold: `OK`.
18. You can now start specifying your contrasts of interest in `Contrast sessions` comparing left to right hand responders and vice versa.
19. Select `Contrast sessions` :material-arrow-right-bold: `New: T-contrast`.
14. Name your contrast, `Name` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `left > right`.
15. Specify your contrast weight, `Weights vector` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `1 -1`.
16. Now, do the same for the reverse contrast - `Contrast sessions` :material-arrow-right-bold: `New: T-contrast`. `Name` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `right > left`. `Weights vector` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `-1 1`.
17. When you're ready, save your batch and press :material-play: to run your analysis.
8. Return to the main SPM menu window and select `Specify 2nd level`.
9. In the pop-up batch editor window, select your newly created output directory by clicking `Directory` and navigating to `derivatives/second_level/two_sample_ttest_task` in the selection box.
10. Define your statistical model by selecting `Design` :material-arrow-right-bold: `Two-sample t-test`
11. Select `Group 1 scans` :material-arrow-right-bold: `Specify...`. Bring up the edit window by clicking `Ed` in the file selection window.
12. From the edit window, you can now insert the variables you have saved in Matlab. Type in `img_group1` and press `Eval`. This should fill the window with full paths to each left-hand responder's `con_0009.nii` file. Click `Accept` :material-arrow-right-bold: `Done`.
13. Let's do the same thing for right-hand responders. `Group 2 scans` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `Ed` :material-arrow-right-bold: `img_group2` :material-arrow-right-bold: `Eval` :material-arrow-right-bold: `Accept` :material-arrow-right-bold: `Done`.
14. From the drop-down menu, select `SPM` :material-arrow-right-bold: `Stats` :material-arrow-right-bold: `Model estimation`.
15. Navigate to `Model estimation` in the left-hand panel of the batch window.
16. Press `Select SPM.mat` :material-arrow-right-bold: `Dependency` :material-arrow-right-bold: `Factorial design specification: SPM.mat file` :material-arrow-right-bold: `OK`.
17. From the drop-down menu panel, select `SPM` :material-arrow-right-bold: `Stats` :material-arrow-right-bold: `Contrast manager`.
18. Within the `Contrast manager`, click on `Select SPM.mat` :material-arrow-right-bold: `Dependency` :material-arrow-right-bold: `Model estimation: SPM.mat file` :material-arrow-right-bold: `OK`.
19. You can now start specifying your contrasts of interest in `Contrast sessions` comparing left to right hand responders and vice versa.
20. Select `Contrast sessions` :material-arrow-right-bold: `New: T-contrast`.
21. Name your contrast, `Name` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `left > right`.
22. Specify your contrast weight, `Weights vector` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `1 -1`.
23. Now, do the same for the reverse contrast - `Contrast sessions` :material-arrow-right-bold: `New: T-contrast`. `Name` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `right > left`. `Weights vector` :material-arrow-right-bold: `Specify...` :material-arrow-right-bold: `-1 1`.
24. When you're ready, save your batch and press :material-play: to run your analysis.
Your design matrix should have two columns specifying left-hand and right-hand responders:
Expand All @@ -77,7 +77,7 @@ After going through these steps, SPM will display the results as an activation m
![](../../../assets/figures/tutorials/fmri/group/semantic_two_sample_ttest_results.png)
We can see that a left-hand response was associated with activation in the contralateral (right) motor cortex.
We can see that participants who used their left-hand to make responses had stronger (more postitive) activation in the contralateral (right) motor cortex.
!!! question "Exercise"
Can you follow the steps above to view the second contrast we specified? What do you expect the results will be? Can you display them as a heatmap on a standard template?
Expand Down

0 comments on commit 13c249c

Please sign in to comment.