vtcinterpolate.m

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

M
43
字号
function vtcInterpolate(path, vtc, points_per_TR);
% syntax: vtcInterpolate(path, vtc, points_per_TR);
% 
% this func resample the vtc, i.e. increase its samplig rate by
% 'points_per_TR' factor. it does it using the interp function. it returns
% TCs multiplied by 100, in order to avoid accuracy loss by the VTC format
% (TCs as integers)
% 
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il

datestr(now)

% open the vtc file for reading
fid = fopen([path vtc '.vtc'],'r');

% open the vmp file for writing
nfid = fopen([path vtc '_interpolated_' num2str(points_per_TR) 'points_per_TR.vtc'],'w');

% READ HEADER
[NoOfVolumes, cols, rows, slices, protocol, TR] = vtcMoveToAfterHeaderPosition(fid);
% WRITE THE HEADER OF THE NEW VTC
vtcWriteHeader(nfid, NoOfVolumes*points_per_TR,protocol, TR/points_per_TR);

for z=1:slices
	for y=1:rows
        for x=1:cols         
            fseek(fid, 0, 'cof');
            TC = fread(fid, NoOfVolumes, 'uint16');
            TC = TC/100;
            TC = interp(TC,points_per_TR)*100;
            fseek(nfid, 0, 'cof');
            fwrite(nfid,TC, 'uint16');
        end
    end
end

fclose('all');
datestr(now)

⌨️ 快捷键说明

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