From f9281a1ab83846d18c073d28bfca047cc6c09904 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:41:46 +0200 Subject: [PATCH 1/8] fix extra tab added at the end of tsv lines --- .pre-commit-config.yaml | 44 +++++++++++++++++++ checkCppBidsDependencies.m | 65 ++++++++++++++++++++++++++++ miss_hit.cfg | 4 +- requirements.txt | 4 +- src/saveEventsFile.m | 31 +++++++++---- src/templates/miss_hit.cfg | 3 +- src/utils/checkCppBidsDependencies.m | 50 --------------------- tests/miss_hit.cfg | 3 +- tests/test_saveEventsFileSave.m | 48 ++++++++++++++++++++ tests/utils/setUp.m | 2 +- 10 files changed, 190 insertions(+), 64 deletions(-) create mode 100644 .pre-commit-config.yaml create mode 100644 checkCppBidsDependencies.m delete mode 100644 src/utils/checkCppBidsDependencies.m diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..52cf84c5 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,44 @@ +repos: + +- repo: local + + hooks: + + - id: mh_version + name: mh_version + entry: mh_style + args: [-v] + verbose: true + language: python + additional_dependencies: [miss_hit_core] + + # - id: mh_style + # name: mh_style + # entry: mh_style + # args: [--process-slx, --fix] + # files: ^(.*\.(m|slx))$ + # language: python + # additional_dependencies: [miss_hit_core] + + # - id: mh_metric + # name: mh_metric + # entry: mh_metric + # args: [--ci] + # files: ^(.*\.(m|slx))$ + # language: python + # additional_dependencies: [miss_hit_core] + + # - id: mh_lint + # name: mh_lint + # entry: mh_lint + # files: ^(.*\.(m|slx))$ + # language: python + # additional_dependencies: [miss_hit] + +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v2.0.0 + hooks: + - id: trailing-whitespace + - id: end-of-file-fixer + - id: check-yaml + - id: check-added-large-files diff --git a/checkCppBidsDependencies.m b/checkCppBidsDependencies.m new file mode 100644 index 00000000..a0de47ab --- /dev/null +++ b/checkCppBidsDependencies.m @@ -0,0 +1,65 @@ +% (C) Copyright 2020 CPP_BIDS developers + +function checkCppBidsDependencies(cfg) + % + % Adds dependencies to the Matlab / Octave path and make sure we got all of them. + % + % USAGE:: + % + % checkCppBidsDependencies(cfg) + % + % :param cfg: Configuration. See ``checkCFG()``. + % :type cfg: structure + + if nargin < 1 + cfg.verbose = 2; + end + + global CPP_BIDS_INITIALIZED + + if isempty(CPP_BIDS_INITIALIZED) + + GITHUB_WORKSPACE = getenv('GITHUB_WORKSPACE'); + + if strcmp(GITHUB_WORKSPACE, '/github/workspace') + + pth = GITHUB_WORKSPACE; + addpath(genpath(fullfile(pth, 'lib'))); + + elseif isempty(GITHUB_WORKSPACE) % local + + pth = fullfile(fileparts(mfilename('fullpath'))); + + addpath(pth); + + addpath(fullfile(pth, 'lib', 'utils')); + + checkSubmodule(fullfile(pth, 'lib', 'JSONio')); + checkSubmodule(fullfile(pth, 'lib', 'bids-matlab')); + + addpath(genpath(fullfile(pth, 'src'))); + + end + + printCreditsCppBids(cfg); + + CPP_BIDS_INITIALIZED = true(); + + else + fprintf(1, '\n\nCPP_BIDS already initialized\n\n'); + + end + +end + +function checkSubmodule(pth) + % If external dir is empty throw an exception + % and ask user to update submodules. + if numel(dir(pth)) <= 2 % Means that the external is empty + error(['Git submodules are not cloned!', ... + 'Try this in your terminal:', ... + ' git submodule update --recursive ']); + else + addpath(pth); + end +end diff --git a/miss_hit.cfg b/miss_hit.cfg index 60976e52..5bb11eaf 100644 --- a/miss_hit.cfg +++ b/miss_hit.cfg @@ -1,6 +1,8 @@ # style guide (https://florianschanda.github.io/miss_hit/style_checker.html) line_length: 100 regex_function_name: "[a-z]+(([A-Z]){1}[A-Za-z]+)*" +regex_parameter_name: "[a-z0-9]+(([A-Z]){1}[A-Za-z]+)*" + exclude_dir: "lib" copyright_entity: "CPP_BIDS developers" @@ -8,4 +10,4 @@ copyright_entity: "CPP_BIDS developers" metric "cnest": limit 4 metric "file_length": limit 500 metric "cyc": limit 15 -metric "parameters": limit 6 \ No newline at end of file +metric "parameters": limit 6 diff --git a/requirements.txt b/requirements.txt index 471b6d23..258f423e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,6 +2,6 @@ Sphinx sphinxcontrib-matlabdomain sphinxcontrib-napoleon sphinx_rtd_theme -miss_hit==0.9.15 +miss_hit==0.9.29 notebook -octave_kernel \ No newline at end of file +octave_kernel diff --git a/src/saveEventsFile.m b/src/saveEventsFile.m index 01d7991a..07701f32 100644 --- a/src/saveEventsFile.m +++ b/src/saveEventsFile.m @@ -378,9 +378,9 @@ function printToFile(cfg, logFile, skipEvent, iEvent) if ~skipEvent if ~logFile(1).isStim - printData(logFile(1).fileID, logFile(iEvent).onset, cfg); - printData(logFile(1).fileID, logFile(iEvent).duration, cfg); - printData(logFile(1).fileID, logFile(iEvent).trial_type, cfg); + printData(logFile(1).fileID, logFile(iEvent).onset, cfg, true); + printData(logFile(1).fileID, logFile(iEvent).duration, cfg, true); + printData(logFile(1).fileID, logFile(iEvent).trial_type, cfg, false); end printExtraColumns(logFile, iEvent, cfg); @@ -394,26 +394,41 @@ function printToFile(cfg, logFile, skipEvent, iEvent) function printExtraColumns(logFile, iEvent, cfg) % loops through the extra columns and print them namesExtraColumns = returnNamesExtraColumns(logFile); + if ~logFile(1).isStim && numel(namesExtraColumns) > 0 + fprintf(logFile(1).fileID, '\t'); + talkToMe(cfg, '\t'); + end + addTab = true; for iExtraColumn = 1:numel(namesExtraColumns) data = logFile(iEvent).(namesExtraColumns{iExtraColumn}); - printData(logFile(1).fileID, data, cfg); + if iExtraColumn == numel(namesExtraColumns) + addTab = false; + end + printData(logFile(1).fileID, data, cfg, addTab); end end -function printData(output, data, cfg) +function printData(output, data, cfg, addTab) % write char % for numeric data we replace any nan by n/a + + if addTab + separator = '\t'; + else + separator = ''; + end + if ischar(data) - content = sprintf('%s\t', data); + content = sprintf('%s%s', data, separator); fprintf(output, content); talkToMe(cfg, content); else for i = 1:numel(data) if isnan(data(i)) - content = sprintf('%s\t', 'n/a'); + content = sprintf('%s%s', 'n/a', separator); else - content = sprintf('%f\t', data(i)); + content = sprintf('%f%s', data(i), separator); end fprintf(output, content); talkToMe(cfg, content); diff --git a/src/templates/miss_hit.cfg b/src/templates/miss_hit.cfg index d86aaeb0..c36d2548 100644 --- a/src/templates/miss_hit.cfg +++ b/src/templates/miss_hit.cfg @@ -1,9 +1,10 @@ # style guide (https://florianschanda.github.io/miss_hit/style_checker.html) line_length: 100 regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*" +regex_parameter_name: "test_suite|[a-z0-9]+(([A-Z]){1}[A-Za-z]+)*" # metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) metric "cnest": limit 4 metric "file_length": limit 500 metric "cyc": limit 15 -metric "parameters": limit 5 \ No newline at end of file +metric "parameters": limit 5 diff --git a/src/utils/checkCppBidsDependencies.m b/src/utils/checkCppBidsDependencies.m deleted file mode 100644 index 4512ee43..00000000 --- a/src/utils/checkCppBidsDependencies.m +++ /dev/null @@ -1,50 +0,0 @@ -% (C) Copyright 2020 CPP_BIDS developers - -function checkCppBidsDependencies(cfg) - % - % Adds dependencies to the Matlab / Octave path and make sure we got all of them. - % - % USAGE:: - % - % checkCppBidsDependencies(cfg) - % - % :param cfg: Configuration. See ``checkCFG()``. - % :type cfg: structure - - GITHUB_WORKSPACE = getenv('GITHUB_WORKSPACE'); - - if strcmp(GITHUB_WORKSPACE, '/github/workspace') - - pth = GITHUB_WORKSPACE; - addpath(genpath(fullfile(pth, 'lib'))); - - elseif isempty(GITHUB_WORKSPACE) % local - - pth = fullfile(fileparts(mfilename('fullpath')), '..', '..'); - addpath(fullfile(pth, 'lib', 'utils')); - - pth = fullfile(fileparts(mfilename('fullpath')), '..', '..'); - pth = abspath(pth); - - checkSubmodule(fullfile(pth, 'lib', 'JSONio')); - checkSubmodule(fullfile(pth, 'lib', 'bids-matlab')); - - addpath(genpath(fullfile(pth, 'src'))); - - end - - printCreditsCppBids(cfg); - -end - -function checkSubmodule(pth) - % If external dir is empty throw an exception - % and ask user to update submodules. - if numel(dir(pth)) <= 2 % Means that the external is empty - error(['Git submodules are not cloned!', ... - 'Try this in your terminal:', ... - ' git submodule update --recursive ']); - else - addpath(pth); - end -end diff --git a/tests/miss_hit.cfg b/tests/miss_hit.cfg index d86aaeb0..c36d2548 100644 --- a/tests/miss_hit.cfg +++ b/tests/miss_hit.cfg @@ -1,9 +1,10 @@ # style guide (https://florianschanda.github.io/miss_hit/style_checker.html) line_length: 100 regex_function_name: "((test_[a-z]+)|[a-z]+)(([A-Z]){1}[A-Za-z]+)*" +regex_parameter_name: "test_suite|[a-z0-9]+(([A-Z]){1}[A-Za-z]+)*" # metrics limit for the code quality (https://florianschanda.github.io/miss_hit/metrics.html) metric "cnest": limit 4 metric "file_length": limit 500 metric "cyc": limit 15 -metric "parameters": limit 5 \ No newline at end of file +metric "parameters": limit 5 diff --git a/tests/test_saveEventsFileSave.m b/tests/test_saveEventsFileSave.m index 7d65805d..57310305 100644 --- a/tests/test_saveEventsFileSave.m +++ b/tests/test_saveEventsFileSave.m @@ -46,6 +46,54 @@ function test_saveEventsFileSaveBasic() end +function test_saveEventsFileSaveNoExtraTab() + + cfg.verbose = 2; + + cfg.subject.subjectNb = 1; + cfg.subject.runNb = 1; + + cfg.task.name = 'testtask'; + + cfg = createFilename(cfg); + + logFile.extraColumns.Speed.length = 1; + logFile.extraColumns.LHL24.length = 3; + logFile.extraColumns.is_Fixation.length = 1; + + logFile = saveEventsFile('init', cfg, logFile); + logFile = saveEventsFile('open', cfg, logFile); + + % logFile.onset = 2; + % logFile.duration = 3; + + % ROW 2: normal events : all info is there + logFile(1, 1).onset = 2; + logFile(end, 1).trial_type = 'MotionUp'; + logFile(end, 1).duration = 3; + logFile(end, 1).Speed = 2; + logFile(end, 1).is_Fixation = true; + logFile(end, 1).LHL24 = 1:3; + + logFile = saveEventsFile('save', cfg, logFile); + + saveEventsFile('close', cfg, logFile); + + funcDir = fullfile(cfg.dir.outputSubject, cfg.fileName.modality); + eventFilename = cfg.fileName.events; + + % FID = fopen(fullfile(funcDir, eventFilename), 'r'); + % content = fread(FID, 900, 'uint8=>char') + + FID = fopen(fullfile(funcDir, eventFilename), 'r'); + content = fread(FID, 900); + tab = 9; + eol = 10; + assert(content(end) == 10); + assert(content(end - 1) ~= 9); + +end + function test_saveEventsFileSaveStim() %% set up diff --git a/tests/utils/setUp.m b/tests/utils/setUp.m index ec282c03..1f3aac45 100644 --- a/tests/utils/setUp.m +++ b/tests/utils/setUp.m @@ -2,7 +2,7 @@ function [cfg, logFile] = setUp() - cfg.verbose = 2; + cfg.verbose = 0; cfg.subject.subjectNb = 1; cfg.subject.runNb = 1; From 8457652e373f02a1c3ab45c72d7f8bdfe925cd57 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 28 Oct 2021 18:44:03 +0000 Subject: [PATCH 2/8] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .github/workflows/bids_validator.yml | 11 ++---- .github/workflows/check_markdown.yml | 4 +-- .github/workflows/check_md_links.yml | 2 +- .github/workflows/run_tests.yml | 4 +-- .readthedocs.yml | 2 +- .travis.yml | 2 +- .zenodo.json | 2 +- binder/postBuild | 1 - docs/source/conf.py | 4 +-- docs/source/contributing.rst | 5 +-- docs/source/function_description.rst | 16 ++++----- docs/source/gui.rst | 6 ++-- docs/source/index.rst | 10 +++--- docs/source/set_up.rst | 6 ++-- docs/source/utilities.rst | 6 ++-- lib/utils/abspath.m | 10 +++--- lib/utils/file_utils.m | 32 ++++++++--------- notebooks/README.md | 2 +- npm-requirements.txt | 1 - templates/CHANGES | 2 +- templates/README | 45 ++++++++++++------------ tests/testData/eventsDataDictionary.json | 2 +- tests/testData/extra_bold.json | 2 +- tests/testData/stimDataDictionary.json | 2 +- version.txt | 2 +- 25 files changed, 82 insertions(+), 99 deletions(-) diff --git a/.github/workflows/bids_validator.yml b/.github/workflows/bids_validator.yml index f31b2081..e366716b 100644 --- a/.github/workflows/bids_validator.yml +++ b/.github/workflows/bids_validator.yml @@ -23,7 +23,7 @@ jobs: - name: Make jsonread for octave run: | sudo apt-get -y -qq update - sudo apt-get -y install octave + sudo apt-get -y install octave sudo apt-get -y install liboctave-dev cd lib/JSONio mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS @@ -32,18 +32,13 @@ jobs: - name: Update octave path run: | octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'lib'))); savepath();" - octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath();" + octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath();" - name: Install BIDS validator run: | sudo npm install -g bids-validator@1.6.2 - - name: Create dummy dataset and validate it + - name: Create dummy dataset and validate it run: | cd tests/manualTests octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/raw/ --ignoreNiftiHeaders - - - - - diff --git a/.github/workflows/check_markdown.yml b/.github/workflows/check_markdown.yml index 46725a09..76c0d501 100644 --- a/.github/workflows/check_markdown.yml +++ b/.github/workflows/check_markdown.yml @@ -26,9 +26,7 @@ jobs: - name: Install dependencies and check markdown run: | npm install `cat npm-requirements.txt` - npx remark README.md --frail + npx remark README.md --frail npx remark ./notebooks/ --frail npx remark ./tests/ --frail npx remark ./docs/ --frail - - diff --git a/.github/workflows/check_md_links.yml b/.github/workflows/check_md_links.yml index 62bb95e1..560a509e 100644 --- a/.github/workflows/check_md_links.yml +++ b/.github/workflows/check_md_links.yml @@ -14,4 +14,4 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@master - - uses: gaurav-nelson/github-action-markdown-link-check@v1 \ No newline at end of file + - uses: gaurav-nelson/github-action-markdown-link-check@v1 diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 616f9c21..5464f120 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -21,7 +21,7 @@ jobs: - name: Make jsonread for octave run: | sudo apt-get -y -qq update - sudo apt-get -y install octave + sudo apt-get -y install octave sudo apt-get -y install liboctave-dev cd lib/JSONio mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS @@ -30,7 +30,7 @@ jobs: uses: joergbrech/moxunit-action@master with: tests: tests # files or directories containing the MOxUnit test cases - src: src # directories to be added to the Octave search path before running the tests. + src: src # directories to be added to the Octave search path before running the tests. ext: tests/utils # External resources to add to the search put (excluded from coverage) # data: # Directory for test data with_coverage: true diff --git a/.readthedocs.yml b/.readthedocs.yml index ec0951f4..4ede163a 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -23,4 +23,4 @@ formats: python: version: 3.7 install: - - requirements: requirements.txt \ No newline at end of file + - requirements: requirements.txt diff --git a/.travis.yml b/.travis.yml index ddf16c80..30de7037 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,7 +11,7 @@ node_js: - "11" branches: - only: # only run the CI for those branches + only: # only run the CI for those branches - master - dev diff --git a/.zenodo.json b/.zenodo.json index 6edf043c..3c1807f2 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -32,4 +32,4 @@ ], "license": "MIT license", "upload_type": "software" -} \ No newline at end of file +} diff --git a/binder/postBuild b/binder/postBuild index effa7ebe..b24a09f9 100644 --- a/binder/postBuild +++ b/binder/postBuild @@ -1,3 +1,2 @@ cd ${HOME} cd lib/JSONio; mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS; cd .. - diff --git a/docs/source/conf.py b/docs/source/conf.py index 5a423f71..49022d6e 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -31,7 +31,7 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinxcontrib.matlab', + 'sphinxcontrib.matlab', 'sphinx.ext.autodoc'] matlab_src_dir = os.path.dirname(os.path.abspath('../../src')) primary_domain = 'mat' @@ -88,4 +88,4 @@ 'searchbox.html', 'donate.html', ] -} \ No newline at end of file +} diff --git a/docs/source/contributing.rst b/docs/source/contributing.rst index 38d48d74..39d54f69 100644 --- a/docs/source/contributing.rst +++ b/docs/source/contributing.rst @@ -48,7 +48,7 @@ Template proposal end -.. autofunction:: templateFunction +.. autofunction:: templateFunction Example code in the help section @@ -100,6 +100,3 @@ Example code in the help section end .. autofunction:: templateFunctionExample - - - diff --git a/docs/source/function_description.rst b/docs/source/function_description.rst index 6db43466..b0cace17 100644 --- a/docs/source/function_description.rst +++ b/docs/source/function_description.rst @@ -1,11 +1,11 @@ Function description ******************** - -List of functions in the ``src`` folder. + +List of functions in the ``src`` folder. ---- -.. automodule:: src +.. automodule:: src .. autofunction:: convertSourceToRaw .. autofunction:: createDataDictionary @@ -14,13 +14,13 @@ List of functions in the ``src`` folder. .. autofunction:: createJson ``createJson`` can be used to save in a -human readable format the extra parameters that you used to run your experiment. +human readable format the extra parameters that you used to run your experiment. This will most likely make the json file non-bids compliant but it can prove useful, to keep this information in your source dataset for when you write your methods sections 2 years later after running the experiment. -This ensures that those are the exact parameters you used and you won't have -to read them from the ``setParameters.m`` file and wonder -if those might have been modified when running the experiment +This ensures that those are the exact parameters you used and you won't have +to read them from the ``setParameters.m`` file and wonder +if those might have been modified when running the experiment and you did not commit and tagged that change with git. And for the love of the flying spaghetti monster do not save all your @@ -30,5 +30,3 @@ Octave installed on a computer (plus not everyone uses those). .. autofunction:: readAndFilterLogfile .. autofunction:: saveEventsFile .. autofunction:: userInputs - - diff --git a/docs/source/gui.rst b/docs/source/gui.rst index 3852af8a..b339b3cd 100644 --- a/docs/source/gui.rst +++ b/docs/source/gui.rst @@ -1,17 +1,15 @@ Graphic interface ***************** - + List of functions in the ``gui`` folder: those are mostly to handle the "graphic interface" that can be used to deal with ``userInputs()``. ---- -.. automodule:: src.gui +.. automodule:: src.gui .. autofunction:: askForGroupAndOrSession .. autofunction:: askUserGui .. autofunction:: createQuestionList .. autofunction:: getIsQuestionToAsk .. autofunction:: setDefaultResponses - - diff --git a/docs/source/index.rst b/docs/source/index.rst index b663cb83..f5a0f369 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -38,11 +38,11 @@ A session folder will ALWAYS be created even if not requested (default will be ` Task labels will be printed in ``camelCase`` in the filenames. Time stamps are added directly in the filename by adding a suffix -``_date-*`` (default format is ``YYYYMMDDHHMM``) which makes the file name non-BIDS compliant. -This was added to prevent overwriting files in case a certain run needs to be done -a second time because of a crash. -Some of us are paranoid about keeping even cancelled runs during my experiments. -This suffix should be removed to make the data set BIDS compliant. +``_date-*`` (default format is ``YYYYMMDDHHMM``) which makes the file name non-BIDS compliant. +This was added to prevent overwriting files in case a certain run needs to be done +a second time because of a crash. +Some of us are paranoid about keeping even cancelled runs during my experiments. +This suffix should be removed to make the data set BIDS compliant. See ``convertSourceToRaw()`` for more details. For example:: diff --git a/docs/source/set_up.rst b/docs/source/set_up.rst index 41c9edfb..1756bd4c 100644 --- a/docs/source/set_up.rst +++ b/docs/source/set_up.rst @@ -23,8 +23,8 @@ Group, subject, session and run =============================== You can use the ``userInputs()`` function to easily set the group name as well as -the subject, session and run number. You can ask the function to not bother you with -group and session +the subject, session and run number. You can ask the function to not bother you with +group and session .. todo: @@ -50,4 +50,4 @@ group and session session If you use it with `cfg.subject.askGrpSess = [1 1]`, it will ask you about both. - This is the default behavior. \ No newline at end of file + This is the default behavior. diff --git a/docs/source/utilities.rst b/docs/source/utilities.rst index 7821160d..10645d25 100644 --- a/docs/source/utilities.rst +++ b/docs/source/utilities.rst @@ -1,7 +1,7 @@ Utility functions ***************** - -List of functions in the ``utils`` folder. + +List of functions in the ``utils`` folder. ---- @@ -22,6 +22,6 @@ List of functions in the ``utils`` folder. .. autofunction:: returnNbColumns .. autofunction:: setDefaultFields -.. automodule:: src.gui +.. automodule:: src.gui .. autofunction:: askUserCli diff --git a/lib/utils/abspath.m b/lib/utils/abspath.m index 4376fc4f..08a74675 100644 --- a/lib/utils/abspath.m +++ b/lib/utils/abspath.m @@ -18,14 +18,14 @@ % Example % fpath = abspath(fpath) % -% See also +% See also %% Copyright notice % -------------------------------------------------------------------- % Copyright (C) 2010 Deltares % Bas Hoonhout % -% bas.hoonhout@deltares.nl +% bas.hoonhout@deltares.nl % % Rotterdamseweg 185 % 2629HD Delft @@ -45,9 +45,9 @@ % -------------------------------------------------------------------- % This tool is part of OpenEarthTools. -% OpenEarthTools is an online collaboration to share and manage data and +% OpenEarthTools is an online collaboration to share and manage data and % programming tools in an open source, version controlled environment. -% Sign up to recieve regular updates of this function, and to contribute +% Sign up to recieve regular updates of this function, and to contribute % your own tools. %% Version @@ -114,4 +114,4 @@ if isunix && ... (isempty(fpath) || ~strcmp(fpath(1), '~')) fpath = [filesep fpath]; -end \ No newline at end of file +end diff --git a/lib/utils/file_utils.m b/lib/utils/file_utils.m index 84ab444f..70d3e3a9 100644 --- a/lib/utils/file_utils.m +++ b/lib/utils/file_utils.m @@ -96,7 +96,7 @@ % constructs % t must be a cell array of (relative or absolute) paths, d must be a % single cell containing the base path of relative paths in t - + if ispc % valid absolute paths % Allow drive letter or UNC path mch = '^([a-zA-Z]:)|(\\\\[^\\]*)'; @@ -106,20 +106,20 @@ if (nargin < 2) || isempty(basepath) basepath = {pwd}; end - + % Find partial paths, prepend them with d ppsel = cellfun(@isempty, regexp(t, mch, 'once')); t(ppsel) = cellfun(@(t1)fullfile(basepath{1}, t1), t(ppsel), 'UniformOutput', false); - + % Break paths into cell lists of folder names pt = pathparts(t); - + % Remove single '.' folder names sd = cellfun(@(pt1)strcmp(pt1, '.'), pt, 'UniformOutput', false); for cp = 1:numel(pt) pt{cp} = pt{cp}(~sd{cp}); end - + % Go up one level for '..' folders, don't remove drive letter/server name % from PC path if ispc @@ -142,14 +142,14 @@ pt{cp} = tmppt; end end - + % Assemble paths if ispc t = cellfun(@(pt1)fullfile(pt1{:}), pt, 'UniformOutput', false); else t = cellfun(@(pt1)fullfile(filesep, pt1{:}), pt, 'UniformOutput', false); end - + end % ========================================================================== @@ -160,14 +160,14 @@ % returns cell array of path component cellstr arrays % For PC (WIN) targets, both '\' and '/' are accepted as filesep, similar % to MATLAB fileparts - + if ispc fs = '\\/'; else fs = filesep; end pp = cellfun(@(p1)textscan(p1, '%s', 'delimiter', fs, 'MultipleDelimsAsOne', 1), p); - + if ispc for k = 1:numel(pp) if ~isempty(regexp(pp{k}{1}, '^[a-zA-Z]:$', 'once')) @@ -198,14 +198,14 @@ otherwise error('Invalid action: ''%s''.', action); end - + if nargin < 2 d = pwd; else d = file_utils(d, 'cpath'); end dirMode = false; - + if nargin < 3 expr = '.*'; else @@ -220,16 +220,16 @@ expr = varargin{1}; end end - + dd = dir(d); - + if isempty(dd) return end files = sort({dd(~[dd.isdir]).name})'; dirs = sort({dd([dd.isdir]).name})'; dirs = setdiff(dirs, {'.', '..'}); - + if dirMode t = regexp(dirs, expr); if numel(dirs) == 1 && ~iscell(t) @@ -244,12 +244,12 @@ end files = files(~cellfun(@isempty, t)); end - + if fullpath files = cellfun(@(x) fullfile(d, x), files, 'UniformOutput', false); dirs = cellfun(@(x) fullfile(d, x), dirs, 'UniformOutput', false); end files = char(files); dirs = char(dirs); - + end diff --git a/notebooks/README.md b/notebooks/README.md index 21a5da9f..b09d8fd8 100644 --- a/notebooks/README.md +++ b/notebooks/README.md @@ -10,7 +10,7 @@ install it. If using miniconda, run `conda install jupyter` to download and install the Jupyter Notebook package. -1. Install [Octave kernel](https://pypi.org/project/octave-kernel/): +1. Install [Octave kernel](https://pypi.org/project/octave-kernel/): `pip install octave_kernel` 1. Run `jupyter notebook` in your terminal. `Octave` should appear on the list diff --git a/npm-requirements.txt b/npm-requirements.txt index 061f9ade..7e328257 100644 --- a/npm-requirements.txt +++ b/npm-requirements.txt @@ -3,4 +3,3 @@ remark-lint@6.0.2 remark-preset-lint-recommended@3.0.2 remark-preset-lint-markdown-style-guide@2.1.2 remark-preset-lint-consistent - diff --git a/templates/CHANGES b/templates/CHANGES index 12eb6c37..e22df35e 100644 --- a/templates/CHANGES +++ b/templates/CHANGES @@ -1,3 +1,3 @@ 1.0.0 YYYY-MM-DD - - initial release \ No newline at end of file + - initial release diff --git a/templates/README b/templates/README index 16b16495..46d96025 100644 --- a/templates/README +++ b/templates/README @@ -1,6 +1,6 @@ # README -(template copied from the BIDS starter kit: +(template copied from the BIDS starter kit: https://github.com/bids-standard/bids-starter-kit) The README is usually the starting point for researchers using your data @@ -10,8 +10,8 @@ README makes your data much more usable. In general you can include information in the README that is not captured by some other files in the BIDS dataset (dataset_description.json, events.tsv, ...). -It can also be useful to also include information that might already be -present in another file of the dataset but might be important for users to be aware of +It can also be useful to also include information that might already be +present in another file of the dataset but might be important for users to be aware of before preprocessing or analysing the data. If the README gets too long you have the possibility to create a `/doc` folder @@ -31,9 +31,9 @@ Indicate the name and contact details (email and ORCID) of the person responsibl - [ ] Practical information to access the data -If there is any special information related to access rights or -how to download the data make sure to include it. -For example, if the dataset was curated using datalad, +If there is any special information related to access rights or +how to download the data make sure to include it. +For example, if the dataset was curated using datalad, make sure to include the relevant section from the datalad handbook: http://handbook.datalad.org/en/latest/basics/101-180-FAQ.html#how-can-i-help-others-get-started-with-a-shared-dataset @@ -43,19 +43,19 @@ http://handbook.datalad.org/en/latest/basics/101-180-FAQ.html#how-can-i-help-oth - [ ] Year(s) that the project ran -If no `scans.tsv` is included, this could at least cover when the data acquisition +If no `scans.tsv` is included, this could at least cover when the data acquisition starter and ended. Local time of day is particularly relevant to subject state. - [ ] Brief overview of the tasks in the experiment -A paragraph giving an overview of the experiment. This should include the +A paragraph giving an overview of the experiment. This should include the goals or purpose and a discussion about how the experiment tries to achieve these goals. - [ ] Description of the contents of the dataset -An easy thing to add is the output of the bids-validator that describes what type of -data and the number of subject one can expect to find in the dataset. +An easy thing to add is the output of the bids-validator that describes what type of +data and the number of subject one can expect to find in the dataset. - [ ] Independent variables @@ -71,9 +71,9 @@ questionnaires administered to assess behavioral aspects of the experiment. - [ ] Control variables -A brief discussion of the control variables --- that is what aspects -were explicitly controlled in this experiment. The control variables might -include subject pool, environmental conditions, set up, or other things +A brief discussion of the control variables --- that is what aspects +were explicitly controlled in this experiment. The control variables might +include subject pool, environmental conditions, set up, or other things that were explicitly controlled. - [ ] Quality assessment of the data @@ -81,7 +81,7 @@ that were explicitly controlled. Provide a short summary of the quality of the data ideally with descriptive statistics if relevant and with a link to more comprehensive description (like with MRIQC) if possible. -## Methods +## Methods ### Subjects @@ -93,7 +93,7 @@ using a group column. - [ ] Information about the recruitment procedure - [ ] Subject inclusion criteria (if relevant) - [ ] Subject exclusion criteria (if relevant) - + ### Apparatus A summary of the equipment and environment setup for the @@ -108,16 +108,16 @@ A summary of what setup was performed when a subject arrived. How the tasks were organized for a session. This is particularly important because BIDS datasets usually have task data -separated into different files.) +separated into different files.) - [ ] Was task order counter-balanced? -- [ ] What other activities were interspersed between tasks? +- [ ] What other activities were interspersed between tasks? -- [ ] In what order were the tasks and other activities performed? +- [ ] In what order were the tasks and other activities performed? ### Task details -As much detail as possible about the task and the events that were recorded. +As much detail as possible about the task and the events that were recorded. ### Additional data acquired @@ -132,14 +132,14 @@ https://bids-specification.readthedocs.io/en/stable/03-modality-agnostic-files.h ### Experimental location -This should include any additional information regarding the +This should include any additional information regarding the the geographical location and facility that cannot be included in the relevant json files. ### Missing data Mention something if some participants are missing some aspects of the data. -This can take the form of a processing log and/or abnormalities about the dataset. +This can take the form of a processing log and/or abnormalities about the dataset. Some examples: @@ -152,6 +152,5 @@ Some examples: ### Notes Any additional information or pointers to information that -might be helpful to users of the dataset. Include qualitative information +might be helpful to users of the dataset. Include qualitative information related to how the data acquisition went. - diff --git a/tests/testData/eventsDataDictionary.json b/tests/testData/eventsDataDictionary.json index 21402989..c26e9e48 100644 --- a/tests/testData/eventsDataDictionary.json +++ b/tests/testData/eventsDataDictionary.json @@ -39,4 +39,4 @@ "TermURL": "", "Units": "" } -} \ No newline at end of file +} diff --git a/tests/testData/extra_bold.json b/tests/testData/extra_bold.json index bb36cf1c..5425aa08 100644 --- a/tests/testData/extra_bold.json +++ b/tests/testData/extra_bold.json @@ -7,4 +7,4 @@ "extraInfo": { "nestedExtraInfo": "something extra" } -} \ No newline at end of file +} diff --git a/tests/testData/stimDataDictionary.json b/tests/testData/stimDataDictionary.json index 8efa2614..3438c43a 100644 --- a/tests/testData/stimDataDictionary.json +++ b/tests/testData/stimDataDictionary.json @@ -43,4 +43,4 @@ "TermURL": "", "Units": "" } -} \ No newline at end of file +} diff --git a/version.txt b/version.txt index 6eaf8943..46b105a3 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v2.0.0 \ No newline at end of file +v2.0.0 From 28f70410ef7feb738d89c705b661419e77957b9c Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:46:31 +0200 Subject: [PATCH 3/8] update doc --- docs/Makefile | 3 +++ docs/source/utilities.rst | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index d0c3cbf1..8996f312 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -18,3 +18,6 @@ help: # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +doc: + @$(SPHINXBUILD) -b html "$(SOURCEDIR)" "$(BUILDDIR)" diff --git a/docs/source/utilities.rst b/docs/source/utilities.rst index 7821160d..917c61f4 100644 --- a/docs/source/utilities.rst +++ b/docs/source/utilities.rst @@ -1,13 +1,12 @@ Utility functions ***************** - -List of functions in the ``utils`` folder. + +List of functions in the ``utils`` folder. ---- .. automodule:: src.utils -.. autofunction:: checkCppBidsDependencies .. autofunction:: checkInput .. autofunction:: createValidName .. autofunction:: getFullFilename @@ -22,6 +21,6 @@ List of functions in the ``utils`` folder. .. autofunction:: returnNbColumns .. autofunction:: setDefaultFields -.. automodule:: src.gui +.. automodule:: src.gui .. autofunction:: askUserCli From f001b20bfaa081dd6c45b9fb77abf9d05f48f3ef Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:51:17 +0200 Subject: [PATCH 4/8] remove markdown check github action --- .github/workflows/check_markdown.yml | 32 ---------------------------- .remarkrc | 11 ---------- npm-requirements.txt | 5 ----- 3 files changed, 48 deletions(-) delete mode 100644 .github/workflows/check_markdown.yml delete mode 100644 .remarkrc delete mode 100644 npm-requirements.txt diff --git a/.github/workflows/check_markdown.yml b/.github/workflows/check_markdown.yml deleted file mode 100644 index 76c0d501..00000000 --- a/.github/workflows/check_markdown.yml +++ /dev/null @@ -1,32 +0,0 @@ -name: Check Markdown - -on: - push: - branches: - - master - pull_request: - branches: '*' - -jobs: - build: - - runs-on: ubuntu-latest - - steps: - - - uses: actions/checkout@v2 - with: - submodules: true - fetch-depth: 1 - - - uses: actions/setup-node@v2 - with: - node-version: '10' - - - name: Install dependencies and check markdown - run: | - npm install `cat npm-requirements.txt` - npx remark README.md --frail - npx remark ./notebooks/ --frail - npx remark ./tests/ --frail - npx remark ./docs/ --frail diff --git a/.remarkrc b/.remarkrc deleted file mode 100644 index 201ce70e..00000000 --- a/.remarkrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": [ - "preset-lint-consistent", - "preset-lint-markdown-style-guide", - "preset-lint-recommended", - ["lint-no-duplicate-headings", false], - ["lint-list-item-indent", "tab-size"], - ["lint-maximum-line-length", true], - ["lint-maximum-heading-length", false] - ] -} diff --git a/npm-requirements.txt b/npm-requirements.txt deleted file mode 100644 index 7e328257..00000000 --- a/npm-requirements.txt +++ /dev/null @@ -1,5 +0,0 @@ -remark-cli@5.0.0 -remark-lint@6.0.2 -remark-preset-lint-recommended@3.0.2 -remark-preset-lint-markdown-style-guide@2.1.2 -remark-preset-lint-consistent From 1c2750d0106d578eb664fa0a36c3348debd1e2e6 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:53:58 +0200 Subject: [PATCH 5/8] remove travis --- .travis.yml | 48 ------------------------------------------------ README.md | 4 ---- 2 files changed, 52 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 30de7037..00000000 --- a/.travis.yml +++ /dev/null @@ -1,48 +0,0 @@ -# Travis CI (https://travis-ci.org/) -# This will only work on your repo if you have an account on travis and you -# have set it up to run continuous integration on this this repo - -# Linux distribution (bionic beaver) -dist: focal - -# Language and version -language: node_js -node_js: - - "11" - -branches: - only: # only run the CI for those branches - - master - - dev - -env: - global: # Define environment variables for bash - - OCTFLAGS="--no-gui --no-window-system --silent" - -before_install: - - travis_retry sudo apt-get -y -qq update - # Install octave - - travis_retry sudo apt-get -y install octave - - travis_retry sudo apt-get -y install liboctave-dev - # Install javascript node and node package manager necessary to run the validator - - travis_retry sudo apt-get -y install nodejs - - travis_retry sudo apt-get -y install npm - # Install BIDS-Validator - - sudo npm install -g bids-validator@1.6.2 - -install: - # make octave file the JSONio submodule - - cd lib/JSONio; mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS; cd ../.. - - octave $OCTFLAGS --eval "addpath (pwd); savepath ();" - -before_script: - # Add to src functions to path - - octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath ();" - # Change current directory - - cd tests/manualTests - -jobs: - include: - - - name: "BIDS validator: create and check dataset" - script: octave $OCTFLAGS --eval "test_makeRawDataset" && bids-validator `pwd`/output/raw/ --ignoreNiftiHeaders diff --git a/README.md b/README.md index 6fb0f241..6221f38c 100644 --- a/README.md +++ b/README.md @@ -19,10 +19,6 @@ [![codecov](https://codecov.io/gh/cpp-lln-lab/CPP_BIDS/branch/master/graph/badge.svg)](https://codecov.io/gh/cpp-lln-lab/CPP_BIDS) -**BIDS validator and linter** - -[![Build Status](https://travis-ci.com/cpp-lln-lab/CPP_BIDS.svg?branch=master)](https://travis-ci.com/cpp-lln-lab/CPP_BIDS) - **Contributors** [![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors-) From e5202fa8254ab3d342d195a6e8c3872b0b35ce8a Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:54:44 +0200 Subject: [PATCH 6/8] fix yml --- .github/workflows/bids_validator.yml | 2 +- .github/workflows/check_md_links.yml | 2 +- .github/workflows/miss_hit.yml | 3 +-- .github/workflows/run_tests.yml | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/bids_validator.yml b/.github/workflows/bids_validator.yml index e366716b..81aa8845 100644 --- a/.github/workflows/bids_validator.yml +++ b/.github/workflows/bids_validator.yml @@ -5,7 +5,7 @@ on: branches: - master pull_request: - branches: 'master' + branches: ['master'] env: OCTFLAGS: --no-gui --no-window-system --silent diff --git a/.github/workflows/check_md_links.yml b/.github/workflows/check_md_links.yml index 560a509e..0ed7db21 100644 --- a/.github/workflows/check_md_links.yml +++ b/.github/workflows/check_md_links.yml @@ -7,7 +7,7 @@ on: branches: - master pull_request: - branches: '*' + branches: ['*'] jobs: markdown-link-check: diff --git a/.github/workflows/miss_hit.yml b/.github/workflows/miss_hit.yml index 5c5e561d..3a4e3c21 100644 --- a/.github/workflows/miss_hit.yml +++ b/.github/workflows/miss_hit.yml @@ -5,8 +5,7 @@ on: branches: - master pull_request: - branches: '*' - + branches: ['*'] jobs: build: diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index 5464f120..25ac689b 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -6,7 +6,7 @@ on: - master - dev pull_request: - branches: '*' + branches: ['*'] jobs: build: From 38f6ba85e239a7330ef422cc68f39ce15764be61 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 20:56:43 +0200 Subject: [PATCH 7/8] bump version --- version.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/version.txt b/version.txt index 46b105a3..826e1424 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -v2.0.0 +v2.1.1 From 7764ad6867e58406c2a72458d2339341d6233bb4 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Thu, 28 Oct 2021 21:10:20 +0200 Subject: [PATCH 8/8] update CI --- .github/workflows/bids_validator.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/bids_validator.yml b/.github/workflows/bids_validator.yml index 81aa8845..27d955ed 100644 --- a/.github/workflows/bids_validator.yml +++ b/.github/workflows/bids_validator.yml @@ -31,6 +31,7 @@ jobs: - name: Update octave path run: | + octave $OCTFLAGS --eval "addpath(pwd); savepath();" octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'lib'))); savepath();" octave $OCTFLAGS --eval "addpath(genpath(fullfile(pwd, 'src'))); savepath();"