I have extended the Matlab script (below) to also handle temporal gaps between volumes. If you use multi-band (HyperBand for GE users) you will want to work with your vendor Research Collaboration Manager to get the slice acquisition pattern. The very short TR afforded by Multi-Band reduces the slice timing errors, and it is not clear to me if slice timing correction is required as the HRF is sluggish and the temporal derivative can model some of this consistent variance from the canonical HRF.
function slicetime(TRsec, nSlices, isAscending, isSequential, DelayBetweenVolumesSec);
%compute slice timing
% TRsec : sampling rate (TR) in seconds
% nSlices: number of slices in each 3D volume
% isAscending: ascending (true) or descending (false) order
% isSequential: interleaved (false) or sequential (true) order
% DelayBetweenVolumesSec: pause between final slice of volume and start of next
%Examples
% sliceTime(2.0, 10, true, true); %ascending, sequential
% sliceTime(2.0, 10, false, true); %descending, sequential
% sliceTime(2.0, 10, true, false); %ascending, interleaved
% sliceTime(2.0, 10, false, false); %descending, interleaved
% sliceTime(3.0, 10, true, true, 1.0); %ascending, sequential, sparse
if ~exist('DelayBetweenVolumesSec', 'var')
DelayBetweenVolumesSec = 0; %continuous acquisition
end
TA = (TRsec - DelayBetweenVolumesSec) / nSlices; %assumes no temporal gap between volumes
bidsSliceTiming=[0:TA:TRsec-TA]; %ascending
if ~isAscending %descending
bidsSliceTiming = flip(bidsSliceTiming);
end
if ~isSequential %interleaved
if ~mod(nSlices,2)
fprintf('Timings for Philips or GE. Siemens volume with even number of slices differs https://www.mccauslandcenter.sc.edu/crnl/tools/stc)\n');
end
order = [1:2:nSlices 2:2:nSlices];
bidsSliceTiming(order) = bidsSliceTiming;
end
%report results
fprintf(' "SliceTiming": [\n');
for i = 1 : nSlices
fprintf(' %.3f', bidsSliceTiming(i));
if (i < nSlices)
fprintf(',\n');
else
fprintf(' ],\n');
end
end