vtcsmoothtcpeak.m

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

M
37
字号
function returnVal = vtcSmoothTCpeak(path, vtc, start_at, end_at);
% syntax: vtcSmoothTCpeak(path, vtc, start_at, end_at)
% start_at, end_at are 2 TRs for where the peak begins and ends
% 
% this func will replace the TC is this range with 
% constant value: the average of the TRs before and after
% use it to smooth an unwanted peak that results from a movement etc.
% the original file is [path vtc '.vtc] 
% and the new is [path vtc 'smoothed' start_at 'to' end_at '.vtc']
% 
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il

% OPEN FILES
fid = fopen([path vtc '.vtc'],'r');
nfid = fopen([path vtc '_smoothed' num2str(start_at) 'to' num2str(end_at) '.vtc'],'w');

% COPY VTC HEADER
[cols, rows, slices] = vtcCopyHeader(fid,nfid);
voxelsNo = rows * cols * slices;

% CREATE NEW TCs

for voxel = 1:voxelsNo
   % read time course of current voxel
    fseek(fid, 0, 'cof');
    TC = fread(fid, NoOfVolumes, 'uint16');
    returnVal = mean([TC(start_at-1) TC(end_at+1)]);
    TC(start_at:end_at)=mean([TC(start_at-1) TC(end_at+1)]);
    fwrite(nfid, TC, 'uint16');
end    

fclose('all');

⌨️ 快捷键说明

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