bids-matlab
bids-matlab copied to clipboard
TODO: check if tsvwrite can handle datetime data
function test_datetime_in_struct()
if bids.internal.is_octave()
moxunit_throw_test_skipped_exception('no datetime in Octave');
end
x = '201401010000';
acq_time = datetime(x, 'InputFormat', 'yyyyMMddHHmm');
sub_id = {'foo'};
patients = struct('sub_id', sub_id, 'acq_time', acq_time);
file = fullfile(tempname(), 'foo.tsv');
bids.util.mkdir(fileparts(file));
bids.util.tsvwrite(file, patients);
end
Fails:
failure: Error using num2str (line 53)
Input to num2str must be numeric.
num2str:53 (/usr/local/MATLAB/R2018a/toolbox/matlab/strfun/num2str.p)
tsvwrite:42 (/home/remi/github/bids/matlab/+bids/+util/tsvwrite.m)
test_datetime_in_struct:19 (/home/remi/github/bids/matlab/tests/tests_utils/test_tsvwrite.m)
@gllmflndn
I implemented a dirty hack in case the datatime are in table but I am pinging you in case you have better ideas to solve this: at the moment the strategy is to write all dates in a "BIDS" format ('yyyy-MM-dd''T''HH:mm:ss.SSS')