From a18c50e763dcb09a42eb95d1e343550cff71ec21 Mon Sep 17 00:00:00 2001 From: Remi Gau Date: Sun, 24 Mar 2024 16:53:42 +0100 Subject: [PATCH] reduce amount of warnings --- +bids/+internal/return_subject_index.m | 4 +++- tests/tests_layout/test_layout_derivatives.m | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/+bids/+internal/return_subject_index.m b/+bids/+internal/return_subject_index.m index 74d8b04f..33ae45a2 100644 --- a/+bids/+internal/return_subject_index.m +++ b/+bids/+internal/return_subject_index.m @@ -22,10 +22,12 @@ sub_idx = strcmp(['sub-' sub], {BIDS.subjects.name}'); - ses_idx = true(size(sub_idx)); if isfield(parsed_file.entities, 'ses') ses = parsed_file.entities.ses; ses_idx = strcmp(['ses-' ses], {BIDS.subjects.session}'); + else + % in case we have modality on same level as sessions + ses_idx = cellfun('isempty', {BIDS.subjects.session})'; end sub_idx = find(all([sub_idx, ses_idx], 2)); diff --git a/tests/tests_layout/test_layout_derivatives.m b/tests/tests_layout/test_layout_derivatives.m index 546f543e..89239de2 100644 --- a/tests/tests_layout/test_layout_derivatives.m +++ b/tests/tests_layout/test_layout_derivatives.m @@ -18,6 +18,9 @@ function test_layout_modality_same_level_sessions() 'use_schema', false, ... 'filter', struct('sub', {{'01', '02', '03'}}), ... 'index_dependencies', true); + + % the name won't be accurate + % because the filenames will still contain the ses entity for i = 1:3 copyfile(fullfile(pth_bids_example, sprintf('sub-%02.0f', i), 'ses-01', 'func'), ... fullfile(pth_bids_example, sprintf('sub-%02.0f', i), 'func'));