Skip to content

Commit

Permalink
[FIX] inconsistent slice timing throw errors and not warnings (#982)
Browse files Browse the repository at this point in the history
* inconsistent slice timing throw errors and not warnings

* update doc

* fix tests

* update doc
  • Loading branch information
Remi-Gau authored Apr 20, 2023
1 parent eb140c2 commit 661901e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/batches/stats/setBatchSubjectLevelGLMSpec.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@
try
hdr = spm_vol(fullpathBoldFilename);
catch
warning('Could not open %s.\nThis expected during testing.', fullpathBoldFilename);
warning('Could not open %s.\nExpected during testing.', fullpathBoldFilename);
% TODO a value should be passed by user for this
% hard coded value for test
hdr = ones(200, 1);
Expand Down
23 changes: 12 additions & 11 deletions src/bids/getAndCheckSliceOrder.m
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
function sliceOrder = getAndCheckSliceOrder(BIDS, opt, filter)
%
% Get the slice order information from the BIDS metadata.
% If inconsistent slice timing is found across files it returns empty and
% throws a warning.
% If inconsistent slice timing is found across files
% it throws an error.
%
% USAGE::
%
Expand All @@ -20,10 +20,10 @@
% - :sliceOrder: a vector of the time when each slice was acquired in
% in a volume or indicating the order of acquisition of the slices.
%
% ``getAndCheckSliceOrder`` will try to read the ``opt`` structure for any relevant information
% about slice timing.
% If this is empty, it queries the BIDS dataset to ee if there is any
% consistent slice timing information for a given ``filter``
% ``getAndCheckSliceOrder`` will try to read the ``opt`` structure
% for any relevant information about slice timing.
% If this is empty, it queries the BIDS dataset to see if there is any
% consistent slice timing information for a given ``filter``.
%
% See also: bidsSTC, setBatchSTC
%
Expand Down Expand Up @@ -57,10 +57,11 @@

sliceOrder = [];

msg = sprintf('inconsistent slice timing found for filter:\n%s.\n\n', ...
msg = sprintf(['Inconsistent slice timing found for filter:\n%s.\n\n', ...
'Number of slice per volume seems different across bold files.'], ...
bids.internal.create_unordered_list(filter));
id = 'inconsistentSliceTiming';
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);
id = 'inconsistentSliceTimingLength';
logger('ERROR', msg, 'id', id, 'filename', mfilename(), 'options', opt);

return

Expand All @@ -76,9 +77,9 @@

sliceOrder = [];

wng = sprintf('inconsistent slice timing found for filter:\n%s.\n\n', ...
msg = sprintf('Inconsistent slice timing found for filter:\n%s.\n\n', ...
bids.internal.create_unordered_list(filter));
id = 'inconsistentSliceTiming';
id = 'inconsistentSliceTimingValues';
logger('WARNING', msg, 'id', id, 'filename', mfilename(), 'options', opt);

return
Expand Down
2 changes: 1 addition & 1 deletion src/messages/bidspmHelp.m
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function bidspmHelp()
% Se to ``true`` to overwrites previous versions.
% :type boilerplate_only: logical
%
% :param verbosity: can be ``0``, ``1`` or ``2``. Defaults to ``2``
% :param verbosity: can be any value between ``0`` and ``3``. Defaults to ``2``
% :type verbosity: positive integer
%
% :param space: Defaults to ``{'individual', 'IXI549Space'}``
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ function test_setBatchSubjectLevelGLMSpec_inconsistent_metadata()
%% WHEN
matlabbatch = {};
assertExceptionThrown(@()setBatchSubjectLevelGLMSpec(matlabbatch, BIDS, opt, subLabel), ...
'getAndCheckRepetitionTime:differentRepetitionTime');
'getAndCheckSliceOrder:inconsistentSliceTimingLength');

end

Expand Down
5 changes: 2 additions & 3 deletions tests/tests_bids/unit_tests/test_getAndCheckSliceOrder.m
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ function test_getAndCheckSliceOrder_inconsistent_slice_timing()

[BIDS, opt, filter] = setUp({'vismotion', 'vislocalizer'});

sliceOrder = getAndCheckSliceOrder(BIDS, opt, filter);

assert(isempty(sliceOrder));
assertExceptionThrown(@()getAndCheckSliceOrder(BIDS, opt, filter), ...
'getAndCheckSliceOrder:inconsistentSliceTimingLength');

end

Expand Down

0 comments on commit 661901e

Please sign in to comment.