diff --git a/matlab/updatejsonpetfile.m b/matlab/updatejsonpetfile.m index c8844ef..bb0e3d7 100644 --- a/matlab/updatejsonpetfile.m +++ b/matlab/updatejsonpetfile.m @@ -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 @@ -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 @@ -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 @@ -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'); @@ -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) diff --git a/metadata/PET_metadata.json b/metadata/PET_metadata.json index affc4d2..26456c5 100644 --- a/metadata/PET_metadata.json +++ b/metadata/PET_metadata.json @@ -22,7 +22,6 @@ "ImageDecayCorrectionTime", "ReconMethodName", "ReconMethodParameterLabels", - "ReconMethodParameterUnits", "ReconFilterType", "AttenuationCorrection" ], @@ -62,12 +61,13 @@ "DecayCorrectionFactor", "PromptRate", "RandomRate", - "SinglesRate" + "SinglesRate", + "ReconFilterSize" ], "optional": [ "Anaesthesia", - "ReconMethodParameterValues", - "ReconFilterSize" + "ReconMethodParameterUnits", + "ReconMethodParameterValues" ], "blood_recording_fields": [ "PlasmaAvail", diff --git a/metadata/PET_reconstruction_methods.json b/metadata/PET_reconstruction_methods.json index a6f9ec3..2b4269b 100644 --- a/metadata/PET_reconstruction_methods.json +++ b/metadata/PET_reconstruction_methods.json @@ -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" ] }, { @@ -178,8 +168,8 @@ "name": "Filtered Back Projection" }, { - "value": "Kinahan-Rogers", - "name": "Reprojection" - } + "value": "3DRP", + "name": "3D Kinahan-Rogers" + } ] } \ No newline at end of file