Skip to content

Commit ff0a316

Browse files
authored
Merge pull request #670 from Remi-Gau/doc
[DOC] improve description of stats output and of bids stats model
2 parents 8195c3b + 8c177e0 commit ff0a316

19 files changed

+488
-17
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,20 @@ name: Bug report
55

66
description: Fill in this template to report a bug
77

8-
title: "[BUG]: "
8+
title: "[BUG]"
99

10-
labels: ["bug"]
10+
labels: ["bug :bug:"]
1111

1212
body:
13+
14+
- type: markdown
15+
attributes:
16+
value: |
17+
Thanks for taking the time to fill out this bug report!
18+
19+
To maximize chances for a quick fix make sure you know
20+
[How to Report Bugs Effectively](https://www.chiark.greenend.org.uk/~sgtatham/bugs.html)
21+
1322
- type: checkboxes
1423
attributes:
1524
label: Is there an existing issue for this?

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
1212
[![codecov](https://codecov.io/gh/cpp-lln-lab/CPP_SPM/branch/main/graph/badge.svg?token=PMQYH0DIPX)](https://codecov.io/gh/cpp-lln-lab/CPP_SPM)
1313
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3554331.svg)](https://doi.org/10.5281/zenodo.3554331)
14-
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](https://github.com/cpp-lln-lab/CPP_SPM#contributors)
14+
[![All Contributors](https://img.shields.io/badge/all_contributors-11-orange.svg?style=flat-square)](https://github.com/cpp-lln-lab/CPP_SPM#contributors)
1515

1616
<!-- markdown-link-check-enable -->
1717

@@ -58,7 +58,6 @@ See
5858
### Preprocessing
5959

6060
```matlab
61-
6261
bids_dir = path_to_raw_bids_dataset;
6362
output_dir = path_to_where_the_output_should_go;
6463
@@ -73,7 +72,6 @@ cpp_spm(bids_dir, output_dir, 'subject', ...
7372
### GLM
7473

7574
```matlab
76-
7775
bids_dir = path_to_raw_bids_dataset;
7876
preproc_dir = path_to_preprocessed_dataset;
7977
output_dir = path_to_where_the_output_should_go;

docs/source/bids_stats_model.md

Lines changed: 145 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ It uses
9292
to run those transformations. Please see this bids-matlab documentation to know
9393
how to use them and call them in your JSON.
9494

95-
The advantage of this bids-matlab transformers is
96-
that they allow you to directly add on tsv files to quickly see
97-
what outcome a series of transformers will produce.
95+
The advantage of this bids-matlab transformers is that they allow you to
96+
directly add on tsv files to quickly see what outcome a series of transformers
97+
will produce.
9898

9999
Below is an example on how to subtract 3 seconds from the event onsets of the
100100
conditions `motion` listed in the `trial_type` columns of the `events.tsv` file,
@@ -151,7 +151,7 @@ dummy scans will be included.
151151
"static"
152152
],
153153
"Model": "spm"
154-
}
154+
}
155155
```
156156

157157
`HRF` specifies:
@@ -169,13 +169,43 @@ Not yet implementated:
169169

170170
- `"fir"`
171171

172+
173+
<!--
174+
```json
175+
"Model": {
176+
"Type": "glm",
177+
"X": [
178+
"motion", -------- Those 2 conditions will be convolved
179+
"static", -------| using the canonical HRF only.
180+
Those 3 conditions <-------"trans_?", |
181+
will not <-------"rot_?", |
182+
be convolved. <-------"*outlier*" |
183+
], |
184+
"HRF": { |
185+
"Variables": [ |
186+
"motion", <--|
187+
"static" <--|
188+
],
189+
"Model": "spm"
190+
}
191+
```
192+
-->
193+
194+
```{image} ./images/gui_batch_model_hrf.png
195+
:alt: Corresponding options in SPM batch
196+
:align: center
197+
```
198+
172199
(bids_stats_model_sofware)=
173200

174201
### Software
202+
175203
<!-- markdown-link-check-disable -->
204+
176205
Note that if you wanted to change the
177206
[`SerialCorrelation` model](auto_correlation_model) used by CPP SPM, you could
178207
do so via the `Software` object of the BIDS stats model.
208+
179209
<!-- markdown-link-check-enable -->
180210

181211
Similar you can adapt directly in the model the threshold used by SPM to create
@@ -207,6 +237,111 @@ of SPM defaults.) .
207237
}
208238
```
209239

240+
```{figure} ./images/gui_batch_model_serialCorrelation_maskThresh.png
241+
---
242+
name: software_spm_batch
243+
align: center
244+
---
245+
Corresponding options in SPM batch
246+
```
247+
248+
### Contrasts
249+
250+
#### Run level
251+
252+
To stay close to the way most SPM users are familiar with, all runs are analyzed
253+
in one single GLM.
254+
255+
Contrasts are the run level that are either specified using `DummyContrasts` or
256+
`Contrasts` will be computed and will have the run number appended to their name
257+
in the SPM gui as shown in {ref}`contrast_run_1` and {ref}`contrast_run_2`.
258+
259+
```{literalinclude} ./examples/model-contrastsRun_smdl.json
260+
:language: json
261+
```
262+
263+
```{figure} ./images/gui_contrast_run_1.png
264+
---
265+
name: contrast_run_1
266+
align: center
267+
---
268+
Contrast for run 1
269+
```
270+
271+
```{figure} ./images/gui_contrast_run_2.png
272+
---
273+
name: contrast_run_2
274+
align: center
275+
---
276+
Contrast for run 2
277+
```
278+
279+
#### Subject level
280+
281+
At the moment the only type of model supported at the run level is averaging of
282+
run level contrasts.
283+
284+
```{literalinclude} ./examples/model-contrastsSubject_smdl.json
285+
:language: json
286+
```
287+
288+
```{figure} ./images/gui_contrast_run_1_and_2.png
289+
---
290+
name: contrast_subject
291+
align: center
292+
---
293+
Subject level contrast averaging beta of run 1 and 2
294+
```
295+
296+
## Dataset level
297+
298+
At the moment only, the only type of models that are supported are:
299+
300+
- one sample t-test: averaging across all subjects
301+
302+
```{literalinclude} ./examples/model-datasetLevel_smdl.json
303+
:language: json
304+
```
305+
306+
- one sample t-test: averaging across all subjects of a specific group
307+
308+
```{literalinclude} ./examples/model_withinGroup_smdl.json
309+
:language: json
310+
```
311+
312+
- 2 samples t-test: comparing 2 groups
313+
314+
At the moment this can only be based on how participants are allocated to a
315+
group based on a `group` or `Group` column in the `participants.tsv` of in the
316+
raw dataset.
317+
318+
```{literalinclude} ./examples/model_betweenGroups_smdl.json
319+
:language: json
320+
```
321+
322+
### Method section
323+
324+
It is possible to write a draft of method section based on a BIDS statistical
325+
model.
326+
327+
```matlab
328+
opt.model.file = fullfile(pwd, ...
329+
'models', ...
330+
'model-faceRepetition_smdl.json');
331+
opt.fwhm.contrast = 0;
332+
opt = checkOptions(opt);
333+
334+
opt.designType = 'block';
335+
336+
outputFile = boilerplate(opt, ...
337+
'outputPath', pwd, ...
338+
'pipelineType', 'stats');
339+
```
340+
341+
```{literalinclude} ./examples/stats.md
342+
:language: markdown
343+
```
344+
210345
## Parametric modulation
211346

212347
Those are not yet fully implemented but there is an example of how to get
@@ -224,8 +359,13 @@ There are several examples of models in the
224359
[model zoo](https://github.com/bids-standard/model-zoo) along with links to
225360
their datasets.
226361

227-
Several of the :ref:`demos` have their own model and you can find several
362+
<!-- markdown-link-check-disable -->
363+
364+
Several of the [demos](demos) have their own model and you can find several
228365
"dummy" models (without corresponding data) used for testing
366+
367+
<!-- markdown-link-check-enable -->
368+
229369
[in this folder](https://github.com/cpp-lln-lab/CPP_SPM/tree/dev/tests/dummyData/models).
230370

231371
An example of JSON file could look something like that:

docs/source/conf.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
# This pattern also affects html_static_path and html_extra_path.
5050
exclude_patterns = ["examples", "defaults", "demo", "images/*.md"]
5151

52+
suppress_warnings = ["myst.header"]
53+
5254
# The name of the Pygments (syntax highlighting) style to use.
5355
pygments_style = "sphinx"
5456

docs/source/demos.rst

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
.. _demos:
2-
31
Demos
42
*****
53

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"Level": "Run",
3+
"Name": "run_level",
4+
"X": [
5+
"olfid_eucalyptus_left",
6+
"olfid_eucalyptus_right",
7+
"olfid_almond_left",
8+
"olfid_almond_right",
9+
"olfloc_eucalyptus_left",
10+
"olfloc_eucalyptus_right",
11+
"olfloc_almond_left",
12+
"olfloc_almond_right",
13+
"resp_03",
14+
"resp_12",
15+
1
16+
],
17+
"DummyContrasts": {
18+
"Contrasts": [
19+
"olfid_eucalyptus_left",
20+
"olfid_eucalyptus_right",
21+
"olfid_almond_left",
22+
"olfid_almond_right",
23+
"olfloc_eucalyptus_left",
24+
"olfloc_eucalyptus_right",
25+
"olfloc_almond_left",
26+
"olfloc_almond_right"
27+
],
28+
"Test": "t"
29+
},
30+
"Contrasts": [
31+
{
32+
"Name": "olfid",
33+
"ConditionList": [
34+
"olfid_eucalyptus_left",
35+
"olfid_eucalyptus_right",
36+
"olfid_almond_left",
37+
"olfid_almond_right"
38+
],
39+
"Weights": [
40+
1,
41+
1,
42+
1,
43+
1
44+
],
45+
"Test": "t"
46+
}
47+
]
48+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"Level": "Subject",
3+
"Name": "subject_level",
4+
"Description": "Only averaging at the subject level is supported for now.",
5+
"GroupBy": [
6+
"contrast",
7+
"subject"
8+
],
9+
"Model": {
10+
"X": [
11+
1
12+
],
13+
"Type": "glm"
14+
},
15+
"DummyContrasts": {
16+
"Test": "t"
17+
}
18+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"Level": "Dataset",
3+
"Name": "dataset_level",
4+
"GroupBy": [
5+
"contrast"
6+
],
7+
"Model": {
8+
"X": [
9+
1
10+
],
11+
"Type": "glm"
12+
},
13+
"DummyContrasts": {
14+
"Test": "t"
15+
}
16+
}

0 commit comments

Comments
 (0)