相关性分析代码片段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);

  

相关性分析代码片段2

时间: 2024-08-29 18:11:23

相关性分析代码片段2的相关文章

相关性分析代码片段

ldcca_tms = img_To_4D_array('C:\Users\Administrator\Desktop\contrast\2014-05-20-17-10.img'); spm_tms = img_To_4D_array('C:\Users\Administrator\Desktop\contrast\no_phycaa.img'); % x = size(spm_tms,1); % y = size(spm_tms,2); % z = size(spm_tms,3); % %

推荐10个非常实用的PHP代码片段

当使用PHP进行开发的时候,如果你自己收藏 了一些非常有用的方法或者代码片段,那么将会给你的开发工作带来极大的便利.今天我们将介绍10个超级好用的PHP代码片段,希望大家能够喜欢! 1.  使用textmagic API发送消息 可能有的时候,你需要发送一些短信给你的客户,那么你绝对应该看看textMagic.它提供了非常简单的API来实现这个功能.但是不是免费的. // Include the TextMagic PHP lib require('textmagic-sms-api-php/T

java学习_有趣代码片段(一)

记一个有趣的代码片段 昨天看到一个十分有意思的问题,当时看到问题的我也是瞬间懵了.其实就是自己掌握的知识不扎实.现在我把它分开经行解析下,如有不对,请指正!主要还是自己对基础知识理解的不扎实,以后还会遇到许许多多的问题,就干脆起了个java学习有趣代码片段(一). 第一个问题 代码如下 package com.zhb; public class Test { static Test test = new Test("3"); static{ System.out.println(&qu

android有用代码片段(一)

有时候,需要一些小的功能,找到以后,就把它贴到了博客下面,作为留言,查找起来很不方便,所以就整理一下,方便自己和他人. 一.  获取系统版本号: PackageInfo info = this.getPackageManager().getPackageInfo(this.getPackageName(), 0); int versionCode=nfo.versionCode string versionName=info.versionNam 二.获取系统信息: <span style=&quo

solr分布式索引【实战一、分片配置读取:工具类configUtil.java,读取配置代码片段,配置实例】

1 private static Properties prop = new Properties(); 2 3 private static String confFilePath = "conf" + File.separator + "config.properties";// 配置文件目录 4 static { 5 // 加载properties 6 InputStream is = null; 7 InputStreamReader isr = null;

100个直接可以拿来用的JavaScript实用功能代码片段

把平时网站上常用的一些实用功能代码片段通通收集起来,方面网友们学习使用,利用好的话可以加快网友们的开发速度,提高工作效率. 目录如下: 1.原生JavaScript实现字符串长度截取2.原生JavaScript获取域名主机3.原生JavaScript清除空格4.原生JavaScript替换全部5.原生JavaScript转义html标签6.原生JavaScript还原html标签7.原生JavaScript时间日期格式转换8.原生JavaScript判断是否为数字类型9.原生JavaScript

关于UITabBar各部分自定义的代码片段

一.自定义TabBar选项卡背景默认UITabBarController的TabBar背景是黑色的,如何自定义成背景图片呢? UITabBarController *tabBarController = [[UITabBarController alloc] init]; // 获取选项卡控制器视图的所有子视图,保存到一数组中 NSArray *array = [tabBarController.view subviews]; // 索引值为1的应该就是TabBar UITabBar  *tab

常用python日期、日志、获取内容循环的代码片段

近段时间对shell脚本和python进行了梳理,将一些脚本中常用的内容,考虑多种方法整理出来,形成有用的代码片段,这样就可以在需要的时候直接使用,也可以用于备忘和思考.本次整理的代码片段有: python中日期.时间常用获取方法: 记录处理日志的logging模块使用:从目录,文件,命名结果中,获取循环条件进行循环.我将这些有用的代码片段整理在一个Python脚本中了,并且测试可用.脚本内容如下: #!/usr/bin/env python #_*_coding:utf8_*_ #常用日期和时

sublime text3 之snippet编写代码片段

sublime text 3 中有个强大的功能就是可以编写各种文件类型的snippet代码片段,可以节省大量的时间. 文件名为:jekyll-top.sublime-snippet(.sublime-snippet)后缀必须这样 <snippet> <content><![CDATA[/** * author:qinbb * title:智能推荐${1:标题} */ ${2}]]></content> <!-- Optional: Set a tabT