📄 vtctemporalsmoothing.m
字号:
function returnVal = VTCtemporalSmoothing(path,vtc,window_size);
% syntax: VTCtemporalSmoothing(path,vtc,window_size);
% default value: window_size = 11 (5tr before & 5tr after)
%
% the input file is [path vtc '.vtc']
% the output is written into [path vtc '_ts' window_size 'tr.vtc']
%
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il
if nargin < 3
window_size = 11;
elseif ~mod(window_size,2)
error('MATLAB:badinput','Input argument ''window_size'' must be odd.');
end
fid = fopen([path vtc '.vtc'],'r');
nfid = fopen([path vtc '_ts' num2str(window_size) 'tr.vtc'],'w');
% READ HEADER
[NoOfVolumes, cols, rows, slices, protocol,TR] = vtcMoveToAfterHeaderPosition(fid);
% WRITE THE HEADER OF THE NEW VTC
vtcWriteHeader(nfid, NoOfVolumes,protocol,TR);
voxelsNo = rows * cols * slices;
mask = 1/window_size*ones(1,window_size);
win = (window_size-1)/2;
for voxel = 1:voxelsNo-1
fseek(fid, 0, 'cof');
TC = fread(fid, NoOfVolumes, 'uint16');
% Write smoothed TC to new vtc
smoothedTC = conv(TC, mask);
fwrite(nfid, smoothedTC(win+1:NoOfVolumes+win), 'uint16');
end
fclose('all');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -