dPTE connectivity and Z score

Hi Team
I computed the dPTE for each of my participants (n=30) and was wondering how to transform the connectivity matrix of each participant into standardized scores (z-values).?

Thanking you in anticipation.

@Sylvain @MartinC ?

Hi Abin,

I don't believe there is a way to do this using the existing processes in the software. I'll let @Sylvain chime in to say whether it makes sense to do this and if it would be helpful to add to the software. In the meantime, you could do this via a script. Here's a draft I made quickly.

To use it, update the sFiles variable at the top with the list of your own files (you can drag & drop them in the process box and right click anywhere on the box -> Copy list to clipboard). The script will duplicate all your connectivity files with a z-score version based on the mean and standard deviation of all your inputs. Make sure you used the exact same atlas for every connectivity file, and if you did not use an atlas you will most likely run out of memory as this script is not at all optimized.

sFiles = {...
    'Subject01/S01_AEF_20131218_01_600Hz/timefreq_connectn_corr_201020_1028.mat', ...
    'Subject02/S01_AEF_20131218_01_600Hz/timefreq_connectn_corr_201021_1231.mat', ...

% Initialize metadata from the first file
FileMat     = in_bst(sFiles{iFile});
nFiles      = length(sFiles);
nPairs      = length(sConnect.TF);
allData     = zeros(nPairs, nFiles);
RowNames    = sConnect.RowNames;
RefRowNames = sConnect.RefRowNames;

% Concatenate data of all files
for iFile = 1:length(sFiles)
    sConnect = in_bst(sFiles{iFile});

    % Make sure the matrix has the same rows as the initial one
    assert(length(sConnect.TF) == nPairs, 'Connectivity matrices do not have the same number of rows.');
    assert(isequal(RowNames, sConnect.RowNames), 'Connectivity matrices do not have the same rows.');
    assert(isequal(RefRowNames, sConnect.RefRowNames), 'Connectivity matrices do not have the same number of rows.');

    allData(:, iFile) = sConnect.TF(:);

% Compute baseline statistics
stdBaseline  = std(allData, 0, 2);
meanBaseline = mean(allData, 2);
% Remove null variance values
stdBaseline(stdBaseline == 0) = 1e-12;

% Compute Z-Score
allData = bst_bsxfun(@minus,   allData, meanBaseline);
allData = bst_bsxfun(@rdivide, allData, stdBaseline);

% Write new files
iStudies = [];
for iFile = 1:length(sFiles)
    sConnect = in_bst(sFiles{iFile});
    sConnect.TF = allData(:, iFile);
    sConnect.Comment = [sConnect.Comment ' | zscore'];

    % Get study of current file
    [sStudy, iStudy] = bst_get('TimefreqFile', sFiles{iFile});
    iStudies(end + 1) = iStudy;
    % Output filename
    NewFile = bst_process('GetNewFilename', bst_fileparts(sStudy.FileName), ['timefreq_connectn_' sConnect.Method]);
    % Save file
    bst_save(NewFile, sConnect, 'v6');
    % Add file to database structure
    db_add_data(iStudy, NewFile, sConnect);


I hope this helps,

1 Like

Z-scoring is indeed one way to standardize (any kind of) measures. The probabilistic interpretation of the magnitudes wrt their significance is legitimate only when the underlying processes are Gaussian though.

Thank you very much for all the inputs - will give this a try.

Dear Marin

Thank you for sharing the codes - I tried following your instructions but keep getting error when running the code 'Undefined function or variable 'iFile'.'

Please advice.

Many thanks

Figured that the error was from my end - the i/p matrix comprised several frequency bands.
Thank you