12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- % Threshold PLI above surrogate level and minimal change, FC emerge, disolve or remain
- clear all
- % close all
- clc
- surroName = 'surroCirc200.mat';
- fcPath = ['./data'];
- dataPath = './data/thetaROIs_R.mat';
- fcName = '/FCraw_R.mat';
- hands = 1;
- load([fcPath surroName], 'p95a')
- load([fcPath fcName])
- % clear fcPath dataPath surroName fcName
- nStage = size(pliR, 1);
- % p95a = prctile(abs(pliSurro),95,4); % minimum FC respects to Surrogates
- % binarize network above threshold
- fc01 = logical(abs(pliR) >= squeeze(p95a(:,:)));
- fcTh = pliR;
- fcTh(~fc01) = 0;
- % differences between stages
- nDisolv = zeros(nStage-1,1);
- nEmerg = zeros(nStage-1,1);
- nStill = zeros(nStage-1,1);
- nTotal = zeros(nStage,1);
- nFlip = zeros(nStage-1,1);
- difTest = [];
- for i = 1:nStage-1
- % disove FC
- condition = logical(fc01(i,:) == 1 & fc01(i+1,:) == 0 );
- difTest = horzcat(difTest, abs( pliR( i, condition ) - pliR( i+1, condition ) ));
- % emerge FC
- condition = logical( fc01(i,:) == 0 & fc01(i+1,:) == 1 );
- difTest = horzcat(difTest, abs( pliR( i, condition ) - pliR( i+1, condition ) ));
- end
- minDif = prctile(difTest,5); % minimal difference in change of FC between consecutive stages
- % remove FCs that emerge or disolve between stages but its difference on value is small.
- for i = 1:nStage-1
- % disolves FC
- belowMinDiff = logical(fc01(i,:) == 1 & fc01(i+1,:) == 0 & abs(pliRL(i,:)-pliRL(i+1,:)) < minDif);
- fc01(i,belowMinDiff) = 0;
- fcTh(i,belowMinDiff) = 0;
- % emerges FC
- belowMinDiff = logical( fc01(i,:) == 0 & fc01(i+1,:) == 1 & abs(pliR(i,:)-pliR(i+1,:)) < minDif );
- fc01(i+1,belowMinDiff) = 0;
- fcTh(i+1,belowMinDiff) = 0;
- end
- %save('dataSave/FCstages.mat', 'fcTh','fc01')
|