vtcfliptcs.m

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

M
47
字号
function returnVal = vtcFlipTCs(path, vtc, cuts);
% syntax: vtcFlipTCs(path, vtc, cuts)
% 
% this func cuts the TC in each voxel to cuts pieces
% and flip each one of them from end to start
% example: 
% for TC =  [1 2 3 4 5 6 7 8 9] and cuts=3
% the func will give: flippedTC = [3 2 1 6 5 4 9 8 7]
% 
% 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 '_flipped_' num2str(cuts) 'cuts.vtc'],'w');

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

cutSize = floor(NoOfVolumes / cuts);

for z=1:slices
	for y=1:rows
        for x=1:cols         
            fseek(fid, 0, 'cof');
            TC = fread(fid, NoOfVolumes, 'uint16');
            for i = 1:cuts
				TC((i-1)*cutSize+1:(i-1)*cutSize+cutSize)=flipud(TC((i-1)*cutSize+1:(i-1)*cutSize+cutSize));
			end
            fseek(nfid, 0, 'cof');
            fwrite(nfid,TC, 'uint16');
        end
    end
end

fclose('all');
datestr(now)

⌨️ 快捷键说明

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