Skip to content
Permalink
02f25a58e6
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
68 lines (57 sloc) 2.45 KB
function dataset_description_BIDS(BIDS,biomax_table)
%
% create BIDS dataset description json file
%
%
% file history:
% created M. Czisch 13.2.2018
clear jsonstruct;
% read general info from master file
fname_out = [BIDS.autoscripts.dir,'/test.json'];
cmd_str = ['rm -rf ', fname_out]; system(cmd_str);
fid2 = fopen(fname_out,'a');
fname = [BIDS.autoscripts.dir,'/masterfile.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);
short_ID = data_set_short_ID(BIDS);
str = ['"PatientID": "',[BIDS.output.dir, short_ID],'"'];
fprintf(fid2, ' %s\n', str);
% biomax -> json
% cave: a minus sign is not allowed in the json name
% therefore, e.g. "rest_run-1" needs to be replaced by "rest_run_1"
% jsonstruct.Loc = jsonencode(biomax_table(1,:));
% jsonstruct.T1w = jsonencode(biomax_table(2,:));
% jsonstruct.Cal = jsonencode(biomax_table(3,:));
% jsonstruct.rest_run_1 = jsonencode(biomax_table(4,:));
% jsonstruct.inplaneT2star_run_1 = jsonencode(biomax_table(5,:));
% jsonstruct.tet = jsonencode(biomax_table(6,:));
% jsonstruct.FLAIR = jsonencode(biomax_table(7,:));
% jsonstruct.reward = jsonencode(biomax_table(8,:));
% jsonstruct.run_1_dwi = jsonencode(biomax_table(9,:));
% jsonstruct.run_2_dwi = jsonencode(biomax_table(10,:));
% jsonstruct.nback = jsonencode(biomax_table(11,:));
% jsonstruct.Loc2 = jsonencode(biomax_table(12,:));
% jsonstruct.Cal2 = jsonencode(biomax_table(13,:));
% jsonstruct.hariri = jsonencode(biomax_table(14,:));
% jsonstruct.inplaneT2star_run_2 = jsonencode(biomax_table(15,:));
% jsonstruct.rest_run_2 = jsonencode(biomax_table(16,:));
% jsonstruct.ist = jsonencode(biomax_table(17,:));
% jsonstruct.Loc3 = jsonencode(biomax_table(18,:));
% jsonstruct.rest_run_3 = jsonencode(biomax_table(19,:));
str = '}';
fprintf(fid2, '%s', str);
fclose(fid); fclose(fid2);