相关性分析代码片段2
%% 参考BLOCK
reference_stimulus =[
0 0 0 0 0 0 0 0 0 0 ...
1 1 1 1 1 1 1 1 1 1 ...
0 0 0 0 0 0 0 0 0 0 ...
1 1 1 1 1 1 1 1 1 1 ...
0 0 0 0 0 0 0 0 0 0 ...
1 1 1 1 1 1 1 1 1 1 ...
0 0 0 0 0 0 0 0 0 0
];
%% 原始数据
datacell_4d = load_untouch_nii('C:\Users\Administrator\Desktop\workspace\phycaa_plus_2104_03_27\func_4d.nii');
%% 两个数据,经过生理噪声预处理和未经过生理噪声预处理
ldcca_tms = img_To_4D_array('C:\Users\Administrator\Desktop\contrast\2014-05-26-20-00.img');
spm_tms = img_To_4D_array('C:\Users\Administrator\Desktop\contrast\no_phycaa.img');
mask_ldcca_tms = ldcca_tms > 0;
inv_mask_ldcca_tms = ~mask_ldcca_tms;
mask_spm_tms = spm_tms > 0;
inv_mask_spm_tms = ~mask_spm_tms;
tmp_spm = spm_tms .* inv_mask_ldcca_tms;
mask_big_left_spm_tms = tmp_spm>0;
tmp_ldcca = ldcca_tms .* inv_mask_spm_tms;
mask_big_left_ldcca_tms = tmp_ldcca > 0;
%% 被去除的体素
ldim = size(datacell_4d.img);
substruct_fullMsk = repmat( mask_big_left_spm_tms, [1,1,1,ldim(4)] );
substruct_spm_tms_2d = reshape( datacell_4d.img(substruct_fullMsk>0), [], ldim(4) );
%% 留下的体素集合
left_fullMsk = repmat( mask_spm_tms.*(~mask_big_left_spm_tms), [1,1,1,ldim(4)] );
left_spm_tms_2d = reshape( datacell_4d.img(left_fullMsk>0), [], ldim(4) );
%% 新增加的点集合
add_fullMsk = repmat( mask_big_left_ldcca_tms, [1,1,1,ldim(4)] );
add_spm_tms_2d = reshape( datacell_4d.img(add_fullMsk>0), [], ldim(4) );
figure(2);
% 统计被去除的点的相关系数,强度
substruct_corr_spms=[];
for i = 1:size(substruct_spm_tms_2d,1)
substruct_corr_spms(i)= corr2(reference_stimulus' , substruct_spm_tms_2d(i,:)');
end
% plot(substruct_corr_spms,'Color','red');
% hold on;
% 统计增加的点的相关系数,强度
add_corr_spms=[];
for i = 1:size(add_spm_tms_2d,1)
add_corr_spms(i)= corr2(reference_stimulus' , add_spm_tms_2d(i,:)');
end
% plot(add_corr_spms,'Color','black');
% hold on;
% 统计剩下的点的相关系数,强度
left_corr_spms=[];
for i = 1:size(left_spm_tms_2d,1)
left_corr_spms(i)= corr2(reference_stimulus' , left_spm_tms_2d(i,:)');
end
% plot(left_corr_spms,'Color','blue');
% hold on;
figure(1);
boxplot(substruct_corr_spms);
figure(2);
boxplot(add_corr_spms);
figure(3);
boxplot(left_corr_spms);
作者:木木

浙公网安备 33010602011771号