diff --git a/+bids/+internal/list_all_trial_types.m b/+bids/+internal/list_all_trial_types.m index 594e143b..7b12f0a1 100644 --- a/+bids/+internal/list_all_trial_types.m +++ b/+bids/+internal/list_all_trial_types.m @@ -54,6 +54,8 @@ trial_type_list = {}; + BIDS = bids.layout(BIDS, 'index_dependencies', false); + event_files = bids.query(BIDS, 'data', ... 'suffix', 'events', ... 'extension', '.tsv', ... diff --git a/+bids/+util/create_sessions_tsv.m b/+bids/+util/create_sessions_tsv.m index d5e2e3f7..e1551466 100644 --- a/+bids/+util/create_sessions_tsv.m +++ b/+bids/+util/create_sessions_tsv.m @@ -49,7 +49,8 @@ %% output_filenames = {}; - layout = bids.layout(layout_or_path, 'use_schema', use_schema); + layout = bids.layout(layout_or_path, 'use_schema', use_schema, ... + 'index_dependencies', false); sessions_list = bids.query(layout, 'sessions'); if isempty(sessions_list) && use_schema diff --git a/+bids/File.m b/+bids/File.m index 0dd8e5fd..772aced8 100644 --- a/+bids/File.m +++ b/+bids/File.m @@ -83,6 +83,7 @@ % Modify metadata % % .. code-block:: matlab + % % % Adding new value % f = f.metadata_add('NewField', 'new value'); % f.metadata() diff --git a/+bids/diagnostic.m b/+bids/diagnostic.m index f1c20313..c2f70a76 100644 --- a/+bids/diagnostic.m +++ b/+bids/diagnostic.m @@ -78,7 +78,8 @@ parse(args, varargin{:}); %% - BIDS = bids.layout(args.Results.BIDS, 'use_schema', args.Results.use_schema); + BIDS = bids.layout(args.Results.BIDS, 'use_schema', args.Results.use_schema, ... + 'index_dependencies', false); output_path = args.Results.output_path; diff --git a/+bids/layout.m b/+bids/layout.m index 2cda6653..a0a6c5bb 100644 --- a/+bids/layout.m +++ b/+bids/layout.m @@ -26,8 +26,8 @@ % any ``derivatives`` folder in the BIDS dataset. % :type index_derivatives: logical % - % :param index_dependencies: if ``true`` this will index the dependencies - % (json files, associated TSV files for each file...) + % :param index_dependencies: if ``true`` this will index the explicit dependencies + % (with "IntendedFor" in json files) % :type index_dependencies: logical % % :param filter: Can be used to index only a subset of the dataset. diff --git a/.github/workflows/run_examples.yml b/.github/workflows/run_examples.yml index 6e4c385f..db2b3687 100644 --- a/.github/workflows/run_examples.yml +++ b/.github/workflows/run_examples.yml @@ -1,6 +1,11 @@ --- name: tests_examples + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: diff --git a/.github/workflows/run_tests_matlab.yml b/.github/workflows/run_tests_matlab.yml index 4e530097..98486fee 100644 --- a/.github/workflows/run_tests_matlab.yml +++ b/.github/workflows/run_tests_matlab.yml @@ -1,6 +1,10 @@ --- name: 'matlab: tests' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: @@ -19,8 +23,9 @@ jobs: strategy: fail-fast: false matrix: - version: [R2021a, R2021b, R2022a, R2022b] + version: [R2021a, R2023a] os: [ubuntu-latest, macos-latest, windows-latest] + test: [slow, fast] runs-on: ${{matrix.os}} @@ -57,7 +62,15 @@ jobs: git clone https://github.com/MOxUnit/MOxUnit.git --depth 1 git clone https://github.com/MOcov/MOcov.git --depth 1 - - name: Run commands + - name: Run slow tests + if: matrix.test == 'slow' + uses: matlab-actions/run-command@v1.1.3 + with: + command: run MOxUnit/MOxUnit/moxunit_set_path(); addpath(fullfile(pwd, 'MOcov', 'MOcov')); global SLOW; SLOW=true; addpath(getenv('GITHUB_WORKSPACE')); + success = run_tests(); assert(success); + + - name: Run fast tests + if: matrix.test == 'fast' uses: matlab-actions/run-command@v1.1.3 with: command: run MOxUnit/MOxUnit/moxunit_set_path(); addpath(fullfile(pwd, 'MOcov', 'MOcov')); addpath(getenv('GITHUB_WORKSPACE')); success = run_tests(); diff --git a/.github/workflows/run_tests_octave.yml b/.github/workflows/run_tests_octave.yml index 0a823c5d..9e855168 100644 --- a/.github/workflows/run_tests_octave.yml +++ b/.github/workflows/run_tests_octave.yml @@ -1,6 +1,10 @@ --- name: 'octave: tests' +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: @@ -17,6 +21,11 @@ env: jobs: test: + strategy: + fail-fast: false + matrix: + test: [slow, fast] + runs-on: ubuntu-22.04 steps: @@ -66,6 +75,13 @@ jobs: mkoctfile --mex jsonread.c jsmn.c -DJSMN_PARENT_LINKS octave $OCTFLAGS --eval "addpath(fullfile(pwd)); savepath();" - - name: Run unit tests Octave + - name: Run fast tests Octave + if: matrix.test == 'fast' + run: | + octave $OCTFLAGS --eval "success = run_tests(); assert(success);" + + - name: Run slow tests Octave + if: matrix.test == 'slow' run: | + export SLOW=true octave $OCTFLAGS --eval "success = run_tests(); assert(success);" diff --git a/.github/workflows/update_schema.yml b/.github/workflows/update_schema.yml index 560d08e0..38a5632e 100644 --- a/.github/workflows/update_schema.yml +++ b/.github/workflows/update_schema.yml @@ -21,6 +21,10 @@ name: update schema # │ │ │ │ │ # * * * * * +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index aef92fb9..15476d11 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -1,6 +1,10 @@ --- name: validate +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + on: push: branches: ['*'] diff --git a/docs/source/images/timing.png b/docs/source/images/timing.png new file mode 100644 index 00000000..b7a9174b Binary files /dev/null and b/docs/source/images/timing.png differ diff --git a/docs/source/index.rst b/docs/source/index.rst index 659d1393..228951c6 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,6 +24,7 @@ To see how to install BIDS-Matlab, please check stats_model transformers schema + performance dev_doc diff --git a/docs/source/performance.rst b/docs/source/performance.rst new file mode 100644 index 00000000..0e9e57da --- /dev/null +++ b/docs/source/performance.rst @@ -0,0 +1,21 @@ +Performance +*********** + +bids-matlab's performance may vary +depending on which options you choose for indexing with :func:`bids.layout`. + +Relying on the BIDS schema (``'use_schema', true``) to only include files that comply with it +may slow down performance a bit. + +Index dependencies (``'index_dependencies', true``) to detect files +with explicit dependencies between them +(for example when a fieldmap mentions that is intended for a specific bold run) +is much slower and you may consider setting this to ``false`` +when if you know that you have no such dependencies in your dataset. + + +.. _fig_benchmark: +.. figure:: images/timing.png + :align: center + + layout indexing performance depending on chosen options diff --git a/run_tests.m b/run_tests.m index d895e89a..ca200bb9 100644 --- a/run_tests.m +++ b/run_tests.m @@ -3,6 +3,8 @@ % (C) Copyright 2021 BIDS-MATLAB developers + tic; + fprintf('\nRunning tests\n'); if nargin < 1 @@ -16,7 +18,12 @@ addpath(fullfile(pwd, 'tests', 'utils')); folderToCover = fullfile(pwd, '+bids'); + testFolder = fullfile(pwd, 'tests'); + if run_slow_test_only + fprintf('Running only slow tests\n'); + testFolder = fullfile(pwd, 'tests', 'tests_slow'); + end if with_coverage success = moxunit_runtests(testFolder, ... @@ -35,4 +42,6 @@ end + toc; + end diff --git a/tests/test_report.m b/tests/test_report.m index a4ca04b5..99540620 100644 --- a/tests/test_report.m +++ b/tests/test_report.m @@ -14,7 +14,7 @@ function test_report_asl() BIDS = fullfile(cfg.pth_bids_example, datasets); - BIDS = bids.layout(BIDS, 'use_schema', true); + BIDS = bids.layout(BIDS, 'use_schema', true, 'index_dependencies', false); filter.modality = 'perf'; @@ -46,7 +46,7 @@ function test_report_basic() for i = 1:numel(datasets) BIDS = fullfile(cfg.pth_bids_example, datasets{i}); - BIDS = bids.layout(BIDS, 'use_schema', true); + BIDS = bids.layout(BIDS, 'use_schema', true, 'index_dependencies', false); for j = 1:numel(modalities) @@ -81,7 +81,7 @@ function test_report_pet() BIDS = fullfile(cfg.pth_bids_example, datasets); - BIDS = bids.layout(BIDS, 'use_schema', true); + BIDS = bids.layout(BIDS, 'use_schema', true, 'index_dependencies', false); filter.modality = 'pet'; @@ -120,7 +120,7 @@ function test_report_moae_data() 'verbose', true, ... 'delete_previous', false); - BIDS = bids.layout(pth, 'use_schema', true); + BIDS = bids.layout(pth, 'use_schema', true, 'index_dependencies', false); report = bids.report(BIDS, ... 'output_path', cfg.output_path, ... diff --git a/tests/tests_layout/layout_timing.m b/tests/tests_layout/layout_timing.m index 201a4384..d18773a4 100644 --- a/tests/tests_layout/layout_timing.m +++ b/tests/tests_layout/layout_timing.m @@ -1,216 +1,82 @@ function layout_timing % - % runs bids.layout on the bids-examples and gives an estimate of the timing - % for each + % runs bids.layout on the bids-examples + % and gives an estimate of the timing for each % - use_schema = false; - - %% WITH SCHEMA - % data time (sec) - % asl001 0.084 - % asl005 0.094 - % asl003 0.095 - % asl002 0.098 - % asl004 0.109 - % pet004 0.114 - % pet003 0.127 - % qmri_tb1tfl 0.137 - % qmri_qsm 0.138 - % qmri_irt1 0.139 - % qmri_sa2rage 0.153 - % micr_SEMzarr 0.159 - % pet001 0.165 - % qmri_mp2rage 0.174 - % pet005 0.182 - % qmri_vfa 0.185 - % qmri_mtsat 0.187 - % micr_SEM 0.198 - % ds000246 0.215 - % qmri_megre 0.217 - % hcp_example_bids 0.244 - % eeg_ds003645s_hed_inheritance 0.257 - % pet002 0.259 - % ds000248 0.292 - % micr_SPIM 0.312 - % qmri_mp2rageme 0.334 - % eeg_ds003645s_hed_longform 0.383 - % ieeg_visual 0.396 - % eeg_ds003645s_hed_library 0.405 - % ieeg_epilepsy_ecog 0.475 - % fnirs_tapping 0.557 - % eeg_rest_fmri 0.602 - % ds000247 0.693 - % ieeg_epilepsyNWB 0.752 - % motion_systemvalidation 0.817 - % eeg_matchingpennies 0.819 - % qmri_mese 0.862 - % eeg_face13 0.871 - % ieeg_epilepsy 1.097 - % ds004332 1.127 - % eeg_ds003645s_hed 1.209 - % ieeg_filtered_speech 1.783 - % ds005 1.904 - % ds003 2.030 - % ds101 2.090 - % qmri_mpm 2.333 - % ds105 2.390 - % motion_spotrotation 2.525 - % ieeg_visual_multimodal 2.544 - % ds052 2.627 - % ds001 2.692 - % genetics_ukbb 2.812 - % synthetic 3.061 - % ds011 3.139 - % ds008 3.390 - % eeg_cbm 3.691 - % ds051 3.726 - % ds114 3.818 - % ds002 3.877 - % ds102 4.276 - % ds007 4.544 - % ds109 4.726 - % ds116 5.002 - % eeg_rishikesh 5.175 - % ieeg_motorMiller2007 5.342 - % ds009 5.821 - % ds006 6.574 - % ds107 6.991 - % ds110 7.362 - % ds113b 7.766 - % eeg_ds000117 8.033 - % ds210 8.614 - % motion_dualtask 8.633 - % ds108 10.668 - % ds000117 15.543 - % 7t_trt 15.960 - % fnirs_automaticity 19.642 - % docs NaN - % ds000001-fmriprep NaN - % tools NaN - - %% WITHOUT SCHEMA - % qmri_qsm 0.071 - % qmri_tb1tfl 0.073 - % qmri_sa2rage 0.081 - % qmri_vfa 0.105 - % qmri_irt1 0.108 - % hcp_example_bids 0.113 - % asl001 0.120 - % pet004 0.122 - % pet001 0.126 - % qmri_mp2rage 0.128 - % asl003 0.128 - % qmri_mtsat 0.132 - % asl002 0.133 - % asl005 0.135 - % pet003 0.145 - % micr_SEMzarr 0.152 - % qmri_megre 0.176 - % asl004 0.177 - % micr_SEM 0.183 - % eeg_ds003645s_hed_inheritance 0.217 - % pet005 0.220 - % qmri_mp2rageme 0.243 - % ds000248 0.264 - % pet002 0.268 - % micr_SPIM 0.292 - % ds000246 0.307 - % ieeg_epilepsyNWB 0.333 - % eeg_ds003645s_hed_longform 0.335 - % ieeg_visual 0.351 - % eeg_ds003645s_hed_library 0.359 - % eeg_ds003645s_hed 0.362 - % ieeg_epilepsy 0.380 - % fnirs_tapping 0.463 - % ieeg_epilepsy_ecog 0.468 - % motion_systemvalidation 0.508 - % eeg_rest_fmri 0.523 - % qmri_mese 0.716 - % eeg_face13 0.767 - % ieeg_filtered_speech 0.775 - % eeg_matchingpennies 0.813 - % ds003 1.049 - % ds000247 1.092 - % ds004332 1.406 - % qmri_mpm 1.735 - % ieeg_motorMiller2007 1.781 - % motion_spotrotation 1.857 - % genetics_ukbb 1.915 - % ieeg_visual_multimodal 2.170 - % ds005 2.202 - % ds101 2.350 - % synthetic 2.446 - % ds052 2.544 - % eeg_cbm 2.554 - % ds001 2.638 - % eeg_rishikesh 2.776 - % ds102 2.939 - % ds105 3.204 - % ds109 3.461 - % ds114 3.507 - % ds011 4.585 - % ds051 4.758 - % ds002 4.927 - % ds008 5.239 - % ds116 5.307 - % eeg_ds000117 5.373 - % ds107 6.259 - % ds113b 6.300 - % ds210 7.619 - % ds110 7.992 - % motion_dualtask 8.380 - % ds108 8.887 - % ds007 10.000 - % ds009 10.363 - % ds006 10.371 - % fnirs_automaticity 14.192 - % 7t_trt 15.023 - % ds000117 23.928 - % docs NaN - % ds000001-fmriprep NaN - % tools NaN - - pth_bids_example = get_test_data_dir(); - - d = dir(pth_bids_example); - d(arrayfun(@(x) ~x.isdir || ismember(x.name, {'.', '..', '.git', '.github'}), d)) = []; - - tab = '\t\t\t'; - - fprintf('\n'); - fprintf(['data' tab 'time (sec)\n']); - fprintf('\n'); - for i = 1:numel(d) + DEBUG = false; + + use_schema_list = [true false]; + index_dependencies_list = [true false]; + + output = struct('name', {{}}); + + for j = 1:numel(use_schema_list) + use_schema = use_schema_list(j); + + for k = 1:numel(index_dependencies_list) + index_dependencies = index_dependencies_list(k); - ds{i} = d(i).name; + output.(field(use_schema, index_dependencies, '_nb_files')) = []; + output.(field(use_schema, index_dependencies, '_time')) = []; + end + end - fprintf(1, '%s', d(i).name); + d = dir(get_test_data_dir()); + d(arrayfun(@(x) ~x.isdir || ismember(x.name, ... + {'.', '..', '.git', '.github', ... + 'docs', 'tools'}), ... + d)) = []; - if exist(fullfile(pth_bids_example, d(i).name, '.SKIP_VALIDATION'), 'file') - fprintf([tab 'skip\n']); - T(i) = nan; - continue + for i = 1:numel(d) + + if DEBUG && i > 4 + break end - tic; - bids.layout(fullfile(pth_bids_example, d(i).name), ... - 'use_schema', use_schema, ... - 'verbose', false); - T(i) = toc; + output.name{i} = d(i).name; + fprintf(1, '%s\n', d(i).name); + + for j = 1:numel(use_schema_list) + use_schema = use_schema_list(j); - fprintf(1, [tab '%0.3f\n'], T(i)); + for k = 1:numel(index_dependencies_list) + index_dependencies = index_dependencies_list(k); + + [time, nb_files] = run_on_examples(d(i).name, use_schema, index_dependencies); + + output.(field(use_schema, index_dependencies, '_nb_files'))(end + 1) = nb_files; + output.(field(use_schema, index_dependencies, '_time'))(end + 1) = time; + end + end end - fprintf('\n'); - [T, I] = sort(T); - ds = ds(I); - fprintf('\n sorted results\n'); - fprintf(['data' tab 'time (sec)\n']); + bids.util.tsvwrite('timing.tsv', output); + +end - for i = 1:numel(ds) - fprintf(1, ['%s' tab '%0.3f\n'], ds{i}, T(i)); +function value = field(use_schema, index_dependencies, suffix) + pattern = 'schema_%i_depedencies_%i'; + value = sprintf([pattern suffix], ... + use_schema, ... + index_dependencies); +end + +function [time, nb_files] = run_on_examples(name, use_schema, index_dependencies) + + if use_schema && exist(fullfile(get_test_data_dir(), name, '.SKIP_VALIDATION'), 'file') + time = nan; + nb_files = nan; + return end + tic; + BIDS = bids.layout(fullfile(get_test_data_dir(), name), ... + 'use_schema', use_schema, ... + 'index_dependencies', index_dependencies, ... + 'verbose', false); + time = toc; + nb_files = numel(bids.query(BIDS, 'data')); + end diff --git a/tests/tests_layout/plot_timing.m b/tests/tests_layout/plot_timing.m new file mode 100644 index 00000000..18cf9aa7 --- /dev/null +++ b/tests/tests_layout/plot_timing.m @@ -0,0 +1,47 @@ +close all; +clear; + +use_schema_list = [true false]; +index_dependencies_list = [true false]; + +data = bids.util.tsvread('timing.tsv'); + +figure(); + +hold on; + +legend_name = {}; + +for j = 1:numel(use_schema_list) + use_schema = use_schema_list(j); + + for k = 1:numel(index_dependencies_list) + index_dependencies = index_dependencies_list(k); + + legend_name{end + 1} = strrep(field(use_schema, index_dependencies, ''), ... + '_', ' '); %#ok<*SAGROW> + + nb_files = data.(field(use_schema, index_dependencies, '_nb_files')); + time = data.(field(use_schema, index_dependencies, '_time')); + + s = scatter(nb_files, time, 100, '.'); + + end +end + +xlabel('number of files'); +ylabel('time (sec)'); + +% axis([0 50 0 2.5]) + +legend(legend_name, 'location', 'NorthWest'); + +print(gcf, 'timing.png', '-dpng'); + +%% +function value = field(use_schema, index_dependencies, suffix) + pattern = 'schema_%i_depedencies_%i'; + value = sprintf([pattern suffix], ... + use_schema, ... + index_dependencies); +end diff --git a/tests/tests_layout/test_layout.m b/tests/tests_layout/test_layout.m index fe48199b..65cff4f3 100644 --- a/tests/tests_layout/test_layout.m +++ b/tests/tests_layout/test_layout.m @@ -61,6 +61,7 @@ function test_layout_filter() BIDS = bids.layout(fullfile(get_test_data_dir(), '7t_trt'), ... 'verbose', verbose, ... + 'index_dependencies', false, ... 'filter', struct('sub', {{'01', '02'}}, ... 'modality', {{'anat', 'func'}}, ... 'ses', {{'1', '2'}})); @@ -82,6 +83,7 @@ function test_layout_filter_regex() BIDS = bids.layout(fullfile(get_test_data_dir(), '7t_trt'), ... 'verbose', verbose, ... + 'index_dependencies', false, ... 'filter', struct('sub', {{'^.*0[12]'}}, ... 'modality', {{'anat', 'func'}}, ... 'ses', {{'[1]'}})); @@ -96,13 +98,3 @@ function test_layout_filter_regex() assertEqual(subjects, {'1'}); end - -function test_layout_smoke_test() - - verbose = false; - - BIDS = bids.layout(fullfile(get_test_data_dir(), 'genetics_ukbb'), 'verbose', verbose); - - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds210'), 'verbose', verbose); - -end diff --git a/tests/tests_layout/test_layout_derivatives.m b/tests/tests_layout/test_layout_derivatives.m index 8bc4970c..ad024bf2 100644 --- a/tests/tests_layout/test_layout_derivatives.m +++ b/tests/tests_layout/test_layout_derivatives.m @@ -6,24 +6,6 @@ initTestSuite; end -function test_layout_warning_invalid_subfolder_struct_fieldname() - - % https://github.com/bids-standard/bids-matlab/issues/332 - - invalid_subfolder = fullfile(get_test_data_dir(), '..', ... - 'data', 'synthetic', 'derivatives', 'invalid_subfolder'); - - if bids.internal.is_octave() - moxunit_throw_test_skipped_exception('Octave:mixed-string-concat warning thrown'); - end - - assertWarning(@()bids.layout(invalid_subfolder, ... - 'use_schema', false, ... - 'verbose', true), ... - 'layout:invalidSubfolderName'); - -end - function test_layout_nested() pth_bids_example = get_test_data_dir(); @@ -41,7 +23,8 @@ function test_layout_nested() for i = 1:numel(dataset_to_test) BIDS = bids.layout(fullfile(pth_bids_example, dataset_to_test{i}), ... 'use_schema', true, 'tolerant', false, ... - 'index_derivatives', true); + 'index_derivatives', true, ... + 'index_dependencies', false); fprintf(1, '.'); end @@ -55,7 +38,8 @@ function test_layout_meg_derivatives() 'ds000117', ... 'derivatives', ... 'meg_derivatives'), ... - 'use_schema', false); + 'use_schema', false, ... + 'index_dependencies', false); modalities = {'meg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); @@ -80,6 +64,7 @@ function test_layout_prefix() 'swuasub-01_acq-anat_TB1TFL.nii.gz')); BIDS = bids.layout(fullfile(pth_bids_example, 'qmri_tb1tfl'), ... + 'index_dependencies', false, ... 'use_schema', false); data = bids.query(BIDS, 'data', ... @@ -99,8 +84,8 @@ function test_layout_schemaless() pth_bids_example = get_test_data_dir(); - BIDS = bids.layout(fullfile(pth_bids_example, ... - 'ds000001-fmriprep'), ... + BIDS = bids.layout(fullfile(pth_bids_example, 'ds000001-fmriprep'), ... + 'index_dependencies', false, ... 'use_schema', false); modalities = {'anat', 'figures', 'func'}; @@ -132,3 +117,21 @@ function test_layout_schemaless() '_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii'] }); end + +function test_layout_warning_invalid_subfolder_struct_fieldname() + + % https://github.com/bids-standard/bids-matlab/issues/332 + + invalid_subfolder = fullfile(get_test_data_dir(), '..', ... + 'data', 'synthetic', 'derivatives', 'invalid_subfolder'); + + if bids.internal.is_octave() + moxunit_throw_test_skipped_exception('Octave:mixed-string-concat warning thrown'); + end + + assertWarning(@()bids.layout(invalid_subfolder, ... + 'use_schema', false, ... + 'verbose', true), ... + 'layout:invalidSubfolderName'); + +end diff --git a/tests/tests_layout/test_layout_schemaless.m b/tests/tests_layout/test_layout_schemaless.m index aca7e848..829886b7 100644 --- a/tests/tests_layout/test_layout_schemaless.m +++ b/tests/tests_layout/test_layout_schemaless.m @@ -23,6 +23,7 @@ function test_layout_no_schema_no_ses_in_filename() BIDS = bids.layout(bids_dir, ... 'verbose', verbose, ... + 'index_dependencies', false, ... 'use_schema', true, ... 'filter', filter); @@ -31,6 +32,7 @@ function test_layout_no_schema_no_ses_in_filename() BIDS = bids.layout(bids_dir, ... 'verbose', verbose, ... + 'index_dependencies', false, ... 'use_schema', false, ... 'filter', filter); diff --git a/tests/tests_layout/timing.tsv b/tests/tests_layout/timing.tsv new file mode 100644 index 00000000..ad6796d4 --- /dev/null +++ b/tests/tests_layout/timing.tsv @@ -0,0 +1,79 @@ +name schema_1_depedencies_1_nb_files schema_1_depedencies_1_time schema_1_depedencies_0_nb_files schema_1_depedencies_0_time schema_0_depedencies_1_nb_files schema_0_depedencies_1_time schema_0_depedencies_0_nb_files schema_0_depedencies_0_time +7t_trt 635 12.878057 635 5.746334 635 13.23332 635 5.226321 +asl001 4 0.122762 4 0.21057 4 0.130981 4 0.053013 +asl002 5 0.110307 5 0.08017299999999999 5 0.107406 5 0.067231 +asl003 5 0.158618 5 0.08215500000000001 5 0.101119 5 0.065372 +asl004 6 0.123305 6 0.101505 6 0.13708 6 0.071115 +asl005 5 0.130211 5 0.097418 5 0.096479 5 0.061447 +ds000001-fmriprep n/a n/a n/a n/a 418 8.171611 418 3.111228 +ds000117 640 18.295967 640 6.784899 864 21.10377 864 8.487672999999999 +ds000246 13 0.358794 13 0.189625 13 0.311395 13 0.102036 +ds000247 40 2.127618 40 0.877923 40 0.842565 40 0.296761 +ds000248 9 0.21457 9 0.201783 11 0.246136 11 0.09224300000000001 +ds001 128 2.715686 128 2.292915 128 2.08474 128 0.944258 +ds002 238 3.989296 238 2.376058 238 3.516501 238 1.991699 +ds003 52 1.810685 52 0.99124 52 0.915794 52 0.455082 +ds004332 58 1.425477 58 0.944766 58 1.45826 58 0.69469 +ds005 128 4.766503 128 2.233034 128 2.671854 128 1.332702 +ds006 384 17.304357 384 7.715079 384 15.992915 384 4.734097 +ds007 276 7.026251 276 3.500368 276 5.600689 276 2.774765 +ds008 197 4.643136 197 3.006904 197 5.059259 197 2.042414 +ds009 360 11.121226 360 3.930276 360 7.077274 360 3.145282 +ds011 196 3.979 196 2.044542 196 2.911879 196 1.32229 +ds051 245 5.41513 245 2.811987 245 3.61198 245 1.586959 +ds052 142 2.900416 142 1.462075 142 2.401136 142 1.380542 +ds101 105 2.566284 105 1.209946 105 1.640797 105 0.785391 +ds102 130 3.285882 130 3.613964 130 2.254736 130 1.235791 +ds105 148 2.344433 148 1.159552 148 2.294374 148 0.936268 +ds107 245 7.439544 245 5.018268 245 5.353551 245 3.352455 +ds108 442 9.877881 442 5.824762 442 9.772868000000001 442 3.719578 +ds109 174 4.845315 174 3.845052 174 3.711721 174 1.60113 +ds110 396 8.428979 396 3.9203 396 7.632956 396 4.624585 +ds113b 312 7.856034 312 4.047022 312 5.895564 312 2.860994 +ds114 164 3.635015 164 2.326693 164 3.986292 164 1.541886 +ds116 238 5.358747 238 2.236292 238 4.713165 238 1.895178 +ds210 300 9.889874000000001 300 3.460661 300 7.280257 300 3.151618 +eeg_cbm 80 2.375438 80 1.20596 80 3.103752 80 0.847672 +eeg_ds000117 321 8.917916999999999 321 3.816874 321 6.344976 321 2.20161 +eeg_ds003645s_hed 20 0.547461 20 0.220162 20 0.37045 20 0.185295 +eeg_ds003645s_hed_inheritance 10 0.491762 10 0.146763 10 0.220385 10 0.116235 +eeg_ds003645s_hed_library 18 0.563624 18 0.206467 18 0.326917 18 0.161759 +eeg_ds003645s_hed_longform 18 0.48201 18 0.248961 18 0.328663 18 0.16511 +eeg_face13 40 1.512921 40 0.475066 40 0.708877 40 0.363321 +eeg_matchingpennies 35 1.223818 35 0.26424 35 0.752654 35 0.197893 +eeg_rest_fmri 36 0.751157 36 0.2244 36 0.571695 36 0.309812 +eeg_rishikesh 120 3.728327 120 2.092848 120 3.96413 120 1.80132 +fnirs_automaticity 624 19.444088 624 7.064014 624 14.293472 624 4.859085 +fnirs_tapping 25 1.105406 25 0.303453 25 0.402494 25 0.229565 +genetics_ukbb 112 2.44505 112 1.405501 112 2.696068 112 1.230629 +hcp_example_bids 5 0.17511 5 0.160794 5 0.130965 5 0.06297800000000001 +ieeg_epilepsy 21 0.534711 21 0.330119 21 0.391636 21 0.302818 +ieeg_epilepsyNWB 15 0.522953 15 0.171177 15 0.349226 15 0.154569 +ieeg_epilepsy_ecog 18 0.607453 18 0.186014 18 0.445421 18 0.205806 +ieeg_filtered_speech 49 1.330714 49 0.409764 49 0.693241 49 0.300797 +ieeg_motorMiller2007 103 2.640748 103 0.9111629999999999 103 1.962946 103 0.669125 +ieeg_visual 19 0.871592 19 0.317233 19 0.334786 19 0.143083 +ieeg_visual_multimodal 101 2.419473 101 1.069651 101 2.70493 101 1.291842 +micr_SEM 6 0.297653 6 0.12262 6 0.202291 6 0.093598 +micr_SEMzarr 4 0.245839 4 0.273165 4 0.147603 4 0.068276 +micr_SPIM 11 0.671759 11 0.185743 11 0.373255 11 0.170519 +motion_dualtask 355 10.028597 355 3.714179 355 9.046773 355 3.525084 +motion_spotrotation 100 2.140386 100 0.78505 100 1.775886 100 0.939034 +motion_systemvalidation 27 0.720349 27 0.318322 27 0.518885 27 0.189777 +pet001 4 0.270659 4 0.221607 4 0.11098 4 0.06858300000000001 +pet002 8 0.391504 8 0.158324 8 0.221316 8 0.108903 +pet003 3 0.132492 3 0.07571700000000001 3 0.091964 3 0.061076 +pet004 3 0.168884 3 0.236781 3 0.094412 3 0.057697 +pet005 5 0.267879 5 0.246028 5 0.138186 5 0.087008 +qmri_irt1 4 0.18725 4 0.176378 4 0.130704 4 0.063917 +qmri_megre 8 0.202014 8 0.117488 8 0.183043 8 0.09503200000000001 +qmri_mese 32 0.920145 32 0.444109 32 0.704209 32 0.323025 +qmri_mp2rage 5 0.228771 5 0.235643 5 0.127973 5 0.07502 +qmri_mp2rageme 11 0.399368 11 0.149428 11 0.258685 11 0.126593 +qmri_mpm 53 1.840644 53 0.654851 53 2.045668 53 0.475899 +qmri_mtsat 5 0.270519 5 0.188931 5 0.164588 5 0.121687 +qmri_qsm 2 0.202867 2 0.16589 2 0.116158 2 0.043784 +qmri_sa2rage 2 0.15133 2 0.20459 2 0.219949 2 0.048966 +qmri_tb1tfl 2 0.117524 2 0.127355 2 0.130369 2 0.04258 +qmri_vfa 4 0.168128 4 0.182997 4 0.130711 4 0.071682 +synthetic 111 2.869342 111 1.188585 111 2.506092 111 1.370206 diff --git a/tests/tests_private/test_append_to_layout.m b/tests/tests_private/test_append_to_layout.m index 26b0d1a6..95c68b88 100644 --- a/tests/tests_private/test_append_to_layout.m +++ b/tests/tests_private/test_append_to_layout.m @@ -32,8 +32,7 @@ function test_append_to_layout_schema_unknown_entity() file = 'sub-16_task-bar_foo-bar_meg.ds'; - assertWarning( ... - @()bids.internal.append_to_layout(file, subject, modality, schema, previous), ... + assertWarning(@()bids.internal.append_to_layout(file, subject, modality, schema, previous), ... 'append_to_layout:unknownEntity'); end @@ -61,8 +60,7 @@ function test_append_to_layout_basic() file = 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz'; subject = bids.internal.append_to_layout(file, subject, modality, schema, previous); - expected.anat = struct( ... - 'filename', 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz', ... + expected.anat = struct('filename', 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz', ... 'suffix', 'T1w', ... 'ext', '.nii.gz', ... 'prefix', '', ... @@ -114,8 +112,7 @@ function test_append_to_structure_basic_test() subject = bids.internal.append_to_layout(file, subject, ... modality, schema, previous); - expected.anat(1, 1) = struct( ... - 'filename', 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz', ... + expected.anat(1, 1) = struct('filename', 'sub-16_ses-mri_run-1_acq-hd_T1w.nii.gz', ... 'suffix', 'T1w', ... 'ext', '.nii.gz', ... 'prefix', '', ... @@ -203,8 +200,7 @@ function test_append_to_layout_schemaless() schema = bids.Schema(use_schema); schema.verbose = true; - subject = struct( ... - modality, struct([]), ... + subject = struct(modality, struct([]), ... 'path', fullfile(pwd, 'sub-01')); previous = struct('group', struct('index', 0, 'base', '', 'len', 1), ... diff --git a/tests/tests_private/test_list_events.m b/tests/tests_private/test_list_events.m index 23e57753..99af8d16 100644 --- a/tests/tests_private/test_list_events.m +++ b/tests/tests_private/test_list_events.m @@ -14,19 +14,17 @@ function test_list_events_basic() pth_bids_example = get_test_data_dir(); - data_sets_to_test = '^ds00.*[0-9]$'; % '^ds.*[0-9]$' + data_sets_to_test = '^ds00[0-9]$'; % '^ds.*[0-9]$' examples = bids.internal.file_utils('FPList', get_test_data_dir(), 'dir', data_sets_to_test); for i = 1:size(examples, 1) - BIDS = bids.layout(deblank(examples(i, :))); + BIDS = bids.layout(deblank(examples(i, :)), 'index_dependencies', false); tasks = bids.query(BIDS, 'tasks'); for j = 1:numel(tasks) - [bids.internal.file_utils(BIDS.pth, 'basename'), ' - ', tasks{j}]; - [data, headers, y_labels] = bids.internal.list_events(BIDS, 'func', tasks{j}); bids.internal.plot_diagnostic_table(data, ... diff --git a/tests/tests_query/test_bids_query.m b/tests/tests_query/test_bids_query.m index 27d93437..913e9136 100644 --- a/tests/tests_query/test_bids_query.m +++ b/tests/tests_query/test_bids_query.m @@ -8,7 +8,8 @@ function test_query_phenotype() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002'), ... + 'index_dependencies', false); phenotype = bids.query(BIDS, 'phenotype'); @@ -32,11 +33,13 @@ function test_query_phenotype() function test_query_participants() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002'), ... + 'index_dependencies', false); participants = bids.query(BIDS, 'participants'); - BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl001')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl001'), ... + 'index_dependencies', false); participants = bids.query(BIDS, 'participants'); @@ -44,7 +47,8 @@ function test_query_participants() function test_query_impossible_suffix_should_return_empty() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic'), ... + 'index_dependencies', false); % no suffix bold in anat filter = struct('sub', '01', ... @@ -60,12 +64,14 @@ function test_query_impossible_suffix_should_return_empty() function test_query_suffixes() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002'), ... + 'index_dependencies', false); suffixes = {'T1w', 'pet'}; assertEqual(bids.query(BIDS, 'suffixes'), suffixes); - BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic'), ... + 'index_dependencies', false); suffixes = {'T1w'}; assertEqual(bids.query(BIDS, 'suffixes', 'modality', 'anat'), suffixes); @@ -74,7 +80,8 @@ function test_query_suffixes() function test_query_subjects() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_visual')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_visual'), ... + 'index_dependencies', false); subjs = arrayfun(@(x) sprintf('%02d', x), 1:2, 'UniformOutput', false); assertEqual(bids.query(BIDS, 'subjects'), subjs); @@ -95,7 +102,8 @@ function test_query_regex_subjects_no_regex_by_default() % end - BIDS = bids.layout(fullfile(get_test_data_dir(), '..', 'data', 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), '..', 'data', 'synthetic'), ... + 'index_dependencies', false); data = bids.query(BIDS, 'subjects', 'sub', '01'); @@ -109,7 +117,8 @@ function test_query_regex_subjects_no_regex_by_default() function test_query_regex_subjects() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000247')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000247'), ... + 'index_dependencies', false); data = bids.query(BIDS, 'data', 'sub', '.*', 'suffix', 'T1w'); @@ -123,7 +132,8 @@ function test_query_regex_subjects() function test_query_with_indices() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds105')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds105'), ... + 'index_dependencies', false); data_1 = bids.query(BIDS, 'data', 'sub', '1', 'run', {3, 5, '7', '01'}, 'suffix', 'bold'); data_2 = bids.query(BIDS, 'data', 'sub', '1', 'run', 1:2:7, 'suffix', 'bold'); @@ -134,7 +144,8 @@ function test_query_with_indices() function test_query_entities() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_qsm')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_qsm'), ... + 'index_dependencies', false); entities = bids.query(BIDS, 'entities'); @@ -144,7 +155,8 @@ function test_query_entities() assertEqual(entities, expected); %% - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002'), ... + 'index_dependencies', false); entities = bids.query(BIDS, 'entities', 'suffix', 'pet'); @@ -157,7 +169,8 @@ function test_query_entities() function test_query_events_tsv_in_root() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic'), ... + 'index_dependencies', false); data = bids.query(BIDS, 'data', 'sub', '01', 'ses', '01', 'task', 'nback', 'suffix', 'events'); @@ -170,7 +183,8 @@ function test_query_events_tsv_in_root() function test_query_exclude_entity() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000246')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000246'), ... + 'index_dependencies', false); filter = struct('sub', '0001'); assertEqual(bids.query(BIDS, 'modalities', filter), {'anat', 'meg'}); @@ -189,7 +203,8 @@ function test_query_exclude_entity() function test_query_basic() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet005')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet005'), ... + 'index_dependencies', false); tasks = {'eyes'}; assertEqual(bids.query(BIDS, 'tasks'), tasks); @@ -204,7 +219,8 @@ function test_query_basic() function test_query_data_filter() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet005')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet005'), ... + 'index_dependencies', false); % make sure that query can work with filter filters = {'sub', {'01'}; ... @@ -225,7 +241,8 @@ function test_query_data_filter() function test_query_extension() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl'), ... + 'index_dependencies', false); extensions = bids.query(BIDS, 'extensions'); @@ -244,7 +261,8 @@ function test_query_extension() function test_query_metadata() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl'), ... + 'index_dependencies', false); md = bids.query(BIDS, 'metadata', ... 'sub', '01', ... @@ -258,7 +276,8 @@ function test_query_metadata() function test_query_modalities() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'pet002'), ... + 'index_dependencies', false); modalities = {'anat', 'pet'}; @@ -270,7 +289,8 @@ function test_query_modalities() function test_query_tsv_content() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'eeg_ds003645s_hed_inheritance')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'eeg_ds003645s_hed_inheritance'), ... + 'index_dependencies', false); tsv_content = bids.query(BIDS, 'tsv_content', 'suffix', 'events'); @@ -291,7 +311,8 @@ function test_query_tsv_content() function test_query_tsv_content_error() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_tb1tfl'), ... + 'index_dependencies', false); assertExceptionThrown(@()bids.query(BIDS, 'tsv_content', 'extension', '.nii.gz'), ... 'query:notJustTsvFiles'); @@ -299,7 +320,8 @@ function test_query_tsv_content_error() function test_query_sessions() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic'), ... + 'index_dependencies', false); sessions = {'01', '02'}; assertEqual(bids.query(BIDS, 'sessions'), sessions); assertEqual(bids.query(BIDS, 'sessions', 'sub', '02'), sessions); @@ -312,7 +334,8 @@ function test_query_sessions() function test_query_sessions_tsv() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'synthetic'), ... + 'index_dependencies', false); suffixes = bids.query(BIDS, 'suffixes'); assert(ismember('sessions', suffixes)); @@ -354,7 +377,8 @@ function test_query_sessions_tsv() function test_query_scans_tsv() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'motion_spotrotation')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'motion_spotrotation'), ... + 'index_dependencies', false); suffixes = bids.query(BIDS, 'suffixes'); assert(ismember('scans', suffixes)); diff --git a/tests/tests_query/test_bids_query_asl.m b/tests/tests_query/test_bids_query_asl.m index d1eb644f..7dd29e38 100644 --- a/tests/tests_query/test_bids_query_asl.m +++ b/tests/tests_query/test_bids_query_asl.m @@ -35,7 +35,8 @@ function test_bids_query_asl_basic_asl002() function test_bids_query_asl_basic_asl001() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl001')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl001'), ... + 'index_dependencies', false); modalities = {'anat', 'perf'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); @@ -64,7 +65,8 @@ function test_bids_query_asl_basic_asl001() function test_bids_query_asl_basic_asl003() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl003')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'asl003'), ... + 'index_dependencies', false); modalities = {'anat', 'perf'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); diff --git a/tests/tests_query/test_bids_query_derivatives.m b/tests/tests_query/test_bids_query_derivatives.m index f22d6279..f61c857b 100644 --- a/tests/tests_query/test_bids_query_derivatives.m +++ b/tests/tests_query/test_bids_query_derivatives.m @@ -9,6 +9,7 @@ function test_bids_query_derivatives_basic() BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000001-fmriprep'), ... + 'index_dependencies', false, ... 'use_schema', false); spaces = bids.query(BIDS, 'spaces'); diff --git a/tests/tests_query/test_bids_query_dwi.m b/tests/tests_query/test_bids_query_dwi.m index 4e8fc39b..1ccea623 100644 --- a/tests/tests_query/test_bids_query_dwi.m +++ b/tests/tests_query/test_bids_query_dwi.m @@ -11,7 +11,8 @@ function test_bids_query_dwi_basic() % dwi queries % %% - BIDS = bids.layout(fullfile(get_test_data_dir(), 'eeg_rest_fmri')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'eeg_rest_fmri'), ... + 'index_dependencies', false); modalities = {'anat', 'dwi', 'eeg', 'func'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); diff --git a/tests/tests_query/test_bids_query_eeg.m b/tests/tests_query/test_bids_query_eeg.m index cc480d8d..cc66e1aa 100644 --- a/tests/tests_query/test_bids_query_eeg.m +++ b/tests/tests_query/test_bids_query_eeg.m @@ -12,7 +12,8 @@ function test_bids_query_eeg_basic_1() % %% - BIDS = bids.layout(fullfile(get_test_data_dir, 'eeg_face13')); + BIDS = bids.layout(fullfile(get_test_data_dir, 'eeg_face13'), ... + 'index_dependencies', false); modalities = {'eeg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); @@ -38,7 +39,8 @@ function test_bids_query_eeg_basic_2() % %% - BIDS = bids.layout(fullfile(get_test_data_dir, 'eeg_ds000117')); + BIDS = bids.layout(fullfile(get_test_data_dir, 'eeg_ds000117'), ... + 'index_dependencies', false); modalities = {'anat', 'eeg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); diff --git a/tests/tests_query/test_bids_query_func.m b/tests/tests_query/test_bids_query_func.m index 0e541954..6c3d8666 100644 --- a/tests/tests_query/test_bids_query_func.m +++ b/tests/tests_query/test_bids_query_func.m @@ -11,7 +11,8 @@ function test_bids_query_func_basic() % func queries % - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds001')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds001'), ... + 'index_dependencies', false); %% dependencies dependencies = bids.query(BIDS, 'dependencies', ... diff --git a/tests/tests_query/test_bids_query_ieeg.m b/tests/tests_query/test_bids_query_ieeg.m index 89c85260..ca52e765 100644 --- a/tests/tests_query/test_bids_query_ieeg.m +++ b/tests/tests_query/test_bids_query_ieeg.m @@ -12,7 +12,8 @@ function test_bids_query_ieeg_basic_1() % %% - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_epilepsy')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_epilepsy'), ... + 'index_dependencies', false); modalities = {'anat', 'ieeg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); @@ -38,7 +39,8 @@ function test_bids_query_ieeg_basic_2() % %% - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_epilepsy_ecog')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ieeg_epilepsy_ecog'), ... + 'index_dependencies', false); modalities = {'anat', 'ieeg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); diff --git a/tests/tests_query/test_bids_query_matlab_octave.m b/tests/tests_query/test_bids_query_matlab_octave.m index 1d74463a..bb73dd71 100644 --- a/tests/tests_query/test_bids_query_matlab_octave.m +++ b/tests/tests_query/test_bids_query_matlab_octave.m @@ -11,7 +11,8 @@ function test_query_impossible_suffix_should_return_empty() - BIDS = bids.layout(fullfile(get_test_data_dir(), '7t_trt')); + BIDS = bids.layout(fullfile(get_test_data_dir(), '7t_trt'), ... + 'index_dependencies', false); subjects = bids.query(BIDS, 'subjects'); assertEqual(size(subjects), [1, 22]); diff --git a/tests/tests_query/test_bids_query_meg.m b/tests/tests_query/test_bids_query_meg.m index 9a50d795..f56a4465 100644 --- a/tests/tests_query/test_bids_query_meg.m +++ b/tests/tests_query/test_bids_query_meg.m @@ -11,7 +11,8 @@ function test_bids_query_meg_basic() % meg queries % - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000246')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000246'), ... + 'index_dependencies', false); modalities = {'anat', 'meg'}; assertEqual(bids.query(BIDS, 'modalities'), modalities); @@ -21,9 +22,8 @@ function test_bids_query_meg_basic() assertEqual(bids.query(BIDS, 'suffixes'), suffixes); % smoke tests - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000247')); - - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000248')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000248'), ... + 'index_dependencies', false); dependencies = bids.query(BIDS, 'dependencies', 'sub', '01', 'suffix', 'meg'); diff --git a/tests/tests_query/test_bids_query_microscopy.m b/tests/tests_query/test_bids_query_microscopy.m index 1bc991a6..043f8bd1 100644 --- a/tests/tests_query/test_bids_query_microscopy.m +++ b/tests/tests_query/test_bids_query_microscopy.m @@ -8,12 +8,14 @@ function test_bids_query_microscopy_basic() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'micr_SEM')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'micr_SEM'), ... + 'index_dependencies', false); data = bids.query(BIDS, 'data'); assertEqual(numel(data), 6); - BIDS = bids.layout(fullfile(get_test_data_dir(), 'micr_SPIM')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'micr_SPIM'), ... + 'index_dependencies', false); data = bids.query(BIDS, 'data'); assertEqual(numel(data), 11); diff --git a/tests/tests_query/test_bids_query_motion.m b/tests/tests_query/test_bids_query_motion.m index 62ee47ee..3d199607 100644 --- a/tests/tests_query/test_bids_query_motion.m +++ b/tests/tests_query/test_bids_query_motion.m @@ -11,7 +11,8 @@ function test_bids_query_motion_basic() % motion queries % - BIDS = bids.layout(fullfile(get_test_data_dir(), 'motion_spotrotation')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'motion_spotrotation'), ... + 'index_dependencies', false); optodes_files = bids.query(BIDS, 'data', ... 'suffix', 'channels'); diff --git a/tests/tests_query/test_bids_query_nirs.m b/tests/tests_query/test_bids_query_nirs.m index 44d39b6e..ab345c1b 100644 --- a/tests/tests_query/test_bids_query_nirs.m +++ b/tests/tests_query/test_bids_query_nirs.m @@ -11,7 +11,8 @@ function test_bids_query_nirs_basic() % nirs queries % - BIDS = bids.layout(fullfile(get_test_data_dir(), 'fnirs_tapping')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'fnirs_tapping'), ... + 'index_dependencies', false); optodes_files = bids.query(BIDS, 'data', ... 'suffix', 'optodes'); diff --git a/tests/tests_query/test_bids_query_qmri.m b/tests/tests_query/test_bids_query_qmri.m index fd6676ff..b44a8e2d 100644 --- a/tests/tests_query/test_bids_query_qmri.m +++ b/tests/tests_query/test_bids_query_qmri.m @@ -8,7 +8,8 @@ function test_bids_query_qmri_megre_echos() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_megre')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_megre'), ... + 'index_dependencies', false); echos = bids.query(BIDS, 'echos', 'modality', 'anat'); assertEqual(numel(echos), 8); @@ -17,7 +18,8 @@ function test_bids_query_qmri_megre_echos() function test_bids_query_qmri_irt1_inv() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_irt1')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'qmri_irt1'), ... + 'index_dependencies', false); inversions = bids.query(BIDS, 'inversions'); assertEqual(numel(inversions), 4); diff --git a/tests/tests_query/test_query_bug_453.m b/tests/tests_query/test_query_bug_453.m index 56c2a8e5..f7804072 100644 --- a/tests/tests_query/test_query_bug_453.m +++ b/tests/tests_query/test_query_bug_453.m @@ -1,6 +1,7 @@ function test_query_bug_453() - BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000248')); + BIDS = bids.layout(fullfile(get_test_data_dir(), 'ds000248'), ... + 'index_dependencies', false); assertEqual(bids.query(BIDS, 'modalities'), {'anat', 'meg'}); assertEqual(bids.query(BIDS, 'modalities', 'task', '.*'), {'meg'}); diff --git a/tests/test_diagnostic.m b/tests/tests_slow/test_diagnostic.m similarity index 84% rename from tests/test_diagnostic.m rename to tests/tests_slow/test_diagnostic.m index 697d81b3..a1657697 100644 --- a/tests/test_diagnostic.m +++ b/tests/tests_slow/test_diagnostic.m @@ -10,6 +10,10 @@ function test_diagnostic_basic() + if ~run_slow_test_only() + moxunit_throw_test_skipped_exception('slow test only'); + end + close all; pth_bids_example = get_test_data_dir(); @@ -19,7 +23,7 @@ function test_diagnostic_basic() for i = 1:size(examples, 1) - BIDS = bids.layout(deblank(examples(i, :))); + BIDS = bids.layout(deblank(examples(i, :)), 'index_dependencies', false); diagnostic_table = bids.diagnostic(BIDS, 'output_path', pwd); diagnostic_table = bids.diagnostic(BIDS, 'split_by', {'suffix'}, 'output_path', pwd); diff --git a/tests/test_download_ds.m b/tests/tests_slow/test_download_ds.m similarity index 90% rename from tests/test_download_ds.m rename to tests/tests_slow/test_download_ds.m index 2fc4bde0..948f3410 100644 --- a/tests/test_download_ds.m +++ b/tests/tests_slow/test_download_ds.m @@ -10,6 +10,10 @@ function test_download_ds_moae() + if ~run_slow_test_only() + moxunit_throw_test_skipped_exception('slow test only'); + end + output_dir = bids.util.download_ds('source', 'spm', ... 'demo', 'moae', ... 'out_path', temp_dir(), ... @@ -35,6 +39,10 @@ function test_download_ds_moae() function test_download_ds_facerep() + if ~run_slow_test_only() + moxunit_throw_test_skipped_exception('slow test only'); + end + output_dir = bids.util.download_ds('source', 'spm', ... 'demo', 'facerep', ... 'out_path', temp_dir(), ... diff --git a/tests/tests_utils/test_create_data_dict.m b/tests/tests_utils/test_create_data_dict.m index efbb9158..b573594d 100644 --- a/tests/tests_utils/test_create_data_dict.m +++ b/tests/tests_utils/test_create_data_dict.m @@ -10,7 +10,8 @@ function test_create_data_dict_basic() pth_bids_example = get_test_data_dir(); - BIDS = bids.layout(fullfile(pth_bids_example, 'ds001')); + BIDS = bids.layout(fullfile(pth_bids_example, 'ds001'), ... + 'index_dependencies', false); tsv_files = bids.query(BIDS, 'data', ... 'sub', '01', ... @@ -48,7 +49,8 @@ function test_create_data_dict_schema() pth_bids_example = get_test_data_dir(); - BIDS = bids.layout(fullfile(pth_bids_example, 'ds001')); + BIDS = bids.layout(fullfile(pth_bids_example, 'ds001'), ... + 'index_dependencies', false); tsv_files = bids.query(BIDS, 'data', ... 'suffix', 'events'); @@ -76,7 +78,8 @@ function test_create_data_dict_schema() pth_bids_example = get_test_data_dir(); - BIDS = bids.layout(fullfile(pth_bids_example, dataset)); + BIDS = bids.layout(fullfile(pth_bids_example, dataset), ... + 'index_dependencies', false); tasks = bids.query(BIDS, 'tasks'); @@ -154,7 +157,8 @@ function test_create_data_dict_several_tsv() dataset = datasets{i_dataset}; - BIDS = bids.layout(fullfile(pth_bids_example, dataset)); + BIDS = bids.layout(fullfile(pth_bids_example, dataset), ... + 'index_dependencies', false); tasks = bids.query(BIDS, 'tasks'); diff --git a/tests/tests_utils/test_plot_events.m b/tests/tests_utils/test_plot_events.m index a0084bf2..7e61f17f 100644 --- a/tests/tests_utils/test_plot_events.m +++ b/tests/tests_utils/test_plot_events.m @@ -12,7 +12,7 @@ function test_plot_events_ds101() data_dir = fullfile(get_test_data_dir(), 'ds001'); - BIDS = bids.layout(data_dir); + BIDS = bids.layout(data_dir, 'index_dependencies', false); events_files = bids.query(BIDS, ... 'data', ... @@ -33,7 +33,7 @@ function test_plot_events_ds101_with_model() 'model', ... 'model-balloonanalogrisktask_smdl.json'); - BIDS = bids.layout(data_dir); + BIDS = bids.layout(data_dir, 'index_dependencies', false); events_files = bids.query(BIDS, ... 'data', ... @@ -49,7 +49,7 @@ function test_plot_events_ds108() data_dir = fullfile(get_test_data_dir(), 'ds108'); - BIDS = bids.layout(data_dir); + BIDS = bids.layout(data_dir, 'index_dependencies', false); events_files = bids.query(BIDS, ... 'data', ... diff --git a/tests/utils/run_slow_test_only.m b/tests/utils/run_slow_test_only.m new file mode 100644 index 00000000..72156ed1 --- /dev/null +++ b/tests/utils/run_slow_test_only.m @@ -0,0 +1,9 @@ +function value = run_slow_test_only() + % (C) Copyright 2023 BIDS-MATLAB developers + global SLOW + ENV_SLOW = getenv('SLOW'); + value = false; + if ~isempty(ENV_SLOW) || (~isempty(SLOW) && SLOW) + value = true; + end +end