Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 40 additions & 12 deletions matlab/updatejsonpetfile.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
% information, if only the jsonfile is provided, it only checks if valid
% (and possibly updates some fields from scalar to array)
%
% :format: - status = updatejsonpetfile(jsonfilename,newfields,dcminfo)
% :format: - status = updatejsonpetfile(jsonfilename)
% - status = updatejsonpetfile(jsonfilename,newfields,dcminfo)
%
% :param jsonfilename: json file to check or update update
% can also be the json structure (add field filename to ensure update on disk)
% can also be the json structure
% :param newfields: (optional) a structure with the newfields to go into the json file
% :param dcminfo: (optional) a dcmfile or the dicominfo structure from a representative
% dicom file. This information is used to also update the json
Expand Down Expand Up @@ -85,7 +86,27 @@
jsonwrite(jsonfilename,orderfields(filemetadata));
end

% -------------- only check --------------
% -------------- only check ---------------

% conditionally fields for recon method and filters to update
if iscell(filemetadata.ReconMethodParameterLabels)
test = ~contains("none",cellfun(@(x) x{1}, filemetadata.ReconMethodParameterLabels));
else
test = ~contains("none",filemetadata.ReconMethodParameterLabels);
end

if test
petmetadata.mandatory{end+1} = 'ReconMethodParameterUnits';
petmetadata.mandatory{end+1} = 'ReconMethodParameterValues';
petmetadata.optional(strcmpi('ReconMethodParameterUnits',petmetadata.optional))=[];
petmetadata.optional(strcmpi('ReconMethodParameterValues',petmetadata.optional))=[];
end

if ~contains("none",filemetadata.ReconFilterType)
petmetadata.mandatory{end+1} = 'ReconFilterType';
petmetadata.recommended(strcmpi('ReconFilterType',petmetadata.recommended))=[];
end

for m=length(petmetadata.mandatory):-1:1
test(m) = isfield(filemetadata,petmetadata.mandatory{m});
end
Expand Down Expand Up @@ -367,13 +388,11 @@
filemetadata.ReconMethodParameterValues = [str2double(subset),str2double(iteration)];
else % returns none if actually seen as empty by get_recon_method
filemetadata.ReconMethodParameterLabels = "none";
filemetadata.ReconMethodParameterUnits = "none";
try
if isempty(filemetadata.ReconMethodParameterValues) % in case user passes info
filemetadata.ReconMethodParameterValues = 0; % if none should be 0
end
catch
filemetadata.ReconMethodParameterValues = 0;
if isfield(filemetadata,'ReconMethodParameterUnits')
filemetadata = rmfield(filemetadata,'ReconMethodParameterUnits');
end
if isfield(filemetadata,'ReconMethodParameterValues')
filemetadata = rmfield(filemetadata,'ReconMethodParameterValues');
end
end
end
Expand Down Expand Up @@ -416,8 +435,15 @@
else
filemetadata.ReconFilterSize = str2double(FilterSize);
end

elseif contains(filtername,'Rad','IgnoreCase',true)
filemetadata.ReconFilterType = 'none';
if isfield(filemetadata,'ReconFilterSize')
filemetadata = rmfield(filemetadata,'ReconFilterSize');
end

else

% might need to remove trailing .00 for regex to work
if contains(filtername,'.00') && ~contains(filtername,{'/','\'})
loc = strfind(filtername,'.00');
Expand All @@ -438,7 +464,9 @@
end
else
filemetadata.ReconFilterType = "none";
filemetadata.ReconFilterSize = 0; % conditional on ReconFilterType
if isfield(filemetadata,'ReconFilterSize')
filemetadata = rmfield(filemetadata,'ReconFilterSize');
end
end

function [filemetadata,updated] = update_arrays(filemetadata)
Expand Down
8 changes: 4 additions & 4 deletions metadata/PET_metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"ImageDecayCorrectionTime",
"ReconMethodName",
"ReconMethodParameterLabels",
"ReconMethodParameterUnits",
"ReconFilterType",
"AttenuationCorrection"
],
Expand Down Expand Up @@ -62,12 +61,13 @@
"DecayCorrectionFactor",
"PromptRate",
"RandomRate",
"SinglesRate"
"SinglesRate",
"ReconFilterSize"
],
"optional": [
"Anaesthesia",
"ReconMethodParameterValues",
"ReconFilterSize"
"ReconMethodParameterUnits",
"ReconMethodParameterValues"
],
"blood_recording_fields": [
"PlasmaAvail",
Expand Down
42 changes: 16 additions & 26 deletions metadata/PET_reconstruction_methods.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,38 +72,28 @@
},
{
"contents": "LOR-RAMLA",
"subsets": null,
"iterations": null,
"ReconMethodName": "Line Of Response - Row Action Maximum Likelihood",
"ReconMethodParameterUnits": [
"none",
"none"
],
"ReconMethodParameterLabels": [
"subsets",
"iterations"
],
"ReconMethodParameterValues": [
null,
null
"none"
]
},
{
"contents": "3D-RAMLA",
"subsets": null,
"iterations": null,
"ReconMethodName": "3D Row Action Maximum Likelihood",
"ReconMethodParameterUnits": [
null,
null
],
"ReconMethodParameterLabels": [
"subsets",
"iterations"
"none"
]
},
{
"contents": "3DRP",
"ReconMethodName": "3D Kinahan-Rogers",
"ReconMethodParameterLabels": [
"none"
],
"ReconMethodParameterValues": [
null,
null
"contents": "3-D Kinahan-Rogers",
"ReconMethodName": "3D Kinahan-Rogers",
"ReconMethodParameterLabels": [
"none"
]
},
{
Expand Down Expand Up @@ -178,8 +168,8 @@
"name": "Filtered Back Projection"
},
{
"value": "Kinahan-Rogers",
"name": "Reprojection"
}
"value": "3DRP",
"name": "3D Kinahan-Rogers"
}
]
}
Loading