Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENH] add model selection to CLI #1121

Merged
merged 40 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9c7deac
update submod
Remi-Gau Aug 8, 2023
d3ad58e
[DATALAD] Recorded changes
Remi-Gau Aug 8, 2023
3fe68fc
Merge remote-tracking branch 'upstream/main' into bmc
Remi-Gau Aug 8, 2023
86be519
[DATALAD] Recorded changes
Remi-Gau Aug 8, 2023
877fe1c
minor work on cli
Remi-Gau Aug 8, 2023
17eaee4
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 8, 2023
eb29df5
fix some tests
Remi-Gau Aug 8, 2023
a8366bf
more fixes
Remi-Gau Aug 8, 2023
253cdc7
add folders
Remi-Gau Aug 8, 2023
86f5cc7
start implementing bms
Remi-Gau Aug 8, 2023
ff6e4e2
fix system test
Remi-Gau Aug 9, 2023
61a4751
loop over models
Remi-Gau Aug 9, 2023
7a81162
rm models
Remi-Gau Aug 9, 2023
201749b
generate models
Remi-Gau Aug 9, 2023
34a58b6
update bids matlab
Remi-Gau Aug 9, 2023
3edb174
Apply suggestions from code review
Remi-Gau Aug 9, 2023
fd2cc02
fix bug
Remi-Gau Aug 9, 2023
4e8227d
fix test
Remi-Gau Aug 9, 2023
dd4ec15
refacrtor
Remi-Gau Aug 9, 2023
da17b00
refactor
Remi-Gau Aug 9, 2023
c10d4fa
add basic error handling
Remi-Gau Aug 9, 2023
93eeef3
fix test
Remi-Gau Aug 9, 2023
2cd100c
fix and doc
Remi-Gau Aug 9, 2023
0cf78ff
fix
Remi-Gau Aug 9, 2023
9bad6bc
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Aug 9, 2023
f2d564d
move space to each action cli
Remi-Gau Aug 10, 2023
3792d28
add use_dummy_regressor arg
Remi-Gau Aug 10, 2023
71a9339
[DATALAD] Recorded changes
Remi-Gau Aug 10, 2023
5a55992
move space to each action cli
Remi-Gau Aug 10, 2023
17f0657
Merge branch 'tmp' into bmc
Remi-Gau Aug 10, 2023
6649cf0
[DATALAD] Recorded changes
Remi-Gau Aug 10, 2023
cba8f1d
update fields name, fix failing tests, add arg displaying function
Remi-Gau Aug 10, 2023
ae4418b
refactor CI
Remi-Gau Aug 10, 2023
5f7102e
FCI
Remi-Gau Aug 10, 2023
0db9412
smooth bms data
Remi-Gau Aug 10, 2023
f6098db
use the proper task
Remi-Gau Aug 10, 2023
843c032
use dummy regressor argument
Remi-Gau Aug 10, 2023
a673ccf
[DATALAD] Recorded changes
Remi-Gau Aug 10, 2023
8af559c
use proper argument
Remi-Gau Aug 10, 2023
0e2e5bb
fix passing or use fummy argument
Remi-Gau Aug 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/workflows/system_tests_bms.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%
% (C) Copyright 2023 bidspm developers

root_dir = getenv('GITHUB_WORKSPACE');

fprintf('\nroot dir is %s\n', root_dir);

addpath(fullfile(root_dir, 'spm12'));

cd(fullfile(root_dir, 'demos', 'bayes'));

run ds000114_run;
23 changes: 16 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ jobs:
os: [ubuntu-latest, macos-latest]
matlab: [R2022b]
include:
- test_type: system
script: bms
os: ubuntu-latest
matlab: R2022b
- test_type: unit
os: ubuntu-latest
matlab: R2022b
Expand All @@ -59,12 +63,6 @@ jobs:
if: matrix.test_type == 'system'
run: echo ${{ matrix.test_type }} test ${{ matrix.script }}

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get -y -qq update
sudo apt-get -y install unzip wget

- name: Install Node
uses: actions/setup-node@v3
with:
Expand All @@ -75,6 +73,14 @@ jobs:
with:
python-version: '3.11'

- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get -y -qq update
sudo apt-get -y install unzip wget git-annex
python -m pip install --upgrade pip setuptools
pip install datalad

- name: Clone bidspm
uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -104,6 +110,10 @@ jobs:
cd tests
make data

- name: Get data for BMS
if: matrix.script == 'bms'
run: make -C demos/bayes data_ds000114

- name: Install Moxunit and MOcov
run: |
git clone https://github.com/MOxUnit/MOxUnit.git --depth 1
Expand All @@ -130,7 +140,6 @@ jobs:
fail_ci_if_error: false
# token: ${{ secrets.CODECOV_TOKEN }} # not required but might help API rate limits


- name: Run system tests MATLAB ${{ matrix.script }}
if: matrix.test_type == 'system'
uses: matlab-actions/run-command@v1.2.1
Expand Down
61 changes: 40 additions & 21 deletions bidspm.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@
% (C) Copyright 2022 bidspm developers

args = defaultInputParser();
parse(args, varargin{:});
try
parse(args, varargin{:});
catch ME
displayArguments(varargin{:});
rethrow(ME);
end

action = args.Results.action;

Expand Down Expand Up @@ -45,7 +50,7 @@

case 'help'
system('bidspm --help');
help(fullfile(fileparts(mfilename('fullpath')), 'src', 'messages', 'bidspmHelp.m'));
help(fullfile(rootDir(), 'src', 'messages', 'bidspmHelp.m'));

case 'version'
versionBidspm();
Expand Down Expand Up @@ -77,9 +82,12 @@
case 'default_model'
cliDefaultModel(varargin{2:end});

case {'stats', 'contrasts', 'results'}
case {'stats', 'contrasts', 'results', 'specify_only'}
cliStats(varargin{2:end});

case {'bms'}
cliBayesModel(varargin{2:end});

case 'meaning_of_life'
fprintf('\n42\n\n');

Expand All @@ -94,12 +102,25 @@

end

function displayArguments(varargin)
disp('arguments passed were :');
for i = 1:numel(varargin)
fprintf('- ');
disp(varargin{i});
end
fprintf(1, '\n');
end

function value = rootDir()
value = fullfile(fileparts(mfilename('fullpath')));
end

%% low level actions
function versionBidspm()
try
versionNumber = getVersion();
catch
versionNumber = fileread(fullfile(fileparts(mfilename('fullpath')), 'version.txt'));
versionNumber = fileread(rootDir(), 'version.txt');
versionNumber = versionNumber(1:end - 1);
end
fprintf(1, '%s\n', versionNumber);
Expand Down Expand Up @@ -130,8 +151,6 @@ function initBidspm(dev)
% octave packages
installlist = {'io', 'statistics', 'image'};

thisDirectory = fileparts(mfilename('fullpath'));

global BIDSPM_INITIALIZED
global BIDSPM_PATHS

Expand All @@ -143,27 +162,27 @@ function initBidspm(dev)
end

% add bidspm source code
BIDSPM_PATHS = fullfile(thisDirectory);
BIDSPM_PATHS = fullfile(rootDir());
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
pathSep, ...
genpath(fullfile(thisDirectory, 'src')));
genpath(fullfile(rootDir(), 'src')));
if dev
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, pathSep, ...
fullfile(thisDirectory, 'tests', 'utils'));
fullfile(rootDir(), 'tests', 'utils'));
end

% for some reasons this folder was otherwise not added to the path in Octave
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
pathSep, ...
genpath(fullfile(thisDirectory, 'src', 'workflows', 'stats')));
genpath(fullfile(rootDir(), 'src', 'workflows', 'stats')));

% add library that do not have an set up script
libList = {'spmup'};

for i = 1:numel(libList)
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, ...
pathSep, ...
genpath(fullfile(thisDirectory, 'lib', libList{i})));
genpath(fullfile(rootDir(), 'lib', libList{i})));
end

libList = {'mancoreg', ...
Expand All @@ -173,23 +192,23 @@ function initBidspm(dev)
'utils'};
for i = 1:numel(libList)
BIDSPM_PATHS = cat(2, BIDSPM_PATHS, pathSep, ...
fullfile(thisDirectory, 'lib', libList{i}));
fullfile(rootDir(), 'lib', libList{i}));
end

BIDSPM_PATHS = cat(2, BIDSPM_PATHS, pathSep, ...
fullfile(thisDirectory, 'lib', 'brain_colours', 'code'));
fullfile(rootDir(), 'lib', 'brain_colours', 'code'));

BIDSPM_PATHS = cat(2, BIDSPM_PATHS, pathSep, ...
fullfile(thisDirectory, 'lib', 'riksneurotools', 'GLM'));
fullfile(rootDir(), 'lib', 'riksneurotools', 'GLM'));

addpath(BIDSPM_PATHS, '-begin');

silenceOctaveWarning();

% add library that have a set up script
run(fullfile(thisDirectory, 'lib', 'CPP_ROI', 'initCppRoi'));
run(fullfile(thisDirectory, 'lib', 'spm_2_bids', 'init_spm_2_bids'));
run(fullfile(thisDirectory, 'lib', 'octache', 'setup'));
run(fullfile(rootDir(), 'lib', 'CPP_ROI', 'initCppRoi'));
run(fullfile(rootDir(), 'lib', 'spm_2_bids', 'init_spm_2_bids'));
run(fullfile(rootDir(), 'lib', 'octache', 'setup'));

checkDependencies(opt);
printCredits(opt);
Expand Down Expand Up @@ -248,8 +267,6 @@ function uninitBidspm()

% (C) Copyright 2021 bidspm developers

thisDirectory = fileparts(mfilename('fullpath'));

global BIDSPM_INITIALIZED
global BIDSPM_PATHS

Expand All @@ -258,7 +275,7 @@ function uninitBidspm()
return

else
run(fullfile(thisDirectory, 'lib', 'CPP_ROI', 'uninitCppRoi'));
run(fullfile(rootDir(), 'lib', 'CPP_ROI', 'uninitCppRoi'));
rmpath(BIDSPM_PATHS);
spm('Clean');
spm('Quit');
Expand Down Expand Up @@ -350,7 +367,9 @@ function update()
'default_model'; ...
'stats'; ...
'contrasts'; ...
'results'};
'results'; ...
'specify_only', ...
'bms'};

end

Expand Down
2 changes: 1 addition & 1 deletion demos/MoAE/moae_01_bids_app.m
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
bidspm(bids_dir, output_dir, 'subject', ...
'participant_label', {subject_label}, ...
'action', 'preprocess', ...
'task', {'auditory'}, ...
'task', 'auditory', ...
'ignore', {'unwarp', 'slicetiming'}, ...
'space', {'IXI549Space'}, ...
'fwhm', 6, ...
Expand Down
6 changes: 3 additions & 3 deletions demos/MoAE/test_moae.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

bidspm();
if download_data
download_moae_ds(download_data, clean);
download_moae_ds(download_data, clean); %#ok<*UNRCH>
end

warning('off', 'SPM:noDisplay');
Expand Down Expand Up @@ -52,12 +52,12 @@
%% preproc
bids_dir = fullfile(WD, 'inputs', 'raw');
output_dir = fullfile(tempname, 'outputs', 'derivatives');
mkdir(output_dir);
spm_mkdir(output_dir);

bidspm(bids_dir, output_dir, 'subject', ...
'participant_label', {'01'}, ...
'action', 'preprocess', ...
'task', {'auditory'}, ...
'task', 'auditory', ...
'ignore', ignore{iOption}, ...
'space', space(iOption), ...
'options', optionsFile);
Expand Down
11 changes: 11 additions & 0 deletions demos/bayes/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.PHONY: clean data data_ds000001

data_ds000114:
mkdir -p inputs
cd inputs && datalad install ///openneuro/ds000114
cd inputs && datalad install ///openneuro-derivatives/ds000114-fmriprep
cd inputs/ds000114-fmriprep && datalad get sub-*/anat/*MNI152NLin2009cAsym*desc-preproc*.nii.gz -J 12
cd inputs/ds000114-fmriprep && datalad get sub-*/ses-*/func/*tsv -J 12
cd inputs/ds000114-fmriprep && datalad get sub-*/ses-*/func/*json -J 12
cd inputs/ds000114-fmriprep && datalad get sub-*/ses-*/func/*overtverbgeneration*MNI152NLin2009cAsym*_mask.nii.gz -J 12
cd inputs/ds000114-fmriprep && datalad get sub-*/ses-*/func/*overtverbgeneration*MNI152NLin2009cAsym*desc-preproc*bold.nii.gz -J 12
Loading
Loading