Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

plot_mNet.m 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. clear all
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. % Prelude: basic setup
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. targetFolder = 'D:\Labor\Projects\Stroke_tDCS_rsfmri\B_rsfmri_stroke_tDCS_mice\data';
  6. time = {'baseline','Day 3','Day 14','Day 21'};
  7. group = {'Control','PT sham', 'PT tDCS'};
  8. plotX = 1; % check if plot results
  9. saveX =0; % check if save results
  10. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  11. cd 'D:\Labor\Analyses\Toolbox\fMRI';
  12. addpath('FSLNets')
  13. addpath('L1precision')
  14. addpath('pwling')
  15. addpath('../Tools/BCT')
  16. at={' @ '};
  17. sp={' '};
  18. cd (targetFolder)
  19. folder_idx = pwd; % get folder ID to store data
  20. files_idx = dir([folder_idx,'/*mat']); % list data2load
  21. baseFileName = files_idx.name;
  22. fullFileName = fullfile(folder_idx, baseFileName);
  23. dirInfos = dir(fullFileName);
  24. % clear ('folder_idx','files_idx','baseFileName','fullFileName');
  25. c=date;
  26. c=strrep(c,'-','_');
  27. nt=length(time);
  28. clx=[ 0.7 0.7 0.7; 1.0000 0.4118 0.1608;0.0745 0.6235 1.0000];
  29. cd (targetFolder)
  30. load 'data.mat';
  31. load 'labels.mat';
  32. load 'subjects.mat';
  33. load 'mouse_modules_M.mat';
  34. % load 'mNetZ.mat';
  35. % mNet=matZ;
  36. if saveX==1
  37. if ~exist(strcat(c,'_results'))
  38. mkdir(strcat(c,'_results'));
  39. end
  40. cd(strcat(c,'_results'))
  41. savefolder=pwd;
  42. end
  43. %%
  44. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  45. % 1) get stored Matrices
  46. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  47. % A: whole network [mNet]
  48. % extract saved mNet from files
  49. for ri = 1:size(data,2)
  50. for li = 1:size(data(ri).subj,2)
  51. for ti = 1:size(data(ri).subj(li).tp,2)
  52. mnx=data(ri).subj(li).tp(ti).mNet;
  53. if ~isempty(mnx)
  54. mNet(:,:,(ri-1)*4+ti,li)=mnx;
  55. end
  56. end
  57. % rnx=data(ri).subj(li).mNet;
  58. % ROI(:,:,li,ri)=rnx;
  59. end
  60. end
  61. mNet(mNet==0)=nan;
  62. clear ('mnx','rnx','li','ri');
  63. mNet_mean = squeeze(mean(mNet,4,'omitnan'));
  64. % delta Mat of group-means to baseline
  65. for i=1:length(group)
  66. ix=i-1;
  67. for kx=1:length(time)
  68. delta_mNet(:,:,ix*nt+kx)=(mNet_mean(:,:,ix*nt+kx)-mNet_mean(:,:,ix*nt+1));
  69. DD_mNet(:,:,ix*nt+kx)=(mNet_mean(:,:,ix*nt+kx)-mNet_mean(:,:,ix*nt+1))-(mNet_mean(:,:,4+kx)-mNet_mean(:,:,4+1));
  70. % -(ROI_group(:,:,kx)-ROI_group(:,:,1));
  71. end
  72. end
  73. %%
  74. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  75. % 2) sensomotor sub-network
  76. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  77. ROI14=mNet(labels.nr14,labels.nr14,:,:);
  78. clear 'mnx'
  79. inp_delta=ROI14;
  80. inp_delta(inp_delta==0)=nan;
  81. ROI_group=squeeze(mean(inp_delta,3,'omitnan'));
  82. for i=1:length(group)
  83. ix=i-1;
  84. for kx=1:length(time)
  85. deltaROI(:,:,ix*nt+kx)=(ROI_group(:,:,ix*nt+kx)-ROI_group(:,:,ix*nt+1));
  86. % -(ROI_group(:,:,kx)-ROI_group(:,:,1));
  87. end
  88. end
  89. %%
  90. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  91. % 3) plot raw group mean of networks
  92. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  93. [X,Y,On] = grid_communities(M);
  94. if plotX==1
  95. for i=1:length(group)
  96. ix=i-1;
  97. for k=3%1:length(time)
  98. % mixed=triu(ROI_group_delta(:,:,ix*4+k))+tril(ROI_group(:,:,ix*4+k));
  99. name=(strcat(group(i),' -', time(k)));
  100. ID=(strcat(time(k)));
  101. % plotmat_values_rsfMRI(ROI_group(:,:,ix*length(time)+k),targetFolder,dirInfos,[-1 1],0,labels.ROI_short);
  102. plotmat_values_rsfMRI(delta_mNet(On,On,ix*nt+k),targetFolder,dirInfos,[-.75 .75],0,[]);
  103. hold on
  104. axis square;
  105. ylabel([])
  106. plot(X,Y,'k','linewidth',2)
  107. % plot(get(gca,'xlim'),[mean(get(gca,'ylim')), mean(get(gca,'ylim'))],'k-','linewidth',2);
  108. % plot([mean(get(gca,'xlim')), mean(get(gca,'xlim'))], get(gca,'ylim'),'k-','linewidth',2);
  109. title(strcat(name))%,'; mean node strength = ', num2str(norm_ROI_delta(ix*4+k))));
  110. ax=gca;
  111. ax.FontSize=20;
  112. ax.FontName='Times';
  113. nmx=char(strcat(name,'_ROI_delta.png'));
  114. nm_fig=char(strcat(name,'_ROI_delta.fig'));
  115. if saveX==1
  116. cd (savefolder)
  117. saveas(gcf,char(nmx));
  118. saveas(gcf,char(nm_fig));
  119. end
  120. % pause(2)
  121. % close
  122. end
  123. end
  124. end