Skip to content

Commit f4b986f

Browse files
authored
[ENH] use sub commands for python CLI (#1292)
* start adding sub commands * preproc subcommand * deal with create roi parser * deal with default_model sub command * deal with bms action * deal with stats actions * start adapting cli * add test for command building * add test for CLI for preproc, smooth... * add test for command building for stats * add test for command building for bms * rename function * start switching CLI * several fixes * more fix * keep switchingµ * fix * fix * linti * fixes * fixes * minor fixes * additional fixes * fix output ROI * visualize output in circle ci
1 parent 344838e commit f4b986f

26 files changed

+1305
-482
lines changed

.circleci/config.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,11 @@ jobs:
113113
/bids_dataset \
114114
/outputs/ds000001 \
115115
subject \
116-
--action default_model \
116+
default_model \
117117
--task balloonanalogrisktask \
118118
--space MNI152NLin2009cAsym \
119-
--verbosity 3
119+
--verbosity 3 \
120+
--skip_validation
120121
121122
cat /home/circleci/outputs/ds000001/derivatives/models/*.json
122123
@@ -130,10 +131,11 @@ jobs:
130131
/bids_dataset \
131132
/outputs/ds000001 \
132133
dataset \
133-
--action default_model \
134+
default_model \
134135
--task balloonanalogrisktask \
135136
--space MNI152NLin2009cAsym \
136-
--verbosity 3
137+
--verbosity 3 \
138+
--skip_validation
137139
138140
cat /home/circleci/outputs/ds000001/derivatives/models/*.json
139141
@@ -147,15 +149,17 @@ jobs:
147149
-v /tmp/workspace/data/ds000001:/bids_dataset \
148150
-v /home/circleci/outputs:/outputs \
149151
<< parameters.dh_orga >>/<< parameters.dh_repo >> \
150-
/outputs/ds000001 \
152+
/bids_dataset \
151153
/outputs/ds000001 \
152154
dataset \
153-
--action create_roi \
155+
create_roi \
154156
--roi_atlas wang \
155157
--roi_name V1v V1d \
156158
--space IXI549Space \
157159
--verbosity 3
158160
161+
cat /home/circleci/outputs
162+
159163
- store_artifacts:
160164
path: /home/circleci/outputs
161165

@@ -190,7 +194,7 @@ jobs:
190194
/bids_dataset \
191195
/outputs/ds000001 \
192196
subject \
193-
--action smooth \
197+
smooth \
194198
--task balloonanalogrisktask \
195199
--participant_label 01 02 \
196200
--space MNI152NLin2009cAsym \
@@ -212,10 +216,9 @@ jobs:
212216
/bids_dataset \
213217
/outputs/ds000001 \
214218
subject \
215-
--action stats \
219+
stats \
216220
--preproc_dir /outputs/ds000001/derivatives/bidspm-preproc \
217221
--model_file /models/model-balloonanalogrisktaskDefault_smdl.json \
218-
--ignore slicetiming \
219222
--space MNI152NLin2009cAsym \
220223
--skip_validation \
221224
--fwhm 0 \
@@ -235,7 +238,7 @@ jobs:
235238
/bids_dataset \
236239
/outputs/ds000001 \
237240
dataset \
238-
--action stats \
241+
stats \
239242
--preproc_dir /outputs/ds000001/derivatives/bidspm-preproc \
240243
--model_file /models/model-balloonanalogrisktaskDefault_smdl.json \
241244
--space MNI152NLin2009cAsym \

.flake8

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[flake8]
2-
max-line-length = 110
3-
max-complexity = 10
2+
max-line-length = 90
3+
max-complexity = 11
44
ignore = F841, D100, D101, D103, D104
55
exclude =
66
*build

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3939
- allow inter session contrasts to be computed at the subject level
4040
- improve naming of contrast to mention bids ses and run
4141

42+
* [ENH] add Bayesian model selection to the python CLI #1292 @Remi-Gau
4243

4344
### Changed
4445

46+
4547
* [ENH] align specification of F contrasts on the BIDS stats model: they should now be specified as a 2D matrix and not a 1D vector. #1276 @Remi-Gau
4648
* [DOC] change theme and structure of the documentation #1256 @Remi-Gau
4749
* [REF] Refactor and update CLI in #1096 @Remi-Gau
4850
* [ENH] {func}`getData` only loads anat data when requested #1257 @Remi-Gau
51+
* [ENH] the python CLI now uses sub-commands instead of the named parameter `--action` #1292 @Remi-Gau
4952

5053
### Deprecated
5154

demos/MoAE/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bidspm \
1919
$PWD/inputs/raw \
2020
$PWD/outputs/derivatives \
2121
subject \
22-
--action preprocess \
22+
preprocess \
2323
--participant_label 01 \
2424
--space individual IXI549Space \
2525
--task auditory \
@@ -37,7 +37,7 @@ bidspm \
3737
$PWD/inputs/fmriprep \
3838
$PWD/outputs/derivatives \
3939
subject \
40-
--action smooth \
40+
smooth \
4141
--participant_label 01 \
4242
--space '^.*MNI.*$' \
4343
--task auditory \
@@ -52,7 +52,7 @@ bidspm \
5252
$PWD/inputs/raw \
5353
$PWD/outputs/derivatives \
5454
dataset \
55-
--action default_model \
55+
default_model \
5656
--space IXI549Space \
5757
--task auditory \
5858
--verbosity 2 \
@@ -66,7 +66,7 @@ bidspm \
6666
$PWD/inputs/raw \
6767
$PWD/outputs/derivatives \
6868
subject \
69-
--action stats \
69+
stats \
7070
--preproc_dir $PWD/outputs/derivatives/bidspm-preproc \
7171
--model_file $PWD/models/model-MoAE_smdl.json \
7272
--fwhm 6
@@ -77,7 +77,7 @@ bidspm \
7777
$PWD/inputs/raw \
7878
$PWD/outputs/derivatives \
7979
subject \
80-
--action stats \
80+
stats \
8181
--preproc_dir $PWD/outputs/derivatives/bidspm-preproc \
8282
--model_file $PWD/outputs/derivatives/models/model-defaultAuditory_smdl.json \
8383
--fwhm 6
@@ -96,7 +96,7 @@ docker run -it --rm \
9696
/derivatives \
9797
subject \
9898
--task auditory \
99-
--action preprocess \
99+
preprocess \
100100
--fwhm 8
101101
```
102102

@@ -111,7 +111,7 @@ docker run -it --rm \
111111
/raw \
112112
/derivatives \
113113
subject \
114-
--action stats \
114+
stats \
115115
--preproc_dir /derivatives/bidspm-preproc \
116116
--model_file /models/model-MoAE_smdl.json \
117117
--fwhm 6

demos/MoAE/test_moae.m

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@
3131

3232
optionsFile = fullfile(WD, 'options', 'options_task-auditory.json');
3333

34-
space = {'individual'
34+
space = {
3535
'IXI549Space'
36+
'individual'
3637
'IXI549Space'
3738
'individual'};
38-
ignore = {{'unwarp'}
39-
{'unwarp', 'qa'}
39+
ignore = {{'unwarp', 'qa'}
40+
{'unwarp'}
4041
{''}
4142
{''}};
42-
43-
models = {fullfile(WD, 'models', 'model-MoAEindividual_smdl.json')
43+
models = {
4444
fullfile(WD, 'models', 'model-MoAE_smdl.json')
45+
fullfile(WD, 'models', 'model-MoAEindividual_smdl.json')
4546
fullfile(WD, 'models', 'model-MoAE_smdl.json')
4647
fullfile(WD, 'models', 'model-MoAEindividual_smdl.json')};
4748

@@ -65,14 +66,16 @@
6566
%% stats
6667
preproc_dir = fullfile(output_dir, 'bidspm-preproc');
6768

68-
% only specify the subject level model
69-
bidspm(bids_dir, output_dir, 'subject', ...
70-
'participant_label', {'01'}, ...
71-
'action', 'stats', ...
72-
'preproc_dir', preproc_dir, ...
73-
'model_file', models{iOption}, ...
74-
'options', optionsFile, ...
75-
'design_only', true);
69+
if ~bids.internal.is_octave() && ~ispc()
70+
% only specify the subject level model
71+
bidspm(bids_dir, output_dir, 'subject', ...
72+
'participant_label', {'01'}, ...
73+
'action', 'stats', ...
74+
'preproc_dir', preproc_dir, ...
75+
'model_file', models{iOption}, ...
76+
'options', optionsFile, ...
77+
'design_only', true);
78+
end
7679

7780
% specify, estimate model and contrasts, and view results
7881
bidspm(bids_dir, output_dir, 'subject', ...

demos/face_repetition/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bidspm \
1212
$PWD/outputs/raw \
1313
$PWD/outputs/derivatives \
1414
subject \
15-
--action preprocess \
15+
preprocess \
1616
--participant_label 01 \
1717
--space individual IXI549Space \
1818
--task facerepetition \
@@ -25,7 +25,7 @@ bidspm \
2525
$PWD/outputs/raw \
2626
$PWD/outputs/derivatives \
2727
subject \
28-
--action preprocess \
28+
preprocess \
2929
--space individual IXI549Space \
3030
--anat_only \
3131
--skip_validation
@@ -38,7 +38,7 @@ bidspm \
3838
$PWD/outputs/raw \
3939
$PWD/outputs/derivatives \
4040
subject \
41-
--action create_roi \
41+
create_roi \
4242
--roi_atlas wang \
4343
--roi_name MST hMT
4444
```
@@ -48,7 +48,7 @@ bidspm \
4848
$PWD/outputs/raw \
4949
$PWD/outputs/derivatives \
5050
subject \
51-
--action create_roi \
51+
create_roi \
5252
--roi_atlas hpcex \
5353
--roi_name MST MT
5454
```
@@ -65,7 +65,7 @@ docker run -it --rm \
6565
/raw \
6666
/derivatives \
6767
subject \
68-
--action create_roi \
68+
create_roi \
6969
--roi_atlas hcpex \
7070
--roi_name MST MT
7171
```

docs/source/conf.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,13 @@
8585
}
8686

8787
# We recommend adding the following config value.
88-
# Sphinx defaults to automatically resolve *unresolved* labels using all your Intersphinx mappings.
89-
# This behavior has unintended side-effects, namely that documentations local references can
88+
# Sphinx defaults to automatically resolve *unresolved* labels
89+
# using all your Intersphinx mappings.
90+
# This behavior has unintended side-effects,
91+
# namely that documentations local references can
9092
# suddenly resolve to an external location.
9193
# See also:
92-
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes
94+
# https://www.sphinx-doc.org/en/master/usage/extensions/intersphinx.html#confval-intersphinx_disabled_reftypes # noqa
9395
# intersphinx_disabled_reftypes = ["*"]
9496

9597
coverage_show_missing_items = True

docs/source/images/mermaid.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ graph TD
1717
batch_02 --> E[SPM12]
1818
end
1919

20-
CLI -->|--action results\n--participant-label 01 02\n--model_file smdl.json| bidsResults
20+
CLI -->|results\n--participant-label 01 02\n--model_file smdl.json| bidsResults

docs/source/installation/containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ docker run -it --rm \
4848
/derivatives \
4949
subject \
5050
--task auditory \
51-
--action preprocess \
51+
preprocess \
5252
--fwhm 8
5353
```
5454

@@ -68,7 +68,7 @@ docker run -it --rm \
6868
/raw \
6969
/derivatives \
7070
subject \
71-
--action stats \
71+
stats \
7272
--preproc_dir /derivatives/bidspm-preproc \
7373
--model_file /models/smdl.json \
7474
--fwhm 8

docs/source/stats/bids_stats_model.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ Subject level contrast averaging beta across runs
477477

478478
```{figure} ./images/gui_contrast_cross_session.png
479479
---
480-
name: contrast_subject
480+
name: contrast_subject_cross_sessions
481481
align: center
482482
---
483483
Subject level contrast averaging beta across runs

0 commit comments

Comments
 (0)