1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.  
  3. clear all;clc;
  4. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  5. % haemodynamic response function: BOLD signal has stereotyped shape every
  6. % time a stimulus hits it. We usually use the spm_hrf.m in SPM toolbox to
  7. % produce HRF. Here, we use the 29 vector to represent HRF from 0 s to
  8. % 28 s. In this simulation, we suppose TR=1 s.
  9.  
  10. HRF = [0 0.004 0.043 0.121 0.188 0.211 0.193 0.153 0.108 0.069 0.038 0.016 0.001 -0.009 -0.015 -0.018 -0.019 -0.018 -0.015 -0.013 -0.010 -0.008 -0.006 -0.004 -0.003 -0.002 -0.001 -0.001 -0.001];
  11. % We will plot its shape with figure 1:
  12. figure(1)
  13. % here is the x-coordinates
  14. t = [0:28];
  15. plot(t,HRF,'d-');
  16. grid on;
  17. xlabel('Time (s)');
  18. ylabel('fMRI respond');
  19. title('haemodynamic response function (HRF)');

结果:

  

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % Suppose that our scan for 120 s, we will have 120 point (because TR = 1
  3. % s). If a stimulus onset at t=20 s, we can use a vector to represent this
  4. % stimulation.
  5. onset_1 = [zeros(1,19) 1 zeros(1,100)];
  6. % i.e. the whole vector is maked with 19 zeros, a single 1, and then 100
  7. % zeros. As we have the stimulus onset vector and HRF we can convolve them.
  8. % In Matlab, the command to convolve two vectors is "conv":
  9. conv_1 = conv(HRF,onset_1);
  10. % Let's plot the result in figure 2
  11. figure(2);
  12. % This figure will have 2 rows of subplots.
  13. subplot(2,1,1);
  14. % "Stem" is a good function for showing discrete events:
  15. stem(onset_1);
  16. grid on;
  17. xlabel('Time (s)');
  18. ylabel('Stimulus onset');
  19. subplot(2,1,2);
  20. plot(conv_1,'rx-');
  21. grid on;
  22. xlabel('Time (s)');
  23. ylabel('fMRI signal');

结果:

  

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % Usually, we have repeat a task many times in a run. If three stimulus
  3. % onsets at t=20, 50, 80 s, we also can use a vector to represent this
  4. % stimulation.
  5. onset_2 = [zeros(1,19) 1 zeros(1,29) 1 zeros(1,29) 1 zeros(1,20)];
  6. % Here we use the conv again:
  7. conv_2 = conv(HRF,onset_2);
  8. % Let's plot the result in figure 3
  9. figure(3);
  10. % This figure will have 2 rows of subplots.
  11. subplot(2,1,1);
  12. % "Stem" is a good function for showing discrete events:
  13. stem(onset_2);
  14. grid on;
  15. xlabel('Time (s)');
  16. ylabel('Stimulus onset');
  17. subplot(2,1,2);
  18. plot(conv_2,'rx-');
  19. grid on;
  20. xlabel('Time (s)');
  21. ylabel('fMRI signal');

 结果:

 

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. % Now let's think about the fast event design. In this condition, we will
  3. % have many task during a short time. If three stimulus onsets at t=20, 25,
  4. % 30 s:
  5. onset_3 = [zeros(1,19) 1 zeros(1,4) 1 zeros(1,4) 1 zeros(1,70)];
  6. conv_3 = conv(HRF,onset_3);
  7. figure(4);
  8. subplot(2,1,1);
  9. stem(onset_3);
  10. grid on;
  11. xlabel('Time (s)');
  12. ylabel('Stimulus onset');
  13. subplot(2,1,2);
  14. plot(conv_3,'rx-');
  15. grid on;
  16. xlabel('Time (s)');
  17. ylabel('fMRI signal');

结果:

  1. % The three events are so closed, the result signal is like a blocked
  2. % design. Such as:
  3. onset_4 = [zeros(1,19) ones(1,11) zeros(1,70)]*(3/11);
  4. conv_4 = conv(HRF,onset_4);
  5. figure(5);
  6. subplot(2,1,1);
  7. stem(onset_4);
  8. grid on;
  9. xlabel('Time (s)');
  10. ylabel('Stimulus onset');
  11. subplot(2,1,2);
  12. plot(conv_4,'rx-');
  13. % We will compare the result
  14. hold on; % plot more than one time on a figure
  15. plot(conv_3,'bx-');
  16. grid on;
  17. xlabel('Time (s)');
  18. ylabel('fMRI signal');

结果:

  

