Skip to content

JSON reference comparison #1018

@MichaelStritt

Description

@MichaelStritt

Description

In xASL_test_FullPipelineTest we check that when the dataset_description.json and other JSON files are compared with their reference, the GeneratedBy version information is being ignored. Right now we just check if all other fields exist. If other fields exist but are different, we would ignore this right now (we only check isempty(missingFields)). The function should compare the remaining struct fields based on the JSON files correctly.

if xASL_exist(pathA,'file') && xASL_exist(pathB,'file')
    % Actual comparison
    jsonA = spm_jsonread(pathA);
    jsonB = spm_jsonread(pathB);
    % Get fieldnames
    fieldNamesA = fieldnames(jsonA);
    fieldNamesB = fieldnames(jsonB);
    % Check which fields are shared and which different
    sharedFieldsAB = intersect(fieldNamesB,fieldNamesA);
    % Fields that are in B, but missing in A
    missingFields = setdiff(fieldNamesB,fieldNamesA);
    % Check that there are no fields missing and the only difference is the version
    if isempty(missingFields)
        if ~strcmp(jsonA.GeneratedBy.Version,jsonB.GeneratedBy.Version)
            ignoreRows = [ignoreRows iElement];
        end
    end
end

Release notes

Nothing to report, issue solved before

Metadata

Metadata

Assignees

Labels

testingEither unit testing or full pipeline testing for bugs

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions