function SyncAndCalcCorr(cqg_expression)

global m_CEL;

try
    % Filtering expression and calculating correlation.
    ts1 = [];
    ts2 = [];
    
    for i = 0:cqg_expression.Count - 1
        expressionOutputs = cqg_expression.Item(i);
        if (m_CEL.IsValid(expressionOutputs.Item(int32(0))) && m_CEL.IsValid(expressionOutputs.Item(int32(1))))
            ts1 = [ts1, expressionOutputs.Item(int32(0))]; %#ok<AGROW>
            ts2 = [ts2, expressionOutputs.Item(int32(1))]; %#ok<AGROW>
        end
    end
    
    disp(['Correlation between two timeseries = ', num2str(corr2(ts1,ts2))]);
    
catch
    CEL_ShutDown;
    disp('An error occurred in SyncAndCalcCorr.m file.');
end