%% This function verifies whether a given atlas time course is acceptable % or not % % Inputs: % % - TCin is the input cell array containing the data of each subject in a % cell (of size n_ROI x n_timepoints) % % Outputs: % % - TCout is the same array, having removed the bad regional time courses % - idx_toremove summarizes which regional indices have been removed % % Written by Thomas Bolton, last checked on July 24th function [TCout,idx_toremove] = RemoveNaNRegions(TCin) % Indices of the ROIs where in at least one subject, there are NaN % values idx_toremove = []; n_ROI = size(TCin,1); % If there is at least a NaN value in a given time course, we include % it in the ones to remove if ~isempty(TCin) for j = 1:n_ROI if(sum(isnan(TCin(j,:))) > 0) idx_toremove = [idx_toremove,j]; end end end % Makes each ROI appear only once in the vector idx_toremove = unique(idx_toremove); % Only keeps the time courses that were deemed OK by the check if ~isempty(TCin) TCout = TCin(~ismember(1:n_ROI,idx_toremove),:); else TCout = NaN; end end