From cbe4ea2dec7da2e5bfb5f99c9707062b4b216290 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Wed, 3 Jul 2024 15:13:56 +0200 Subject: [PATCH] [FIX] ignore 'na' as trial types when creating default models (#709) * ignore na as trial types when creating default models * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * lint * rm checks perfomed by pre-commit * fix octave --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- +bids/+internal/list_all_trial_types.m | 6 ++++++ .github/workflows/validate.yml | 29 ------------------------- .pre-commit-config.yaml | 1 - tests/test_bids_model.m | 30 ++++++++++++++++++++++++-- 4 files changed, 34 insertions(+), 32 deletions(-) diff --git a/+bids/+internal/list_all_trial_types.m b/+bids/+internal/list_all_trial_types.m index cfba2bd5..92434e58 100644 --- a/+bids/+internal/list_all_trial_types.m +++ b/+bids/+internal/list_all_trial_types.m @@ -111,4 +111,10 @@ trial_type_list{idx} = []; end + % n/a not included as trial type + idx = ismember(trial_type_list, 'n/a'); + if any(idx) + trial_type_list(idx) = []; + end + end diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index 7c300a8c..f432ff58 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -22,12 +22,6 @@ jobs: with: args: --validate - codespell: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: codespell-project/actions-codespell@master - markdown_link_check: runs-on: ubuntu-latest steps: @@ -37,26 +31,3 @@ jobs: use-quiet-mode: yes use-verbose-mode: yes config-file: .github/workflows/mlc_config.json - - miss_hit: - runs-on: ubuntu-latest - strategy: - matrix: - command: [mh_style, mh_metric --ci, mh_lint] - fail-fast: false - steps: - - uses: actions/checkout@v4 - with: - submodules: true - fetch-depth: 1 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: 3.11 - - name: Install dependencies - run: | - python -m pip install --upgrade pip setuptools - pip3 install -r requirements.txt - - name: ${{ matrix.command }} - run: | - ${{ matrix.command }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f1dfb9fd..2f0770f3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,4 +46,3 @@ repos: rev: v2.3.0 hooks: - id: codespell - args: [--config=setup.cfg] diff --git a/tests/test_bids_model.m b/tests/test_bids_model.m index 1f987ca3..fd20e23a 100644 --- a/tests/test_bids_model.m +++ b/tests/test_bids_model.m @@ -152,8 +152,7 @@ function test_model_basic() function test_model_default_model() - pth_bids_example = get_test_data_dir(); - BIDS = bids.layout(fullfile(pth_bids_example, 'ds003')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds003')); bm = bids.Model(); bm = bm.default(BIDS); @@ -167,6 +166,33 @@ function test_model_default_model() end +function test_model_default_model_with_nan_trial_type() + + bids_tmp = temp_dir(); + copyfile(fullfile(get_test_data_dir(), 'ds003'), bids_tmp); + if bids.internal.is_octave + bids_tmp = fullfile(bids_tmp, 'ds003'); + end + + BIDS = bids.layout(bids_tmp); + tsv_files = bids.query(BIDS, 'data', 'suffix', 'events'); + content = bids.util.tsvread(tsv_files{1}); + content.trial_type{1} = 'n/a'; + bids.util.tsvwrite(tsv_files{1}, content); + + BIDS = bids.layout(bids_tmp); + + bm = bids.Model(); + bm = bm.default(BIDS); + + % design matrix should not include n/a + assertEqual(bm.Nodes{1}.Model.X, ... + {'trial_type.pseudoword' + 'trial_type.word' + '1' }); + +end + function test_model_default_no_events() pth_bids_example = get_test_data_dir();