Skip to content

Commit 6db8641

Browse files
authored
Merge pull request #1 from anushkab/anushkab
Anushkab
2 parents 1dad59d + 34f8b62 commit 6db8641

File tree

4 files changed

+366
-0
lines changed

4 files changed

+366
-0
lines changed
Lines changed: 226 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,226 @@
1+
%% Template Matlab script to create an BIDS compatible sub-01_ses-01_acq-FullExample_run-01_T1w.json file
2+
% This example lists all required RECOMMENDED and optional fields.
3+
% When adding additional metadata please use camelcase
4+
%
5+
%
6+
% anushkab, 2018
7+
%%
8+
clear all
9+
root_dir = '../';
10+
project_label = 'templates';
11+
sub_id = '01';
12+
ses_id = '01';
13+
14+
%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.
15+
16+
acq_id = 'FullExample';
17+
18+
acquisition = 'anat';
19+
20+
%OPTIONAL “ce-<label>” key/value can be used to distinguish sequences using different contrast enhanced images
21+
%OPTIONAL “rec-<label>” key/value can be used to distinguish different reconstruction algorithms
22+
23+
run_id='01';
24+
25+
26+
anat_json_name = fullfile(root_dir,project_label,...
27+
['sub-' sub_id],...==
28+
['ses-' ses_id],acquisition,...
29+
['sub-' sub_id ...
30+
'_ses-' ses_id ...
31+
'_acq-' acq_id ...
32+
'_run-' run_id '_T1w.json']);
33+
34+
% Assign the fields in the Matlab structure that can be saved as a json.
35+
%
36+
37+
%% all REQUIRED /RECOMMENDED /OPTIONAL metadata fields for Magnetic Resonance Imaging data
38+
39+
40+
41+
42+
43+
%Scanner Hardware metadata fields
44+
45+
%RECOMMENDED Manufacturer of the equipment that produced the composite instances.
46+
anat_json.Manufacturer=' ';
47+
48+
%RECOMMENDED Manufacturer`s model name of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 1090 “Manufacturers Model Name”.
49+
anant_json.ManufacturersModelName=' ';
50+
51+
%RECOMMENDED Nominal field strength of MR magnet in Tesla. Corresponds to DICOM Tag 0018,0087 “Magnetic Field Strength” .
52+
anat_json.MagneticFieldStrength=' ';
53+
54+
55+
%RECOMMENDED The serial number of the equipment that produced the composite instances. Corresponds to DICOM Tag 0018, 1000 ”DeviceSerialNumber”.
56+
anat_json.DeviceSerialNumber=' ';
57+
58+
%RECOMMENDED Institution defined name of the machine that produced the composite instances. Corresponds to DICOM Tag 0008, 1010 “Station Name”
59+
anat_json.StationName= ' ';
60+
61+
%RECOMMENDED Manufacturer’s designation of software version of the equipment that produced the composite instances. Corresponds to DICOM Tag 0018, 1020 “Software Versions”.
62+
anat_json.SoftwareVersions= ' ';
63+
64+
%RECOMMENDED (Deprecated) Manufacturer’s designation of the software of the device that created this Hardcopy Image (the printer). Corresponds to DICOM Tag 0018, 101A “Hardcopy Device Software Version”
65+
anat_json.HardcopyDeviceSoftwareVersion=' ';
66+
67+
%RECOMMENDED Information describing the receiver coil
68+
anat_json.ReceiveCoilName= ' ' ;
69+
70+
%RECOMMENDED Information describing the active/selected elements of the receiver coil.
71+
anat_json.ReceiveCoilActiveElements=' ';
72+
73+
74+
%RECOMMENDED the specifications of the actual gradient coil from the scanner model
75+
76+
anat_json.GradientSetType=' ';
77+
78+
79+
%RECOMMENDED This is a relevant field if a non-standard transmit coil is used. Corresponds to DICOM Tag 0018, 9049 “MR Transmit Coil Sequence”.
80+
anat_json.MRTransmitCoilSequence=' ';
81+
82+
%RECOMMENDED A method for reducing the number of independent channels by combining in analog the signals from multiple coil elements. There are typically different default modes when using un-accelerated or accelerated (e.g. GRAPPA, SENSE) imaging
83+
anat_json.MatrixCoilMode=' ';
84+
85+
%RECOMMENDED Almost all fMRI studies using phased-array coils use root-sum-of-squares (rSOS) combination, but other methods exist. The image reconstruction is changed by the coil combination method (as for the matrix coil mode above), so anything non-standard should be reported.
86+
anat_json.CoilCombinationMethod=' ';
87+
88+
89+
90+
%Sequence Specifics metadata fields
91+
92+
%RECOMMENDED A general description of the pulse sequence used for the scan (i.e. MPRAGE, Gradient Echo EPI, Spin Echo EPI, Multiband gradient echo EPI).
93+
anat_json.PulseSequenceType=' ';
94+
95+
%RECOMMENDED Description of the type of data acquired. Corresponds to DICOM Tag 0018, 0020 “Sequence Sequence”.
96+
anat_json.ScanningSequence=' ';
97+
98+
%RECOMMENDED Variant of the ScanningSequence. Corresponds to DICOM Tag 0018, 0021 “Sequence Variant”.
99+
anat_json.SequenceVariant=' ';
100+
101+
%RECOMMENDED Parameters of ScanningSequence. Corresponds to DICOM Tag 0018, 0022 “Scan Options”.
102+
anat_json.ScanOptions=' ';
103+
104+
%RECOMMENDED Manufacturer’s designation of the sequence name. Corresponds to DICOM Tag 0018, 0024 “Sequence Name”.
105+
anat_json.SequenceName=' ';
106+
107+
108+
%RECOMMENDED Information beyond pulse sequence type that identifies the specific pulse sequence used
109+
anat_json.PulseSequenceDetails=' ';
110+
111+
%RECOMMENDED Boolean stating if the image saved has been corrected for gradient nonlinearities by the scanner sequence.
112+
anat_json.NonlinearGradientCorrection=' ';
113+
114+
115+
116+
%In-Plane Spatial Encoding metadata fields
117+
118+
%RECOMMENDED The number of RF excitations need to reconstruct a slice or volume. Please mind that this is not the same as Echo Train Length which denotes the number of lines of k-space collected after an excitation.
119+
anat_json.NumberShots=' ';
120+
121+
%RECOMMENDED The parallel imaging (e.g, GRAPPA) factor. Use the denominator of the fraction of k-space encoded for each slice.
122+
anat_json.ParallelReductionFactorInPlane=' ';
123+
124+
%RECOMMENDED The type of parallel imaging used (e.g. GRAPPA, SENSE). Corresponds to DICOM Tag 0018, 9078 “Parallel Acquisition Technique”.
125+
anat_json.ParallelAcquisitionTechnique=' ';
126+
127+
%RECOMMENDED The fraction of partial Fourier information collected. Corresponds to DICOM Tag 0018, 9081 ”Partial Fourier”.
128+
anat_json.PartialFourier=' ';
129+
130+
%RECOMMENDED The direction where only partial Fourier information was collected. Corresponds to DICOM Tag 0018, 9036 “Partial Fourier Direction
131+
anat_json.PartialFourierDirection=' ';
132+
133+
%REQUIRED if corresponding fieldmap data is present or when using multiple runs with different phase encoding directions
134+
%PhaseEncodingDirection is defined as the direction along which phase is was modulated which may result in visible distortions.
135+
anat_json.PhaseEncodingDirection=' ';
136+
137+
138+
139+
%REQUIRED if corresponding fieldmap data is present.
140+
%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.
141+
anat_json.EffectiveEchoSpacing=' ';
142+
143+
144+
%REQUIRED if corresponding “field/distortion” maps acquired with opposing phase encoding directions are present
145+
%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
146+
anat_json.TotalReadoutTime=' ';
147+
148+
%RECOMMENDED defined as the displacement of the water signal with respect to fat signal in the image. Water-fat shift (WFS) is expressed in number of pixels
149+
anat_json.WaterFatShift=' ';
150+
151+
%RECOMMENDED Number of lines in k-space acquired per excitation per image.
152+
anat_json.EchoTrainLength=' ';
153+
154+
155+
156+
%Timing Parameters metadata fields
157+
158+
%REQUIRED if corresponding fieldmap data is present or the data comes from a multi echo sequence
159+
%The echo time (TE) for the acquisition, specified in seconds.
160+
%Corresponds to DICOM Tag 0018, 0081 “Echo Time”
161+
anat_json.EchoTime=' ';
162+
163+
164+
165+
%RECOMMENDED The inversion time (TI) for the acquisition, specified in seconds. Inversion time is the time after the middle of inverting RF pulse to middle of excitation pulse to detect the amount of longitudinal magnetization
166+
anat_json.InversionTime=' ';
167+
168+
%REQUIRED for sparse sequences that do not have the DelayTime field set. In addition without this parameter slice time correction will not be possible.
169+
%The time at which each slice was acquired within each volume (frame) of the acquisition.
170+
anat_json.SliceTiming=' ';
171+
172+
173+
%RECOMMENDED Possible values: “i”, “j”, “k”, “i-”, “j-”, “k-” (the axis of the NIfTI data along which slices were acquired, and the direction in which SliceTiming is defined with respect to). "i", "j", "k" identifiers correspond to the first, second and third axis of the data in the NIfTI file
174+
%When present ,the axis defined by SliceEncodingDirection needs to be consistent with the ‘slice_dim’ field in the NIfTI header.
175+
anat_json.SliceEncodingDirection=' ';
176+
177+
%RECOMMENDED Actual dwell time (in seconds) of the receiver per point in the readout direction, including any oversampling. For Siemens, this corresponds to DICOM field (0019,1018) (in ns).
178+
anat_json.DwellTime=' ';
179+
180+
181+
%RF & Contrast metadata field
182+
183+
%RECOMMENDED Flip angle for the acquisition, specified in degrees. Corresponds to: DICOM Tag 0018, 1314 “Flip Angle”.
184+
anat_json.FlipAngle=' ';
185+
186+
187+
%Slice Acceleration metadata field
188+
189+
%RECOMMENDED The multiband factor, for multiband acquisitions.
190+
anat_json.MultibandAccelerationFactor=' ';
191+
192+
193+
%Anatomical landmarks metadata fields
194+
195+
%RECOMMENDED Key:value pairs of any number of additional anatomical landmarks and their coordinates in voxel units
196+
anat_json.AnatomicalLandmarkCoordinates=' ';
197+
198+
%Institution information metadata fields
199+
200+
201+
%RECOMMENDED The name of the institution in charge of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 0080 ”InstitutionName”.
202+
anat_json.InstitutionName=' ';
203+
204+
%RECOMMENDED The address of the institution in charge of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 0081 ”InstitutionAddress”
205+
anat_json.InstitutionAddress=' ';
206+
207+
%RECOMMENDED The department in the institution in charge of the equipment that produced the composite instances. Corresponds to DICOM Tag 0008, 1040 ”Institutional Department Name”.
208+
anat_json.InstitutionalDepartmentName=' ';
209+
210+
211+
%OPTIONAL JSON field specific to anatomical scans
212+
%Active ingredient of agent. Values MUST be one of: IODINE, GADOLINIUM, CARBON DIOXIDE, BARIUM, XENON Corresponds to DICOM Tag 0018,1048.
213+
anat_json.ContrastBolusIngredient=' ';
214+
215+
216+
json_options.indent = ' '; % this makes the json look pretier when opened in a txt editor
217+
218+
jsonSaveDir = fileparts(anat_json_name);
219+
if ~isdir(jsonSaveDir)
220+
fprintf('Warning: directory to save json file does not exist, create: %s \n',jsonSaveDir)
221+
end
222+
223+
224+
jsonwrite(anat_json_name,anat_json,json_options)
225+
226+
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
%% Template Matlab script to create an BIDS compatible sub-01_ses-01_acq-ShortExample_run-01_T1w.json file
2+
% This example lists only the required fields.
3+
% When adding additional metadata please use camelcase
4+
%
5+
%
6+
% anushkab, 2018
7+
%%
8+
clear all
9+
root_dir = '../';
10+
project_label = 'templates';
11+
sub_id = '01';
12+
ses_id = '01';
13+
14+
%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.
15+
16+
acq_id = 'ShortExample';
17+
18+
acquisition = 'anat';
19+
20+
%OPTIONAL “ce-<label>” key/value can be used to distinguish sequences using different contrast enhanced images
21+
%OPTIONAL “rec-<label>” key/value can be used to distinguish different reconstruction algorithms
22+
23+
run_id='01';
24+
25+
26+
anat_json_name = fullfile(root_dir,project_label,...
27+
['sub-' sub_id],...==
28+
['ses-' ses_id],acquisition,...
29+
['sub-' sub_id ...
30+
'_ses-' ses_id ...
31+
'_acq-' acq_id ...
32+
'_run-' run_id '_T1w.json']);
33+
34+
% Assign the fields in the Matlab structure that can be saved as a json.
35+
%
36+
37+
%% all REQUIRED metadata fields for Magnetic Resonance Imaging data
38+
39+
40+
41+
42+
43+
%In-Plane Spatial Encoding metadata fields
44+
45+
46+
%REQUIRED if corresponding fieldmap data is present or when using multiple runs with different phase encoding directions
47+
%PhaseEncodingDirection is defined as the direction along which phase is was modulated which may result in visible distortions.
48+
anat_json.PhaseEncodingDirection=' ';
49+
50+
51+
52+
%REQUIRED if corresponding fieldmap data is present.
53+
%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.
54+
anat_json.EffectiveEchoSpacing=' ';
55+
56+
57+
%REQUIRED if corresponding “field/distortion” maps acquired with opposing phase encoding directions are present
58+
%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
59+
anat_json.TotalReadoutTime=' ';
60+
61+
62+
63+
64+
%Timing Parameters metadata fields
65+
66+
%REQUIRED if corresponding fieldmap data is present or the data comes from a multi echo sequence
67+
%The echo time (TE) for the acquisition, specified in seconds.
68+
%Corresponds to DICOM Tag 0018, 0081 “Echo Time”
69+
anat_json.EchoTime=' ';
70+
71+
72+
73+
%REQUIRED for sparse sequences that do not have the DelayTime field set. In addition without this parameter slice time correction will not be possible.
74+
%The time at which each slice was acquired within each volume (frame) of the acquisition.
75+
anat_json.SliceTiming=' ';
76+
77+
78+
79+
80+
json_options.indent = ' '; % this makes the json look pretier when opened in a txt editor
81+
82+
jsonSaveDir = fileparts(anat_json_name);
83+
if ~isdir(jsonSaveDir)
84+
fprintf('Warning: directory to save json file does not exist, create: %s \n',jsonSaveDir)
85+
end
86+
87+
88+
jsonwrite(anat_json_name,anat_json,json_options)
89+
90+
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"Manufacturer": " ",
3+
"MagneticFieldStrength": " ",
4+
"DeviceSerialNumber": " ",
5+
"StationName": " ",
6+
"SoftwareVersions": " ",
7+
"HardcopyDeviceSoftwareVersion": " ",
8+
"ReceiveCoilName": " ",
9+
"ReceiveCoilActiveElements": " ",
10+
"GradientSetType": " ",
11+
"MRTransmitCoilSequence": " ",
12+
"MatrixCoilMode": " ",
13+
"CoilCombinationMethod": " ",
14+
"PulseSequenceType": " ",
15+
"ScanningSequence": " ",
16+
"SequenceVariant": " ",
17+
"ScanOptions": " ",
18+
"SequenceName": " ",
19+
"PulseSequenceDetails": " ",
20+
"NonlinearGradientCorrection": " ",
21+
"NumberShots": " ",
22+
"ParallelReductionFactorInPlane": " ",
23+
"ParallelAcquisitionTechnique": " ",
24+
"PartialFourier": " ",
25+
"PartialFourierDirection": " ",
26+
"PhaseEncodingDirection": " ",
27+
"EffectiveEchoSpacing": " ",
28+
"TotalReadoutTime": " ",
29+
"WaterFatShift": " ",
30+
"EchoTrainLength": " ",
31+
"EchoTime": " ",
32+
"InversionTime": " ",
33+
"SliceTiming": " ",
34+
"SliceEncodingDirection": " ",
35+
"DwellTime": " ",
36+
"FlipAngle": " ",
37+
"MultibandAccelerationFactor": " ",
38+
"AnatomicalLandmarkCoordinates": " ",
39+
"InstitutionName": " ",
40+
"InstitutionAddress": " ",
41+
"InstitutionalDepartmentName": " ",
42+
"ContrastBolusIngredient": " "
43+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"PhaseEncodingDirection": " ",
3+
"EffectiveEchoSpacing": " ",
4+
"TotalReadoutTime": " ",
5+
"EchoTime": " ",
6+
"SliceTiming": " "
7+
}

0 commit comments

Comments
 (0)