123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- % Adds a volume timing metadata to the json for each vaso file
- %
- % requires bids-matlab: https://github.com/bids-standard/bids-matlab
- %
- % The 5.16 for the repetition time in the JSON file refers to the average.
- % The TRs from the oscilloscope were 5.1002 and 5.1999 respectively.
- % NOTE:
- % For the first 10 TRs, the scanner was a bit slower (0.0025s).
- % But I think we can ignore that. One would think that a "realtime system" is more accurate
- clear;
- root_dir = fullfile(fileparts(mfilename('fullpath')), '..');
- % this is hard coded here
- % but obviously would have to be adapted dynamically to each file
- TRs = [5.1002; 5.1999];
- nb_volumes = 200;
- %%
- BIDS = bids.layout(root_dir, 'use_schema', false);
- all_files = bids.query(BIDS, 'data', 'suffix', 'vaso');
- all_metadata = bids.query(BIDS, 'metadata', 'suffix', 'vaso');
- for i = 1:numel(all_files)
- bf = bids.File(all_files{i});
- if numel(all_metadata) > 1
- metadata = all_metadata{i};
- else
- metadata = all_metadata;
- end
-
- AcquisitionDuration = repmat(TRs, nb_volumes / numel(TRs), 1);
- metadata.VolumeTiming = cumsum([0 ; AcquisitionDuration(1:end-1)]);
- metadata.AcquisitionDuration = AcquisitionDuration;
- output_file = fullfile(BIDS.pth, ...
- bf.bids_path, ...
- 'func', ...
- bf.json_filename);
- bids.util.jsonencode(output_file, metadata);
- end
|