Skip to content

Commit

Permalink
try speed up test by not indexing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Aug 17, 2023
1 parent 990ed3a commit 49ba5e1
Show file tree
Hide file tree
Showing 23 changed files with 130 additions and 93 deletions.
2 changes: 2 additions & 0 deletions +bids/+internal/list_all_trial_types.m
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

trial_type_list = {};

BIDS = bids.layout(BIDS, 'index_dependencies', false);

event_files = bids.query(BIDS, 'data', ...
'suffix', 'events', ...
'extension', '.tsv', ...
Expand Down
3 changes: 2 additions & 1 deletion +bids/diagnostic.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion tests/test_diagnostic.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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);
Expand Down
8 changes: 4 additions & 4 deletions tests/test_report.m
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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';

Expand Down Expand Up @@ -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, ...
Expand Down
12 changes: 2 additions & 10 deletions tests/tests_layout/test_layout.m
Original file line number Diff line number Diff line change
Expand Up @@ -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'}}));
Expand All @@ -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]'}}));
Expand All @@ -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
47 changes: 25 additions & 22 deletions tests/tests_layout/test_layout_derivatives.m
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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

Expand All @@ -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);
Expand All @@ -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', ...
Expand All @@ -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'};
Expand Down Expand Up @@ -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
2 changes: 2 additions & 0 deletions tests/tests_layout/test_layout_schemaless.m
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand Down
12 changes: 4 additions & 8 deletions tests/tests_private/test_append_to_layout.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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', '', ...
Expand Down Expand Up @@ -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', '', ...
Expand Down Expand Up @@ -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), ...
Expand Down
Loading

0 comments on commit 49ba5e1

Please sign in to comment.