thresholdPLIbysurro.m 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. % Threshold PLI above surrogate level and minimal change, FC emerge, disolve or remain
  2. clear all
  3. % close all
  4. clc
  5. surroName = 'surroCirc200.mat';
  6. fcPath = ['./data'];
  7. dataPath = './data/thetaROIs_R.mat';
  8. fcName = '/FCraw_R.mat';
  9. hands = 1;
  10. load([fcPath surroName], 'p95a')
  11. load([fcPath fcName])
  12. % clear fcPath dataPath surroName fcName
  13. nStage = size(pliR, 1);
  14. % p95a = prctile(abs(pliSurro),95,4); % minimum FC respects to Surrogates
  15. % binarize network above threshold
  16. fc01 = logical(abs(pliR) >= squeeze(p95a(:,:)));
  17. fcTh = pliR;
  18. fcTh(~fc01) = 0;
  19. % differences between stages
  20. nDisolv = zeros(nStage-1,1);
  21. nEmerg = zeros(nStage-1,1);
  22. nStill = zeros(nStage-1,1);
  23. nTotal = zeros(nStage,1);
  24. nFlip = zeros(nStage-1,1);
  25. difTest = [];
  26. for i = 1:nStage-1
  27. % disove FC
  28. condition = logical(fc01(i,:) == 1 & fc01(i+1,:) == 0 );
  29. difTest = horzcat(difTest, abs( pliR( i, condition ) - pliR( i+1, condition ) ));
  30. % emerge FC
  31. condition = logical( fc01(i,:) == 0 & fc01(i+1,:) == 1 );
  32. difTest = horzcat(difTest, abs( pliR( i, condition ) - pliR( i+1, condition ) ));
  33. end
  34. minDif = prctile(difTest,5); % minimal difference in change of FC between consecutive stages
  35. % remove FCs that emerge or disolve between stages but its difference on value is small.
  36. for i = 1:nStage-1
  37. % disolves FC
  38. belowMinDiff = logical(fc01(i,:) == 1 & fc01(i+1,:) == 0 & abs(pliRL(i,:)-pliRL(i+1,:)) < minDif);
  39. fc01(i,belowMinDiff) = 0;
  40. fcTh(i,belowMinDiff) = 0;
  41. % emerges FC
  42. belowMinDiff = logical( fc01(i,:) == 0 & fc01(i+1,:) == 1 & abs(pliR(i,:)-pliR(i+1,:)) < minDif );
  43. fc01(i+1,belowMinDiff) = 0;
  44. fcTh(i+1,belowMinDiff) = 0;
  45. end
  46. %save('dataSave/FCstages.mat', 'fcTh','fc01')