cd 'D:\Labor\Analyses\Toolbox\fMRI' addpath('FSLNets') addpath('L1precision') addpath('pwling') addpath('../Tools/BCT') 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'); cd 'D:\Labor\Projects\Stroke_tDCS_rsfmri\B_rsfmri_stroke_tDCS_mice\data'; targetFolder=pwd; clear 'data'; %load matrix data from .mat load data.mat; load labels.mat; % % load data_neu2.mat; % % load data_full.mat; % load labelsData.mat; % load labelsROI.mat; % load labelsROI_long.mat; %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % 1) extract mNet/ROI and save in matrix %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 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')); % %% DeltaTDCS = (mNet_mean(:,:,11)-mNet_mean(:,:,9))-(mNet_mean(:,:,7)-mNet_mean(:,:,5)); PTdiff=squeeze(mNet(:,:,7,:)-mNet_mean(:,:,5)); for i = 1:98 for k = 1:98 DeltaSD(i,k) = std(PTdiff(i,k,:),'omitnan'); end end DDelta=DeltaTDCS./DeltaSD; %% [X,Y,On] = grid_communities(M); dirInfo.name=''; plotmat_values_rsfMRI(DeltaTDCS(On,On),[],dirInfo,[-.75 .75],0,[]); hold on axis square; plot(X,Y,'k','linewidth',2) %% NodeDelta=squeeze(mean(DDelta,1,'omitnan')); ROIDelta(1,:)=NodeDelta(labels.nr14(1:7)); ROIDelta(2,:)=NodeDelta(labels.nr14(8:14)); ROI = cell2table(num2cell(ROIDelta),'VariableNames',lab) h=heatmap(ROIDelta) colormap('Parula') h.YDisplayLabels = {'left','right'} h.XDisplayLabels = lab; caxis([0 1]) title('Change in Node Strength (Z-score)') %% cd ('D:\Labor\Projekte\Stroke_tDCS_rsfmri\B_rsfmri_stroke_tDCS_mice\results\Old\plot_nodes') atlas = niftiread("annotations_50_parent_splitted.nii.gz"); nodes = readtable("acronyms_parent_splitted.txt"); nodes = cell2mat(table2cell(nodes(:,1))); atlas_mapped=nan(size(atlas,1),size(atlas,2),size(atlas,3)); NodesMean = squeeze(mean(group_delta(:,:,3,2),1,'omitnan')); NodesStd = squeeze(std(group_delta(:,:,3,2),0,1,'omitnan')); NodesDelta = NodesMean./NodesStd; % % for l=1:length(nodes) % % % % z=find(atlas==nodes(l)); % % if ~isempty(z) % % % % atlas_mapped(z)=NodeDelta(l); % % % % end % % end % % plot_map=atlas_mapped(:,:,124); % % imshow(plot_map,[-1 0]) % % colormap('Parula') % % set(im, 'AlphaData', ~isnan(plot_map)) % % % % % niftiwrite(mask,'atlas_mapped.nii') % % end % % % % %% % % % % cd ('D:\Labor\Projects\Stroke_tDCS_rsfmri\B_rsfmri_stroke_tDCS_mice\results\plot_nodes') % % nodes = readtable("acronyms_parent_splitted.txt"); % % nodes = cell2mat(table2cell(nodes(:,1))); %% for k=1:3 clear ("mask_temp") t=Tiff(strcat('mask',num2str(k),'.tiff')); mask=read(t); % l=Tiff(strcat('lesion_',num2str(k),'.tif')); % lesion=read(l); mask_temp=nan(size(mask,1),size(mask,2)); % mask_temp(:,:)=-10; for l=1:length(nodes) isda=find(mask==nodes(l)); if ~isempty(isda) mask_temp(isda)=NodesDelta(l); end end % lesion(lesion==0)=nan; % lm = imshow(lesion); % colormap(hot) figure clims = [-2 1]; imAlpha=ones(size(mask_temp)); imAlpha(isnan(mask_temp))=0; im = imagesc(mask_temp,'AlphaData',imAlpha); colorbar("off") clim([-2 1]) c=colorbar; c.TickLabels = ''; colormap('jet') % set(im, 'AlphaData', ~isnan(mask_temp)) set(gca,'color',0*[1 1 1],'XTickLabel','','YTickLabel',''); % title('PT tDCS') saveas(gca,strcat('Plot_node_change_tDCS_',num2str(k),'.png')) end