Skip to content

xASL_stat_GetDICOMStatistics: bug with arrays in cell arrays #762

@MichaelStritt

Description

@MichaelStritt

Description

Minor bug in xASL_stat_GetDICOMStatistics. If there are arrays within the cell array structure, the cell functions here ...

%% 3) Write TSV file

% Remove empty elements
TSV(cellfun('isempty',TSV)) = {'_'};

% Remove nan elements
TSV(cell2mat(cellfun(@(x)any(isnan(x)),TSV,'UniformOutput',false))) = {'n/a'};

% Write TSV
xASL_tsvWrite(TSV, PathTSV, bOverwrite);

... don't work. To ensure no arrays in the cell arrays and to make sure all the other fields are correct too, I wrote this fix which seems to do the trick ...

%% 3) Write TSV file

% Ensure all elements of the TSV cell array have the correct format
for iRow=1:size(TSV,1)
    for iColumn=1:size(TSV,2)
        % Remove empty elements (Empty cells in the TSV can lead to reading errors)
        if isempty(TSV{iRow,iColumn})
            TSV{iRow,iColumn} = '_';
        end
        % Convert numeric NaNs to text n/a's (NaN can be exported as empty cells into the TSV, which can lead to reading errors)
        if isnumeric(TSV{iRow,iColumn})
            if isnan(TSV{iRow,iColumn})
                TSV{iRow,iColumn} = 'n/a';
            else
                TSV{iRow,iColumn} = xASL_num2str(TSV{iRow,iColumn});
            end
        end
        % Remove lists (we had a problem where it was tried to insert SliceTiming arrays into the table)
        if size(TSV{iRow,iColumn},1)>1
            TSV{iRow,iColumn} = 'n/a';
        end
    end
end

% Write TSV
xASL_tsvWrite(TSV, PathTSV, bOverwrite);

Requirements

Optional: add bug requirements here

How to test

Optional: insert description about how to test the code changes here

Release notes

Fix TSV tables: default missing numbers or lists to n/a for now, and use '_' for placeholder elements.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions