处理fMRI数据的一些常用Matlab命令

背景

处理fMRI数据常常用到MATLAB,在此记录一些常用代码及功能。

1、读取原始DICOM数据

1-1 读入dicom图像并绘图:

Image = dicomread('fMRI.dcm');
figure;
imshow(Image, [ ]);

1-2 读取dicom图像并查看图像相关信息:

imfomation = dicominfo('fMRI.dcm');  %%直接获得图像信息

Image = dicomread(information);  %%可以读取dicom图像数据
figure;
imshow(Image, [ ]);

2、绘制单个RUN中被试的头动情况

2-1 通过查看被试的头洞情况以确定是否剔除或保留该段数据:

可以在此直接下载该函数,或者复制以下代码进行绘图查看。

function answer = rp_plot(image)
%%%The function will plot the parameter of translation%%
%%%and rotation of the subject's head-movement directly.%%
%%%Writed by Wang Shilei,School of Physics,Peking University%%
%%%Beijing,December 18th,2020%%

data = load(image); %%Load the rp_*.txt%%

set(0,'defaultfigurecolor','w');%%Set the background of figure white%%
figure;
subplot(2,1,1);%%Plot the parameter of translation%%
plot(data(:,1));
hold on;plot(data(:,2));
hold on;plot(data(:,3));
label_1 = legend('x','y','z');
set(label_1,'Box','off');
xlabel('Number of images');
ylabel('Translation (mm)');

subplot(2,1,2);%%Plot the parameter of rotation%%
plot(data(:,4)*180/pi);
hold on;plot(data(:,5)*180/pi);
hold on;plot(data(:,6)*180/pi);
label_2 = legend('x','y','z');
set(label_2,'Box','off');
xlabel('Number of images');
ylabel('Rotation (°)');

绘图结果类似下图所示:

 

posted @ 2020-12-17 02:57  wangsl97  阅读(485)  评论(0编辑  收藏  举报