Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TODO: check if tsvwrite can handle datetime data #607

Open
Remi-Gau opened this issue Aug 1, 2023 · 2 comments
Open

TODO: check if tsvwrite can handle datetime data #607

Remi-Gau opened this issue Aug 1, 2023 · 2 comments

Comments

@Remi-Gau
Copy link
Collaborator

Remi-Gau commented Aug 1, 2023

No description provided.

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Aug 2, 2023

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)

@Remi-Gau
Copy link
Collaborator Author

Remi-Gau commented Aug 2, 2023

@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')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant