Skip to content

Commit b617880

Browse files
authored
[FIX] pass dataset level to stats actions when using python CLI (#1258)
* refactor to improve testing python CLI * fix links * add dataset level analysis using docker * pin dependencies for containers and pass options to ignore nidm in circle ci * use local files to build apptainer image * fci * fix path * pass options through CLI * typo * run default model in CI * add README to apptainer def * fix default * add submodules * glob * fci * python CLI fixes * use absolute path * fix test * fix tests * show options in debug mode * fix saveOptions * fix * do not use nidm for run and subject level for ds000001 * mount options
1 parent c29610e commit b617880

32 files changed

+509
-116
lines changed

.circleci/config.yml

Lines changed: 78 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
- data/ds000001
7676
- data/ds000001-fmriprep
7777

78-
test:
78+
default_model:
7979
machine:
8080
image: ubuntu-2204:2022.10.2
8181

@@ -87,13 +87,53 @@ jobs:
8787
- run: mkdir -p ${HOME}/outputs/ds000001/derivatives
8888

8989
- run:
90-
name: print version
90+
name: default model subject level
9191
command: |
9292
user_name=cpplab
9393
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
9494
docker run -ti --rm \
9595
-v /tmp/workspace/data/ds000001:/bids_dataset \
96-
${user_name}/${repo_name} --version
96+
-v ${HOME}/outputs:/outputs \
97+
${user_name}/${repo_name} \
98+
/bids_dataset \
99+
/outputs/ds000001 \
100+
subject \
101+
--action default_model \
102+
--task balloonanalogrisktask \
103+
--space MNI152NLin2009cAsym \
104+
--verbosity 3
105+
106+
cat ${HOME}/outputs/ds000001/derivatives/models/*.json
107+
108+
- run:
109+
name: default model dataset level
110+
command: |
111+
user_name=cpplab
112+
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
113+
docker run -ti --rm \
114+
-v /tmp/workspace/data/ds000001:/bids_dataset \
115+
-v ${HOME}/outputs:/outputs \
116+
${user_name}/${repo_name} \
117+
/bids_dataset \
118+
/outputs/ds000001 \
119+
dataset \
120+
--action default_model \
121+
--task balloonanalogrisktask \
122+
--space MNI152NLin2009cAsym \
123+
--verbosity 3
124+
125+
cat ${HOME}/outputs/ds000001/derivatives/models/*.json
126+
127+
stats:
128+
machine:
129+
image: ubuntu-2204:2022.10.2
130+
131+
steps:
132+
- attach_workspace:
133+
at: /tmp/workspace
134+
- run: docker load -i /tmp/workspace/docker/image.tar
135+
136+
- run: mkdir -p ${HOME}/outputs/ds000001/derivatives
97137

98138
- run:
99139
name: smooth
@@ -112,21 +152,21 @@ jobs:
112152
--participant_label 01 02 \
113153
--space MNI152NLin2009cAsym \
114154
--fwhm 8 \
115-
--verbosity 2
116-
no_output_timeout: 6h
155+
--verbosity 3
117156
118-
# needed to access the model
157+
# needed to access the model
119158
- checkout
120159

121160
- run:
122-
name: stats
161+
name: stats subject level
123162
command: |
124163
user_name=cpplab
125164
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
126165
docker run -ti --rm \
127166
-v /tmp/workspace/data/ds000001:/bids_dataset \
128167
-v ${HOME}/outputs:/outputs \
129168
-v ~/project/demos/openneuro/models:/models \
169+
-v ~/project/demos/openneuro/options:/options \
130170
${user_name}/${repo_name} \
131171
/bids_dataset \
132172
/outputs/ds000001 \
@@ -137,11 +177,33 @@ jobs:
137177
--ignore slicetiming \
138178
--space MNI152NLin2009cAsym \
139179
--skip_validation \
140-
--fwhm 8 \
180+
--fwhm 0 \
141181
--participant_label 01 02 \
142-
--verbosity 2
143-
no_output_timeout: 6h
182+
--verbosity 3 \
183+
--options /options/ds000001.json
144184
185+
- run:
186+
name: stats group level
187+
command: |
188+
user_name=cpplab
189+
repo_name=$(echo "${CIRCLE_PROJECT_REPONAME}" | tr '[:upper:]' '[:lower:]')
190+
docker run -ti --rm \
191+
-v /tmp/workspace/data/ds000001:/bids_dataset \
192+
-v ${HOME}/outputs:/outputs \
193+
-v ~/project/demos/openneuro/models:/models \
194+
-v ~/project/demos/openneuro/options:/options \
195+
${user_name}/${repo_name} \
196+
/bids_dataset \
197+
/outputs/ds000001 \
198+
dataset \
199+
--action stats \
200+
--preproc_dir /outputs/ds000001/derivatives/bidspm-preproc \
201+
--model_file /models/model-balloonanalogrisktaskDefault_smdl.json \
202+
--space MNI152NLin2009cAsym \
203+
--skip_validation \
204+
--fwhm 0 \
205+
--verbosity 3 \
206+
--options /options/ds000001.json
145207
146208
deploy:
147209

@@ -187,14 +249,18 @@ workflows:
187249
jobs:
188250
- build
189251
- get_data
190-
- test:
252+
- default_model:
253+
requires:
254+
- build
255+
- get_data
256+
- stats:
191257
requires:
192258
- build
193259
- get_data
194260
- deploy:
195261
context:
196262
- DOCKER_HUB
197263
requires:
198-
- test
264+
- build
199265

200266
# VS Code Extension Version: 1.5.1

.github/workflows/apptainer_build.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ jobs:
1717
runs-on: ubuntu-latest
1818
steps:
1919
- uses: actions/checkout@v4
20+
with:
21+
submodules: recursive
22+
fetch-depth: 0
2023

2124
- uses: eWaterCycle/setup-apptainer@v2
2225
with:

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
matlab: R2023b
6666
mode: slow
6767
- test_type: unit
68-
os: macos-latest
68+
os: macos-13
6969
matlab: R2023b
7070
mode: fast
7171
fail-fast: false

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ skipped_roi_*.tsv
2929
CHANGES
3030
README
3131
tests/data/tsv_files/moae_results_table.tsv
32+
htmlcov
3233

3334
# Project specific
3435
onsets*_events.mat
@@ -48,6 +49,8 @@ src/bidspm/_version.py
4849
**/__pycache__
4950
**/build
5051
.coverage
52+
.pytest_cache
53+
.tox
5154

5255
.mypy_cache
5356

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM bids/base_validator
1+
FROM bids/base_validator:1.13.1
22

33
ARG DEBIAN_FRONTEND="noninteractive"
44

@@ -48,6 +48,7 @@ WORKDIR /home/neuro
4848
COPY . /home/neuro/bidspm
4949
WORKDIR /home/neuro/bidspm
5050
RUN pip install --no-cache-dir --upgrade pip && \
51+
pip3 --no-cache-dir install -r requirements.txt && \
5152
pip3 --no-cache-dir install . && \
5253
octave --no-gui --eval "addpath('/opt/spm12/'); savepath ();" && \
5354
octave --no-gui --eval "addpath(pwd); savepath(); bidspm(); path"

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ coverage: ## use coverage
108108
coverage erase
109109
coverage run --source src -m pytest
110110
coverage report -m
111+
coverage html
111112

112113
################################################################################
113114
# DOCKER

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ To start using bidspm, you just need to initialize it for the current MATLAB / O
4040
bidspm()
4141
```
4242

43-
Please see our [documentation](https://bidspm.readthedocs.io/en/latest/installation.html) for more info.
43+
Please see our [documentation](https://bidspm.readthedocs.io/en/latest/installation/index.html) for more info.
4444

4545
## Usage
4646

bidspm.def

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
BootStrap: docker
2-
From: bids/base_validator
2+
From: bids/base_validator:1.13.1
3+
4+
%files
5+
pyproject.toml /opt/bidspm/pyproject.toml
6+
requirements.txt /opt/bidspm/requirements.txt
7+
README.md /opt/bidspm/README.md
8+
bidspm.m /opt/bidspm/bidspm.m
9+
src /opt/bidspm/src
10+
lib /opt/bidspm/lib
11+
.git /opt/bidspm/.git
312

413
%post
514
apt-get -qq update
@@ -38,10 +47,9 @@ From: bids/base_validator
3847
make -C /opt/spm12/src PLATFORM=octave install
3948
ln -s /opt/spm12/bin/spm12-octave /usr/local/bin/spm12
4049

41-
mkdir /opt/bidspm
42-
git clone --recurse-submodules https://github.com/cpp-lln-lab/bidspm.git /opt/bidspm
43-
pip install --no-cache-dir --upgrade pip && \
44-
pip3 --no-cache-dir install /opt/bidspm && \
50+
pip install --upgrade pip
51+
pip install -r /opt/bidspm/requirements.txt
52+
pip install /opt/bidspm
4553
octave --no-gui --eval "addpath('/opt/spm12/'); savepath ('/usr/share/octave/site/m/startup/octaverc');" && \
4654
octave --no-gui --eval "addpath('/opt/bidspm/'); savepath('/usr/share/octave/site/m/startup/octaverc'); bidspm(); path"
4755

bidspm.m

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -179,15 +179,6 @@ function initBidspm(dev)
179179
pathSep, ...
180180
genpath(fullfile(rootDir(), 'src', 'workflows', 'stats')));
181181

182-
% add library that do not have an set up script
183-
libList = {'spmup'};
184-
185-
for i = 1:numel(libList)
186-
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
187-
pathSep, ...
188-
genpath(fullfile(rootDir(), 'lib', libList{i})));
189-
end
190-
191182
libList = {'mancoreg', ...
192183
'bids-matlab', ...
193184
'slice_display', ...
@@ -270,7 +261,7 @@ function updateMacstoolbox()
270261
end
271262

272263
if exist(target_dir, 'dir') == 7
273-
msg = sprintf('updating MACS toolbox: ');
264+
msg = sprintf('updating MACS toolbox\n');
274265
fprintf(1, msg);
275266
[status, cmdout] = system(sprintf('git -C %s pull', target_dir));
276267
if status ~= 0

demos/openneuro/Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ data_ds000001:
1818
mkdir -p inputs
1919
cd inputs && datalad install ///openneuro/ds000001
2020
cd inputs && datalad install ///openneuro-derivatives/ds000001-fmriprep
21-
cd inputs/ds000001 && datalad get sub-0[1-5] -J 3
22-
cd inputs/ds000001-fmriprep && datalad get sub-0[1-5]/func/*tsv -J 12
23-
cd inputs/ds000001-fmriprep && datalad get sub-0[1-5]/func/*json -J 12
24-
cd inputs/ds000001-fmriprep && datalad get sub-0[1-5]/func/*MNI*desc-*bold.nii.gz -J 12
25-
cd inputs/ds000001-fmriprep && datalad get sub-0[1-5]/anat/*MNI*desc-preproc*.nii.gz -J 12
21+
cd inputs/ds000001 && datalad get sub-0[1-2] -J 3
22+
cd inputs/ds000001-fmriprep && datalad get sub-0[1-2]/func/*tsv -J 12
23+
cd inputs/ds000001-fmriprep && datalad get sub-0[1-2]/func/*json -J 12
24+
cd inputs/ds000001-fmriprep && datalad get sub-0[1-2]/anat/*MNI*desc-preproc*.nii.gz -J 12
25+
cd inputs/ds000001-fmriprep && datalad get sub-0[1-2]/func/*MNI*desc-preproc*.nii.gz -J 12
26+
cd inputs/ds000001-fmriprep && datalad get sub-0[1-2]/func/*MNI*desc-*bold.nii.gz -J 12
2627

2728
data_ds000114:
2829
mkdir -p inputs

0 commit comments

Comments
 (0)