📄 rest_to4d.m
字号:
function [AllVolume, VoxelSize, ImgFileList, Origin] =rest_to4d(ADataDir)
%Build a 4D matrix for REST from series of Brain's volume/(time point). By Xiao-Wei Song
%------------------------------------------------------------------------------------------------------------------------------
% Copyright(c) 2007~2010
% State Key Laboratory of Cognitive Neuroscience and Learning in Beijing Normal University
% Written by Xiao-Wei Song
% http://resting-fmri.sourceforge.net
% <a href="Dawnwei.Song@gmail.com">Mail to Author</a>: Xiaowei Song
% Version=1.0;
% Release=20070903;
theFileList = dir(ADataDir);
ImgFileList ={};
for x = 3:size(struct2cell(theFileList),2)
if strcmpi(theFileList(x).name(end-3:end), '.hdr')
if strcmpi(theFileList(x).name(1:end-4), theFileList(x+1).name(1:end-4))
ImgFileList=[ImgFileList; {theFileList(x).name(1:end-4)}];
else
error('*.{hdr,img} should be pairwise. Please re-examin them.');
end
end
end
clear theFileList;
if size(ImgFileList,1)<10,
warning('There are too few time points.(i.e. The number of the time points is less than 10)');
end
%read the normalized functional images
% -------------------------------------------------------------------------
fprintf('\n\t Read 3D EPI functional images: "%s".', ADataDir);
theDataType ='double'; %Default data-type I assumed!
for x = 1:size(ImgFileList,1),
rest_waitbar(x/size(ImgFileList,1), ...
ImgFileList{x}, ...
'Build 3D+time Dataset','Child','NeedCancelBtn');
theFilename = fullfile(ADataDir,ImgFileList{x});
[theOneTimePoint, VoxelSize, Origin] = rest_readfile(theFilename);
%AllVolume(:,:,:,x) = uint16(theOneTimePoint); %Dynamic decision of which data-type I choose! 20071031
if theDataType=='uint16',
AllVolume(:,:,:,x) = uint16(theOneTimePoint);
elseif theDataType=='double',
AllVolume(:,:,:,x) = (theOneTimePoint);
else
rest_misc('ComplainWhyThisOccur');
end
if x==1,
tmpData=theOneTimePoint(0~=theOneTimePoint);
if length(tmpData)>1000 && mean(abs(tmpData))>100,
theDataType ='uint16';
AllVolume =uint16(AllVolume);
AllVolume(:,:,:,x) = uint16(theOneTimePoint);
clear tmpData
AllVolume =repmat(AllVolume, [1,1,1, size(ImgFileList,1)]);
else
%Double!
theDataType ='double';
AllVolume =repmat(AllVolume, [1,1,1, size(ImgFileList,1)]);
end
end
if ~mod(x,5)
fprintf('.');
end
end
VoxelSize = VoxelSize';
fprintf('\n');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -