123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- clear all
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % Prelude: basic setup
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- targetFolder = 'D:\Labor\Projects\Stroke_tDCS_rsfmri\B_rsfmri_stroke_tDCS_mice\data';
- time = {'baseline','Day 3','Day 14','Day 21'};
- group = {'Control','PT sham', 'PT tDCS'};
- plotX = 1; % check if plot results
- saveX =0; % check if save results
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- cd 'D:\Labor\Analyses\Toolbox\fMRI';
- addpath('FSLNets')
- addpath('L1precision')
- addpath('pwling')
- addpath('../Tools/BCT')
- at={' @ '};
- sp={' '};
- cd (targetFolder)
- folder_idx = pwd; % get folder ID to store data
- files_idx = dir([folder_idx,'/*mat']); % list data2load
- baseFileName = files_idx.name;
- fullFileName = fullfile(folder_idx, baseFileName);
- dirInfos = dir(fullFileName);
- % clear ('folder_idx','files_idx','baseFileName','fullFileName');
- c=date;
- c=strrep(c,'-','_');
- nt=length(time);
- clx=[ 0.7 0.7 0.7; 1.0000 0.4118 0.1608;0.0745 0.6235 1.0000];
- cd (targetFolder)
- load 'data.mat';
- load 'labels.mat';
- load 'subjects.mat';
- load 'mouse_modules_M.mat';
- % load 'mNetZ.mat';
- % mNet=matZ;
- if saveX==1
- if ~exist(strcat(c,'_results'))
- mkdir(strcat(c,'_results'));
- end
- cd(strcat(c,'_results'))
- savefolder=pwd;
- end
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 1) get stored Matrices
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % A: whole network [mNet]
- % extract saved mNet from files
- for ri = 1:size(data,2)
- for li = 1:size(data(ri).subj,2)
- for ti = 1:size(data(ri).subj(li).tp,2)
-
- mnx=data(ri).subj(li).tp(ti).mNet;
- if ~isempty(mnx)
- mNet(:,:,(ri-1)*4+ti,li)=mnx;
- end
-
- end
- % rnx=data(ri).subj(li).mNet;
- % ROI(:,:,li,ri)=rnx;
- end
- end
- mNet(mNet==0)=nan;
- clear ('mnx','rnx','li','ri');
- mNet_mean = squeeze(mean(mNet,4,'omitnan'));
- % delta Mat of group-means to baseline
- for i=1:length(group)
- ix=i-1;
- for kx=1:length(time)
- delta_mNet(:,:,ix*nt+kx)=(mNet_mean(:,:,ix*nt+kx)-mNet_mean(:,:,ix*nt+1));
- DD_mNet(:,:,ix*nt+kx)=(mNet_mean(:,:,ix*nt+kx)-mNet_mean(:,:,ix*nt+1))-(mNet_mean(:,:,4+kx)-mNet_mean(:,:,4+1));
-
- % -(ROI_group(:,:,kx)-ROI_group(:,:,1));
- end
- end
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 2) sensomotor sub-network
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- ROI14=mNet(labels.nr14,labels.nr14,:,:);
- clear 'mnx'
- inp_delta=ROI14;
- inp_delta(inp_delta==0)=nan;
- ROI_group=squeeze(mean(inp_delta,3,'omitnan'));
- for i=1:length(group)
- ix=i-1;
- for kx=1:length(time)
- deltaROI(:,:,ix*nt+kx)=(ROI_group(:,:,ix*nt+kx)-ROI_group(:,:,ix*nt+1));
- % -(ROI_group(:,:,kx)-ROI_group(:,:,1));
- end
- end
- %%
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- % 3) plot raw group mean of networks
- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- [X,Y,On] = grid_communities(M);
- if plotX==1
- for i=1:length(group)
- ix=i-1;
- for k=3%1:length(time)
- % mixed=triu(ROI_group_delta(:,:,ix*4+k))+tril(ROI_group(:,:,ix*4+k));
- name=(strcat(group(i),' -', time(k)));
- ID=(strcat(time(k)));
- % plotmat_values_rsfMRI(ROI_group(:,:,ix*length(time)+k),targetFolder,dirInfos,[-1 1],0,labels.ROI_short);
-
- plotmat_values_rsfMRI(delta_mNet(On,On,ix*nt+k),targetFolder,dirInfos,[-.75 .75],0,[]);
- hold on
- axis square;
- ylabel([])
- plot(X,Y,'k','linewidth',2)
- % plot(get(gca,'xlim'),[mean(get(gca,'ylim')), mean(get(gca,'ylim'))],'k-','linewidth',2);
- % plot([mean(get(gca,'xlim')), mean(get(gca,'xlim'))], get(gca,'ylim'),'k-','linewidth',2);
-
- title(strcat(name))%,'; mean node strength = ', num2str(norm_ROI_delta(ix*4+k))));
- ax=gca;
- ax.FontSize=20;
- ax.FontName='Times';
- nmx=char(strcat(name,'_ROI_delta.png'));
- nm_fig=char(strcat(name,'_ROI_delta.fig'));
-
- if saveX==1
- cd (savefolder)
- saveas(gcf,char(nmx));
- saveas(gcf,char(nm_fig));
- end
- % pause(2)
- % close
- end
- end
- end
|