Skip to content

Commit

Permalink
Merge pull request #89 from Remi-Gau/clean-matlab-comments
Browse files Browse the repository at this point in the history
Clean matlab comments
  • Loading branch information
dorahermes committed Sep 10, 2018
2 parents e016612 + 5c0a008 commit 4c706cf
Show file tree
Hide file tree
Showing 12 changed files with 912 additions and 312 deletions.
35 changes: 24 additions & 11 deletions matlabCode/createBIDS_FullExample_events_tsv.m
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
%% Template Matlab script to create an BIDS compatible sub-01_ses-01_task-FullExample-01_events.tsv file
% This example lists all required and optional fields.
% When adding additional metadata please use camelcase
% When adding additional metadata please use CamelCase
%
%
% anushkab, 2018
% modified RG 201809

%%
clear all
clear
root_dir = '../';
project_label = 'templates';
sub_id = '01';
Expand All @@ -15,7 +16,6 @@
acquisition = 'func';
run_id='01';


events_tsv_name = fullfile(root_dir,project_label,...
['sub-' sub_id],...
['ses-' ses_id],acquisition,...
Expand All @@ -24,25 +24,38 @@
'_task-' task_id ...
'_run-' run_id '_events.tsv']);

%% make a _events table and save
%% CONTAINS a set of REQUIRED and OPTIONAL columns
onset = [0]'; %REQUIRED Onset (in seconds) of the event measured from the beginning of the acquisition of the first volume in the corresponding task imaging data file. If any acquired scans have been discarded before forming the imaging data file, ensure that a time of 0 corresponds to the first image stored. In other words negative numbers in “onset” are allowed.
%% make an event table and save

% REQUIRED. Duration of the event (measured from onset) in seconds. Must always be either zero or positive. A "duration" value of zero implies that the delta function or event is so short as to be effectively modeled as an impulse.
%% CONTAINS a set of REQUIRED and OPTIONAL columns
%REQUIRED Onset (in seconds) of the event measured from the beginning of
% the acquisition of the first volume in the corresponding task imaging data file.
% If any acquired scans have been discarded before forming the imaging data file,
% ensure that a time of 0 corresponds to the first image stored. In other words
% negative numbers in onset are allowed.
onset = [0]';

%REQUIRED. Duration of the event (measured from onset) in seconds.
% Must always be either zero or positive. A "duration" value of zero implies
% that the delta function or event is so short as to be effectively modeled as an impulse.
duration = [0]';

%OPTIONAL Primary categorisation of each trial to identify them as instances of the experimental conditions
%OPTIONAL Primary categorisation of each trial to identify them as instances
% of the experimental conditions
trial_type={' '};

%OPTIONAL. Response time measured in seconds. A negative response time can be used to represent preemptive responses and “n/a” denotes a missed response.
%OPTIONAL. Response time measured in seconds. A negative response time can be
% used to represent preemptive responses and n/a denotes a missed response.
response_time=[0]';

%OPTIONAL Represents the location of the stimulus file (image, video, sound etc.) presented at the given onset time
%OPTIONAL Represents the location of the stimulus file (image, video, sound etc.)
% presented at the given onset time
stim_file={' '};

%OPTIONAL Hierarchical Event Descriptor (HED) Tag.
HED= {' '};


%% Save table
t = table(onset,duration,trial_type,response_time,stim_file,HED);

writetable(t,events_tsv_name,'FileType','text','Delimiter','\t');
193 changes: 109 additions & 84 deletions matlabCode/createBIDS_anat_Full_T1w_json.m

Large diffs are not rendered by default.

70 changes: 35 additions & 35 deletions matlabCode/createBIDS_anat_Short_T1w_json.m
Original file line number Diff line number Diff line change
@@ -1,28 +1,32 @@
%% Template Matlab script to create an BIDS compatible sub-01_ses-01_acq-ShortExample_run-01_T1w.json file
% This example lists only the required fields.
% When adding additional metadata please use camelcase
% When adding additional metadata please use CamelCase
%
%
% anushkab, 2018
% modified RG 201809

%%
clear all
clear
root_dir = '../';
project_label = 'templates';
sub_id = '01';
ses_id = '01';

