vtccreatevmpofaveragetcs.m

来自「VTC file is the file format of the Brain」· M 代码 · 共 46 行

M
46
字号
function vmpVec = vtcCreateVMPOfAverageTCs(path, vtc, vmp);
% syntax: vmpVec = vtcCreateVMPOfAverageTCs(path, vtc, vmp)
% 
% this func go over the voxels of the [path vtc '.vtc'] file
% for each voxel, it averages its TC and write 
% the result into vmpVec (the returned value)
% in the end it uses the writeVMP func to display the results as a map
% 
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il

datestr(now)

vtc_fid = fopen([path vtc '.vtc'],'r');

[NoOfVolumes, cols, rows, slices] = vtcMoveToAfterHeaderPosition(vtc_fid);

voxelsNo = rows * cols * slices;

for voxel = 1:voxelsNo
    TC = fread(vtc_fid, NoOfVolumes, 'uint16');
			% calculate average variance (in time) for that voxel, and normalize it
            % in case of garbage data we put in the vtc constant time
            % course, so in the VMP mat we put there zero. (we use
            % 1 - normalized_variance for display purposes (in order to use the
            % correlation map format) so 0 infact stands for  maximal
            % variance.
	if (sum(abs(diff(TC)))==0)
        vmpVec(voxel)=1;
	else
        vmpVec(voxel) = mean(TC);
	end
end

maxAver = max(max(max(vmpVec)))
vmpVec(find(vmpVec==1))=maxAver;
vmpVec = 1 - (vmpVec / maxAver);

writeVMP(path, vmp, vmpVec, 3, NoOfVolumes -1)

fclose('all');
datestr(now)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?