From 23c15be0e5eb8ccf35f1dc7bb1d3a339ffdf6479 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 16:39:33 +0200 Subject: [PATCH 1/8] update CI and makefile --- .github/workflows/matlab_workflow_script.m | 7 ++++++- .github/workflows/run_tests.yml | 13 ++++--------- .github/workflows/run_tests_matlab.yml | 5 ----- tests/.gitignore | 3 ++- tests/Makefile | 1 + tests/miss_hit.cfg | 2 ++ 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/.github/workflows/matlab_workflow_script.m b/.github/workflows/matlab_workflow_script.m index 780cbb9f8..3cfb299dc 100644 --- a/.github/workflows/matlab_workflow_script.m +++ b/.github/workflows/matlab_workflow_script.m @@ -9,7 +9,12 @@ cd(fullfile(root_dir, 'MOxUnit', 'MOxUnit')); run moxunit_set_path(); -cd(fullfile(root_dir)); +cd(root_dir); initCppSpm(); addpath(fullfile(root_dir, 'tests', 'utils')); + +cd demos/MoAE; +download_moae_ds(true); + +cd(root_dir); run run_tests(); diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index faf88c499..d8c6f7279 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -63,19 +63,14 @@ jobs: - name: Update octave path run: | - octave $OCTFLAGS --eval "initCppSpm; savepath();" - octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'tests', 'utils')); savepath();" + octave $OCTFLAGS --eval "initCppSpm; savepath(); exit;" + octave $OCTFLAGS --eval "addpath(fullfile(pwd, 'tests', 'utils')); savepath(); exit;" - name: Prepare data run: | - inputs_folder='demos/MoAE/inputs/' - mkdir $inputs_folder - curl http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip --output $inputs_folder'MoAEpilot.zip' - unzip $inputs_folder'MoAEpilot.zip' -d $inputs_folder - mv $inputs_folder/MoAEpilot $inputs_folder/raw + octave $OCTFLAGS --eval "initCppSpm; cd demos/MoAE; download_moae_ds(true); exit;" cd tests - sh createDummyDataSet.sh - cd .. + make data - name: Run tests run: | diff --git a/.github/workflows/run_tests_matlab.yml b/.github/workflows/run_tests_matlab.yml index 8839d09b0..8a4a8d1de 100644 --- a/.github/workflows/run_tests_matlab.yml +++ b/.github/workflows/run_tests_matlab.yml @@ -39,11 +39,6 @@ jobs: - name: Prepare data run: | - inputs_folder='demos/MoAE/inputs/' - mkdir $inputs_folder - curl http://www.fil.ion.ucl.ac.uk/spm/download/data/MoAEpilot/MoAEpilot.bids.zip --output $inputs_folder'MoAEpilot.zip' - unzip $inputs_folder'MoAEpilot.zip' -d $inputs_folder - mv $inputs_folder/MoAEpilot $inputs_folder/raw cd tests make data diff --git a/tests/.gitignore b/tests/.gitignore index 12808bdc6..e0a49028a 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -3,4 +3,5 @@ */*.json group/* dummyData/derivatives/cpp_spm*/sub-*/ -dummyData/copy/ \ No newline at end of file +dummyData/copy/ +bids-examples diff --git a/tests/Makefile b/tests/Makefile index fb2856680..4e2841488 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -12,6 +12,7 @@ data: rm -f bids-examples/.gitkeep git clone https://github.com/bids-standard/bids-examples.git --depth 1 cp bids-examples/synthetic/dataset_description.json bids-examples/synthetic/derivatives/fmriprep + touch bids-examples/.gitkeep clean_openneuro: rm -rf openneuro/* diff --git a/tests/miss_hit.cfg b/tests/miss_hit.cfg index 684e5239e..0b1582111 100644 --- a/tests/miss_hit.cfg +++ b/tests/miss_hit.cfg @@ -1 +1,3 @@ regex_function_name: "(test(_unit){0,1}_[a-z]+|[a-z]+)(([A-Z]){1}[A-Za-z0-9]+)*" + +exclude_dir: "bids-examples" From 3d0842d0294962eb726bfaef9dc7e9644481e5ac Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 16:43:47 +0200 Subject: [PATCH 2/8] update gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 9eb4afab8..4858f59cc 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,9 @@ venv/* ## visual studio code .vscode +cfg +group + ## MATLAB / OCTAVE gitignore template # From : https://github.com/github/gitignore/blob/master/Global/MATLAB.gitignore From 67f08f5f13e6c0f2f006844a4015ab841dbe8e82 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 16:44:49 +0200 Subject: [PATCH 3/8] only update submod on dev --- .github/workflows/update_submodules.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/update_submodules.yml b/.github/workflows/update_submodules.yml index 3505a04fc..ee2be7078 100644 --- a/.github/workflows/update_submodules.yml +++ b/.github/workflows/update_submodules.yml @@ -30,8 +30,6 @@ name: update submodules on: push: branches: - - main - - master - dev schedule: - cron: "0 0 1 * *" From cf90f250ee65483ee0dfacf1aa26d1be557cdaa8 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 16:51:09 +0200 Subject: [PATCH 4/8] add gitkeep --- tests/bids-examples/.gitkeep | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/bids-examples/.gitkeep diff --git a/tests/bids-examples/.gitkeep b/tests/bids-examples/.gitkeep new file mode 100644 index 000000000..e69de29bb From 89b09722465c850a6088b8cf5258c8e08c8426cc Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 17:00:26 +0200 Subject: [PATCH 5/8] fix data dowload --- demos/MoAE/download.m | 65 +++++++++++++++++++++++++++++++++++ demos/MoAE/download_moae_ds.m | 7 ++-- 2 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 demos/MoAE/download.m diff --git a/demos/MoAE/download.m b/demos/MoAE/download.m new file mode 100644 index 000000000..2ce072175 --- /dev/null +++ b/demos/MoAE/download.m @@ -0,0 +1,65 @@ +function filename = download(URL, output_dir, verbose) + % + % USAGE:: + % + % filename = download(URL, output_dir, verbose) + % + % (C) Copyright 2021 Remi Gau + if nargin < 2 + output_dir = pwd; + end + + msg = sprintf('Downloading dataset from:\n %s\n\n', URL); + printToScreen(msg, verbose); + + tokens = regexp(URL, '/', 'split'); + protocol = tokens{1}; + + filename = tokens{end}; + + if exist(filename, 'file') + delete(filename); + end + + if strcmp(protocol, 'http:') + + if isunix() + if verbose + system(sprintf('wget %s', URL)); + else + system(sprintf('wget -q %s', URL)); + end + else + urlwrite(URL, filename); + end + + % move file in case it was not downloaded in the root dir + if ~exist(fullfile(output_dir, filename), 'file') + printToScreen([filename ' --> ' output_dir], verbose); + movefile(filename, fullfile(output_dir, filename)); + end + filename = fullfile(output_dir, filename); + + else + + ftp_server = tokens{3}; + ftpobj = ftp(ftp_server); + + filename = strjoin(tokens(4:end), '/'); + filename = mget(ftpobj, filename, output_dir); + + end + + if iscell(filename) + filename = filename{1}; + end + + printToScreen(' Done\n\n', verbose); + +end + +function printToScreen(msg, verbose) + if verbose + fprintf(1, msg); + end +end diff --git a/demos/MoAE/download_moae_ds.m b/demos/MoAE/download_moae_ds.m index 03fc0621b..e4425c184 100644 --- a/demos/MoAE/download_moae_ds.m +++ b/demos/MoAE/download_moae_ds.m @@ -17,13 +17,12 @@ function download_moae_ds(downloadData) spm_mkdir(fullfile(working_directory, 'inputs')); %% Get data - fprintf('%-10s:', 'Downloading dataset...'); - urlwrite(URL, 'MoAEpilot.zip'); - fprintf(1, ' Done\n\n'); + filename = download(URL, fullfile(working_directory, 'inputs'), true); fprintf('%-10s:', 'Unzipping dataset...'); - unzip('MoAEpilot.zip'); + unzip(filename); movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw')); + delete(filename) fprintf(1, ' Done\n\n'); end From ae3ce6f20a66d53e247e0d673a6f8de4c0dbc2ae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 9 May 2022 15:41:54 +0000 Subject: [PATCH 6/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- demos/MoAE/download_moae_ds.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/MoAE/download_moae_ds.m b/demos/MoAE/download_moae_ds.m index e4425c184..4865bfefc 100644 --- a/demos/MoAE/download_moae_ds.m +++ b/demos/MoAE/download_moae_ds.m @@ -22,7 +22,7 @@ function download_moae_ds(downloadData) fprintf('%-10s:', 'Unzipping dataset...'); unzip(filename); movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw')); - delete(filename) + delete(filename); fprintf(1, ' Done\n\n'); end From 4830b2c3ed4e6ecddc35cdd6719f1359c23bac10 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 17:42:41 +0200 Subject: [PATCH 7/8] lint --- demos/MoAE/download.m | 8 ++++---- demos/MoAE/download_moae_ds.m | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/demos/MoAE/download.m b/demos/MoAE/download.m index 2ce072175..25df0f0ed 100644 --- a/demos/MoAE/download.m +++ b/demos/MoAE/download.m @@ -10,7 +10,7 @@ end msg = sprintf('Downloading dataset from:\n %s\n\n', URL); - printToScreen(msg, verbose); + print_to_screen(msg, verbose); tokens = regexp(URL, '/', 'split'); protocol = tokens{1}; @@ -35,7 +35,7 @@ % move file in case it was not downloaded in the root dir if ~exist(fullfile(output_dir, filename), 'file') - printToScreen([filename ' --> ' output_dir], verbose); + print_to_screen([filename ' --> ' output_dir], verbose); movefile(filename, fullfile(output_dir, filename)); end filename = fullfile(output_dir, filename); @@ -54,11 +54,11 @@ filename = filename{1}; end - printToScreen(' Done\n\n', verbose); + print_to_screen(' Done\n\n', verbose); end -function printToScreen(msg, verbose) +function print_to_screen(msg, verbose) if verbose fprintf(1, msg); end diff --git a/demos/MoAE/download_moae_ds.m b/demos/MoAE/download_moae_ds.m index e4425c184..4865bfefc 100644 --- a/demos/MoAE/download_moae_ds.m +++ b/demos/MoAE/download_moae_ds.m @@ -22,7 +22,7 @@ function download_moae_ds(downloadData) fprintf('%-10s:', 'Unzipping dataset...'); unzip(filename); movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw')); - delete(filename) + delete(filename); fprintf(1, ' Done\n\n'); end From 9cc7d0e144bb7482a51bd0381bdd15dacdafdb97 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Mon, 9 May 2022 17:55:00 +0200 Subject: [PATCH 8/8] adapt for octave --- demos/MoAE/download_moae_ds.m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/demos/MoAE/download_moae_ds.m b/demos/MoAE/download_moae_ds.m index 4865bfefc..d2296264a 100644 --- a/demos/MoAE/download_moae_ds.m +++ b/demos/MoAE/download_moae_ds.m @@ -21,8 +21,14 @@ function download_moae_ds(downloadData) fprintf('%-10s:', 'Unzipping dataset...'); unzip(filename); - movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw')); - delete(filename); + if isOctave() + movefile(fullfile(working_directory, 'inputs', 'MoAEpilot'), ... + fullfile(working_directory, 'inputs', 'raw')); + delete(filename); + else + movefile('MoAEpilot', fullfile(working_directory, 'inputs', 'raw')); + delete(filename); + end fprintf(1, ' Done\n\n'); end