From 3609466627c27b9d47cb0ec90cb4d80098645610 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 6 Sep 2020 08:27:27 +0200 Subject: [PATCH 1/5] add utils tests --- src/convertSourceToRaw.m | 2 +- src/{ => subfun}/checkCppBidsDependencies.m | 0 src/{ => subfun}/printCreditsCppBids.m | 0 tests/test_utils.m | 15 +++++++++++++++ 4 files changed, 16 insertions(+), 1 deletion(-) rename src/{ => subfun}/checkCppBidsDependencies.m (100%) rename src/{ => subfun}/printCreditsCppBids.m (100%) create mode 100644 tests/test_utils.m diff --git a/src/convertSourceToRaw.m b/src/convertSourceToRaw.m index c70854a7..bfc846ba 100644 --- a/src/convertSourceToRaw.m +++ b/src/convertSourceToRaw.m @@ -10,7 +10,7 @@ function convertSourceToRaw(cfg) % Only covers func folder at the moment sourceDir = fullfile(cfg.dir.output, 'source'); - rawDir = fullfile(cfg.dir.output, 'rawdata'); + rawDir = fullfile(cfg.dir.output, 'raw'); % add dummy README and CHANGE file copyfile(fullfile( ... diff --git a/src/checkCppBidsDependencies.m b/src/subfun/checkCppBidsDependencies.m similarity index 100% rename from src/checkCppBidsDependencies.m rename to src/subfun/checkCppBidsDependencies.m diff --git a/src/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m similarity index 100% rename from src/printCreditsCppBids.m rename to src/subfun/printCreditsCppBids.m diff --git a/tests/test_utils.m b/tests/test_utils.m new file mode 100644 index 00000000..09f1b2e4 --- /dev/null +++ b/tests/test_utils.m @@ -0,0 +1,15 @@ +function test_suite = test_utils %#ok<*STOUT> + try % assignment of 'localfunctions' is necessary in Matlab >= 2016 + test_functions = localfunctions(); %#ok<*NASGU> + catch % no problem; early Matlab versions can use initTestSuite fine + end + initTestSuite; +end + +function test_utilsBasic() + + printCreditsCppBids(); + + checkCppBidsDependencies(); + +end From 44bf72f2dfa2470924eb8a2cad2dcf2d5c5eb0e4 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 6 Sep 2020 08:40:51 +0200 Subject: [PATCH 2/5] add version.txt file --- src/createFilename.m | 12 ++++++------ src/subfun/printCreditsCppBids.m | 5 +++-- tests/test_getIsQuestionToAsk.m | 10 +++++----- tests/test_removeDateSuffix.m | 14 +++++++------- tests/test_utils.m | 2 ++ version.txt | 1 + 6 files changed, 24 insertions(+), 20 deletions(-) create mode 100644 version.txt diff --git a/src/createFilename.m b/src/createFilename.m index 6e3f2ab6..5a9a5da7 100644 --- a/src/createFilename.m +++ b/src/createFilename.m @@ -105,7 +105,7 @@ 'echo', ... 'phaseEncodingDirection', ... 'reconstruction', ... - 'recording', ... + 'recording' ... }; targetFields = { ... @@ -114,7 +114,7 @@ 'echo', ... 'dir', ... 'rec', ... - 'recording', ... + 'recording' ... }; for iField = 1:numel(fields2Check) @@ -146,10 +146,10 @@ pattern = cfg.fileName.pattern; runSuffix = cfg.fileName.suffix.run; - acqSuffix = cfg.fileName.suffix.acquisition ; - ceSuffix = cfg.fileName.suffix.contrastEnhancement ; - dirSuffix = cfg.fileName.suffix.phaseEncodingDirection ; - recSuffix = cfg.fileName.suffix.reconstruction ; + acqSuffix = cfg.fileName.suffix.acquisition; + ceSuffix = cfg.fileName.suffix.contrastEnhancement; + dirSuffix = cfg.fileName.suffix.phaseEncodingDirection; + recSuffix = cfg.fileName.suffix.reconstruction; echoSuffix = cfg.fileName.suffix.echo; recordingSuffix = cfg.fileName.suffix.recording; diff --git a/src/subfun/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m index ab1e19d8..f727d535 100644 --- a/src/subfun/printCreditsCppBids.m +++ b/src/subfun/printCreditsCppBids.m @@ -1,4 +1,7 @@ function printCreditsCppBids(cfg) + + version = fileread(fullfile(fileparts(mfilename('fullpath')),... + '..', '..', 'version.txt')); verbose = true; if ~isempty(cfg) && isfield(cfg, 'verbose') && ~isempty(cfg.verbose) @@ -7,8 +10,6 @@ function printCreditsCppBids(cfg) if verbose - version = '0.0.1'; - contributors = { ... 'Rémi Gau', ... 'Marco Barilari', ... diff --git a/tests/test_getIsQuestionToAsk.m b/tests/test_getIsQuestionToAsk.m index 3be47593..632668c6 100644 --- a/tests/test_getIsQuestionToAsk.m +++ b/tests/test_getIsQuestionToAsk.m @@ -9,10 +9,10 @@ function test_isPositiveIntegerBasic() questions.questionsToAsk = { ... - [], 1 ; ... - [], 0 ; ... - [], 1 ; ... - [], 0 ; ... + [], 1; ... + [], 0; ... + [], 1; ... + [], 0; ... }; responses = { ... @@ -24,6 +24,6 @@ function test_isPositiveIntegerBasic() isQuestionToAsk = getIsQuestionToAsk(questions, responses); - assertEqual(isQuestionToAsk, [false;false;true;false]); + assertEqual(isQuestionToAsk, [false; false; true; false]); end diff --git a/tests/test_removeDateSuffix.m b/tests/test_removeDateSuffix.m index 13c25e1a..67aa2a43 100644 --- a/tests/test_removeDateSuffix.m +++ b/tests/test_removeDateSuffix.m @@ -23,13 +23,13 @@ function test_removeDateSuffixBasic() stimNameZipped = 'test2_stim_date-202008050730.tsv.gz'; filesToProcess = { ... - boldName ; - boldName2 ; - boldName3 ; - jsonName ; - eventsName ; - stimName ; - stimNameZipped ; + boldName; + boldName2; + boldName3; + jsonName; + eventsName; + stimName; + stimNameZipped; }; % create new files for new tests diff --git a/tests/test_utils.m b/tests/test_utils.m index 09f1b2e4..48a7e2bb 100644 --- a/tests/test_utils.m +++ b/tests/test_utils.m @@ -7,6 +7,8 @@ end function test_utilsBasic() + + cfg.verbose = true; printCreditsCppBids(); diff --git a/version.txt b/version.txt new file mode 100644 index 00000000..60453e69 --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +v1.0.0 \ No newline at end of file From c0d327b8c9b705c185d99bf6441726220941fd89 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 6 Sep 2020 08:50:06 +0200 Subject: [PATCH 3/5] fix path issue --- src/subfun/checkCppBidsDependencies.m | 2 +- src/subfun/printCreditsCppBids.m | 4 ++-- tests/test_utils.m | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/subfun/checkCppBidsDependencies.m b/src/subfun/checkCppBidsDependencies.m index 03dfd92f..dc752114 100644 --- a/src/subfun/checkCppBidsDependencies.m +++ b/src/subfun/checkCppBidsDependencies.m @@ -12,7 +12,7 @@ function checkCppBidsDependencies(cfg) elseif isempty(GITHUB_WORKSPACE) % local - pth = fullfile(fileparts(mfilename('fullpath')), '..'); + pth = fullfile(fileparts(mfilename('fullpath')), '..', '..'); checkSubmodule(fullfile(pth, 'lib', 'JSONio')); checkSubmodule(fullfile(pth, 'lib', 'bids-matlab')); diff --git a/src/subfun/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m index f727d535..f47023cb 100644 --- a/src/subfun/printCreditsCppBids.m +++ b/src/subfun/printCreditsCppBids.m @@ -1,6 +1,6 @@ function printCreditsCppBids(cfg) - - version = fileread(fullfile(fileparts(mfilename('fullpath')),... + + version = fileread(fullfile(fileparts(mfilename('fullpath')), ... '..', '..', 'version.txt')); verbose = true; diff --git a/tests/test_utils.m b/tests/test_utils.m index 48a7e2bb..d7f4d771 100644 --- a/tests/test_utils.m +++ b/tests/test_utils.m @@ -7,11 +7,11 @@ end function test_utilsBasic() - + cfg.verbose = true; - printCreditsCppBids(); + printCreditsCppBids(cfg); - checkCppBidsDependencies(); + checkCppBidsDependencies(cfg); end From 7c8654bac4f8b38ed6845ca5e6860e1336a955b8 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 6 Sep 2020 08:58:31 +0200 Subject: [PATCH 4/5] fix reading version for CI context --- src/subfun/printCreditsCppBids.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/subfun/printCreditsCppBids.m b/src/subfun/printCreditsCppBids.m index f47023cb..5a6f2c95 100644 --- a/src/subfun/printCreditsCppBids.m +++ b/src/subfun/printCreditsCppBids.m @@ -1,7 +1,11 @@ function printCreditsCppBids(cfg) - version = fileread(fullfile(fileparts(mfilename('fullpath')), ... - '..', '..', 'version.txt')); + try + version = fileread(fullfile(fileparts(mfilename('fullpath')), ... + '..', '..', 'version.txt')); + catch + version = 'v1.0.0'; + end verbose = true; if ~isempty(cfg) && isfield(cfg, 'verbose') && ~isempty(cfg.verbose) From fe06d938f370df6d3df3bb857cd699c9436d9c71 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 6 Sep 2020 09:07:50 +0200 Subject: [PATCH 5/5] fix path for validator test --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 526353bf..73839af7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,7 +44,7 @@ before_script: jobs: include: - name: "BIDS validator: create and check dataset" - script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/rawdata/ --ignoreNiftiHeaders + script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/raw/ --ignoreNiftiHeaders - name: "miss_hit: checking code quality" script: mh_metric . --ci - name: "miss_hit: checking code style"