%The OPTIONAL “acq-<label>” key/value pair corresponds to a custom label the user MAY use to distinguish a different set of parameters used for acquiring the same modality.
%The OPTIONAL acq-<label> key/value pair corresponds to a custom label
% the user MAY use to distinguish a different set of parameters used for
% acquiring the same modality.

acq_id = 'ShortExample';

acquisition = 'anat';

%OPTIONAL “ce-<label>” key/value can be used to distinguish sequences using different contrast enhanced images
%OPTIONAL “rec-<label>” key/value can be used to distinguish different reconstruction algorithms
%OPTIONAL ce-<label> key/value can be used to distinguish sequences
% using different contrast enhanced images
%OPTIONAL rec-<label> key/value can be used to distinguish different
% reconstruction algorithms

run_id='01';


anat_json_name = fullfile(root_dir,project_label,...
['sub-' sub_id],...==
['ses-' ses_id],acquisition,...
Expand All @@ -31,60 +35,56 @@
'_acq-' acq_id ...
'_run-' run_id '_T1w.json']);


%%
% Assign the fields in the Matlab structure that can be saved as a json.
%

%% all REQUIRED metadata fields for Magnetic Resonance Imaging data

% all REQUIRED /RECOMMENDED /OPTIONAL metadata fields for Magnetic Resonance Imaging data



%% In-Plane Spatial Encoding metadata fields

%In-Plane Spatial Encoding metadata fields


%REQUIRED if corresponding fieldmap data is present or when using multiple runs with different phase encoding directions
%PhaseEncodingDirection is defined as the direction along which phase is was modulated which may result in visible distortions.
%REQUIRED if corresponding fieldmap data is present or when using multiple
% runs with different phase encoding directions phaseEncodingDirection is
% defined as the direction along which phase is was modulated which may
% result in visible distortions.
anat_json.PhaseEncodingDirection=' ';



%REQUIRED if corresponding fieldmap data is present.
%The “effective” sampling interval, specified in seconds, between lines in the phase-encoding direction, defined based on the size of the reconstructed image in the phase direction.
%REQUIRED if corresponding fieldmap data is present. The effective sampling
% interval, specified in seconds, between lines in the phase-encoding direction,
% defined based on the size of the reconstructed image in the phase direction.
anat_json.EffectiveEchoSpacing=' ';


%REQUIRED if corresponding “field/distortion” maps acquired with opposing phase encoding directions are present
%This is actually the “effective” total readout time , defined as the readout duration, specified in seconds, that would have generated data with the given level of distortion. It is NOT the actual, physical duration of the readout train
%REQUIRED if corresponding field/distortion maps acquired with opposing phase
% encoding directions are present. This is actually the effective total
% readout time , defined as the readout duration, specified in seconds,
% that would have generated data with the given level of distortion.
% It is NOT the actual, physical duration of the readout train
anat_json.TotalReadoutTime=' ';




%Timing Parameters metadata fields
%% Timing Parameters metadata fields

%REQUIRED if corresponding fieldmap data is present or the data comes from a multi echo sequence
%The echo time (TE) for the acquisition, specified in seconds.
%Corresponds to DICOM Tag 0018, 0081 Echo Time
%Corresponds to DICOM Tag 0018, 0081 "Echo Time"
anat_json.EchoTime=' ';



%REQUIRED for sparse sequences that do not have the DelayTime field set. In addition without this parameter slice time correction will not be possible.
%The time at which each slice was acquired within each volume (frame) of the acquisition.
%REQUIRED for sparse sequences that do not have the DelayTime field set.
% In addition without this parameter slice time correction will not be possible.
%The time at which each slice was acquired within each volume (frame) of the acquisition.
anat_json.SliceTiming=' ';




json_options.indent = ' '; % this makes the json look pretier when opened in a txt editor
%% Write JSON
% this makes the json look pretier when opened in a txt editor
json_options.indent = ' ';

jsonSaveDir = fileparts(anat_json_name);
if ~isdir(jsonSaveDir)
fprintf('Warning: directory to save json file does not exist, create: %s \n',jsonSaveDir)
end


jsonwrite(anat_json_name,anat_json,json_options)


Loading

0 comments on commit 4c706cf

Please sign in to comment.