对于fmri的hrf血液动力学响应函数的一个很直观的解释-by 西南大学xulei教授的更多相关文章

  1. 对于fmri的设计矩阵构造的一个很直观的解释-by 西南大学xulei教授

    本程序意在解释这样几个问题:完整版代码在本文的最后. 1.实验的设计如何转换成设计矩阵? 2.设计矩阵的每列表示一个刺激条件,如何确定它们? 3.如何根据设计矩阵和每个体素的信号求得该体素对刺激的敏感 ...

  2. fmri的图像数据在matlab中显示,利用imagesc工具进行显示,自带数据集-by 西南大学xulei教授

    这里包含了这样一个数据集:slice_data.mat. 这个数据集中包含的mri数据是:64*64*25.共有25个slice.每个slice的分辨率是64*64. 程序非常简短: load sli ...

  3. [.NET] 打造一个很简单的文档转换器 - 使用组件 Spire.Office

    打造一个很简单的文档转换器 - 使用组件 Spire.Office [博主]反骨仔 [原文]http://www.cnblogs.com/liqingwen/p/6024827.html 序 之前,& ...

  4. [转载]config文件的一个很好的实现

    以下是转载于网上的一个很好的config文件的实现,留存以备案 //Config.h #pragma once #include <string> #include <map> ...

  5. route 一个很奇怪的现象:我的主机能ping通同一网段的其它主机,并也能xshell 远程其它的主机,而其它的主机不能ping通我的ip,也不能远程我和主机

    一个很奇怪的现象:我的主机能ping通同一网段的其它主机,并也能xshell 远程其它的主机,而其它的主机不能ping通我的ip,也不能远程我和主机. [root@NB Desktop]# route ...

  6. C语言 在VS环境下一个很有意思的报错:stack around the variable was corrupted

    今天做一个很简单的oj来温习下c 语言 题目如下 输入 3位正整数 输出 逆置后的正整数 代码如下: #include"stdio.h"int main(){ float h,su ...

  7. [C语言]一个很实用的服务端和客户端进行TCP通信的实例

    本文给出一个很实用的服务端和客户端进行TCP通信的小例子.具体实现上非常简单,只是平时编写类似程序,具体步骤经常忘记,还要总是查,暂且将其记下来,方便以后参考. (1)客户端程序,编写一个文件clie ...

  8. 一个很好的Delphi博客

    一个很好的Delphi博客,主人叫万一 http://www.cnblogs.com/del/archive/2011/09/21/2183007.html

  9. 一个很不错的bash脚本编写教程

    转自 http://blog.chinaunix.net/uid-20328094-id-95121.html 一个很不错的bash脚本编写教程,至少没接触过BASH的也能看懂! 建立一个脚本 Lin ...

随机推荐

  1. Sql Server总结

     主键 主键就是数据行的唯一标识.不会重复的列,才能当主键.一个表可以没有主键,但是会非常难以处理,因此没有特殊理由表都要设定主键.主键有两种选用策略:业务主键和逻辑主键. 业务主键是使用有业务意义的 ...

  2. PHP5.4最新特性

     PHP5.4最新特性   官网:ChangeLog-5.php#5.4.0 原文Oracle:LAMP 体系有了新的竞争,但此版本中的特性使 PHP 再次挑战极限. 稍微做了修改.: 概述总结:1. ...

  3. [转载] select, poll和epoll的区别

    源地址:http://sheepxxyz.blog.163.com/blog/static/61116213201022003513530/ 随着2.6内核对epoll的完全支持,网络上很多的文章和示 ...

  4. 今天来做一个PHP电影小爬虫。

    今天来做一个PHP电影小爬虫.我们来利用simple_html_dom的采集数据实例,这是一个PHP的库,上手很容易.simple_html_dom 可以很好的帮助我们利用php解析html文档.通过 ...

  5. oci.dll文件是用来干嘛的? 如果没有安装ORACLE客户端提示oci.dll未加载

    oracle数据库开发编程中,没有找到oci.dll,一般是系统的 path 设置有问题, 查找oci.dll, 然后加入到系统路径.oci.dll 可下载解压到系统盘的system32目录下.然后打 ...

  6. java内存模型优化建议

    八.Java编程建议 根据GC的工作原理,我们可以通过一些技巧和方式,让GC运行更加有效率,更加符合应用程序的要求.一些关于程序设计的几点建议: 1)最基本的建议就是尽早释放无用对象的引用.大多数程序 ...

  7. 关于J-LINK升级最新固件后无法连上的一点分析

    昨天升级了最新的 Keil MDK 4.53,怕它老是提示 J-Link 要升级,就去 SEGGER 的网站下了个最新版的 J-Link 软件包(4.46F 版的),装好后运行 J-Link Comm ...

  8. VCL定义和使用CM_Message的原因(主要是内部控制,同时可简化参数传递,还可截住消息,统一走消息路线,还可省内存)

    内部控制是指,做了某些操作后产生某些效果,但是Windows系统本身不提供这样的消息,应此不得不自定义.比如父窗口改变了字体,那么所有子窗口也都应该改变字体,至少也得通知一下它们,让子控件自己决定是否 ...

  9. sqlite数据库查询批量

    采网页里的网址,网址每天都变化,而数据库里有几千条数据,通过 select count(*) 来查找数据库里有没有该网址,没有的话就采集入库,所 以如果网页当天更新1千条连接,那采集一次就要selec ...

  10. Android 去掉title bar的3个方法

    1. Java代码实现 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...