%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clear all;clc;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% haemodynamic response function: BOLD signal has stereotyped shape every
% time a stimulus hits it. We usually use the spm_hrf.m in SPM toolbox to
% produce HRF. Here, we use the 29 vector to represent HRF from 0 s to
% 28 s. In this simulation, we suppose TR=1 s. 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];
% We will plot its shape with figure 1:
figure(1)
% here is the x-coordinates
t = [0:28];
plot(t,HRF,'d-');
grid on;
xlabel('Time (s)');
ylabel('fMRI respond');
title('haemodynamic response function (HRF)');

结果:

  

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

结果:

  

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

 结果:

 

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

结果:

% The three events are so closed, the result signal is like a blocked
% design. Such as:
onset_4 = [zeros(1,19) ones(1,11) zeros(1,70)]*(3/11);
conv_4 = conv(HRF,onset_4);
figure(5);
subplot(2,1,1);
stem(onset_4);
grid on;
xlabel('Time (s)');
ylabel('Stimulus onset');
subplot(2,1,2);
plot(conv_4,'rx-');
% We will compare the result
hold on; % plot more than one time on a figure
plot(conv_3,'bx-');
grid on;
xlabel('Time (s)');
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. POJ 1634 Who's the boss?

    题意: 一个员工A的直接上司是那些薪水大于A,并且身高>=A的人中薪水最少的一个. 主席CEO的薪水最高,且身高也是最高的. 有多组数据. 每组数据给出m个员工,和q个询问. 每个员工有id.薪 ...

  2. 使用时间戳引入css、js文件

    前言 最近在一家创业公司实习,主要负责新版官网和商家平台管理系统的前端开发和维护,每次测试都要上传文件到ftp服务器端测试,初期由于更新修改比较频繁,每次都是直接上传覆盖css.js.php文件,链接 ...

  3. BZOJ 1191: [HNOI2006]超级英雄Hero 二分匹配

    1191: [HNOI2006]超级英雄Hero Description 现在电视台有一种节目叫做超级英雄,大概的流程就是每位选手到台上回答主持人的几个问题,然后根据回答问题的多少获得不同数目的奖品或 ...

  4. 在Jmeter中使用自定义编写的Java测试代码

    我们在做性能测试时,有时需要自己编写测试脚本,很多测试工具都支持自定义编写测试脚本,比如LoadRunner就有很多自定义脚本的协议,比如"C Vuser","Java ...

  5. maven依赖的全局排除

    今天遇到要全局排除一个maven依赖,因为Maven本身没有全局排除依赖的办法, 参考了同事人英写的一篇博文(可以看这里http://my.oschina.net/liuyongpo/blog/177 ...

  6. Struts2.0 去掉action后缀名

    刚刚接触Struts2.0,发现默认请求都会带着后缀名:action 就如下图,url地址中会暴露login.action(请原谅struts拼写错误..) 作为一个URL简洁爱(chu)好(nv)者 ...

  7. 李洪强iOS开发之【Objective-C】07-自定义构造方法和description方法

    知识回顾 在前面已经介绍了如何定义类和创建并初始化对象,比如有Student这个类 1.Student.h 1 #import <Foundation/Foundation.h> 2 3 ...

  8. 网络处理1-异步GET请求

    前言 云计算 近几年来,云计算是一个非常热门的技术名词,很多专家认为,云计算会改变互联网的技术基础,甚至会影响整个产业的格局.可能还很多人不了解什么是云计算,简单来说,就是把用户的数据(比如文档.照片 ...

  9. Gravitational Teleport 是一个先进的 SSH 服务器,基于 Golang SSH 构建,完全兼容 OpenSSH

    Gravitational Teleport 是一个先进的 SSH 服务器,可通过 SSH 或者 HTTPS 远程访问 Linux 服务器.其目的是为了替代 sshd.Teleport 可以轻松让团队 ...

  10. OpenThreadToken,OpenProcessToken DuplicateToken 取得句柄的令牌

    https://msdn.microsoft.com/en-us/library/windows/desktop/aa379296(v=vs.85).aspx https://msdn.microso ...