Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
NMR_OPTIMA_BIDS/OPTIMA_dataset_description_BIDS.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
50 lines (39 sloc)
1.26 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function OPTIMA_dataset_description_BIDS(BIDS,biomax_table) | |
% | |
% create BIDS dataset description json file | |
% | |
% | |
% file history: | |
% created M. Czisch 13.2.2018 | |
% last 2.3.2018 | |
clear jsonstruct; | |
fprintf('creating data set description\n'); | |
% make file for general remarks | |
fname_out = [BIDS.output.dir,'/general_README.txt']; | |
cmd_str = ['touch ', fname_out]; system(cmd_str); | |
% read general info from master file | |
fname_out = [BIDS.output.dir,'/general_description_',BIDS.input.data_dir(1).PatientID{3},'.json']; | |
cmd_str = ['rm -rf ', fname_out]; system(cmd_str); | |
fid2 = fopen(fname_out,'a'); | |
fname = [BIDS.autoscripts.dir,'/masterfile_1_0_2.json']; | |
fid = fopen(fname); | |
last_line = fgetl(fid); | |
while ~strcmp(last_line,'}') | |
if strcmp(last_line,'{') | |
second_to_last_line = last_line; | |
last_line = fgetl(fid); | |
else | |
fprintf(fid2, '%s\n', second_to_last_line); | |
second_to_last_line = last_line; | |
last_line = fgetl(fid); | |
end | |
end | |
fprintf(fid2, '%s,\n', second_to_last_line); | |
% add specific info for current dataset | |
str = ['"TimeOfConversion": "',char(date),'"']; | |
fprintf(fid2, ' %s,\n', str); | |
str = ['"PatientID": "',[BIDS.output.dir],'"']; | |
fprintf(fid2, ' %s\n', str); | |
str = '}'; | |
fprintf(fid2, '%s', str); | |
fclose(fid); fclose(fid2); |