⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vtccrop.m

📁 VTC file is the file format of the Brainvoyager. The FMRI matchine scan human s brain and get the vt
💻 M
字号:
function newNoOfVolumes = vtcCrop(path, vtc, TRvec, new_suffix);

% syntax: newNoOfVolumes = vtcCrop(path, vtc, TRvec, new_suffix);
% default values: new_suffix = '_cropped_[start1]_to_[end1]_[start2]_to_[end2]...'
% 
% this func crop all the voxels TC's (of the file [path vtc '.vtc']
% according to the TR's specified in TRvec
% for example if TRvec is [1 50 90 100] the function will remain only the
% TR's from 1 to 50 and from 90 to 100, and crop all the rest
% TRvec must be of even length, and of increasing order, of course.
% the func return the new length of the TC (new NoOfVolumes).
% the resulting vtc is written into [path vtc new_suffix '.vtc']
% 
% example: newNoOfVolumes = vtcCrop('F:\Data\', 'RM_GBU', [1 10 30 50 100 200], '_cond1')
% 
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il


i=1; 
newNoOfVolumes = 0;
suffix = [];

% default suffix
if nargin < 4
	% open a new file for writing the cropped file
	new_suffix = '_cropped'; 
	while i < length(TRvec)
			new_suffix = [suffix '_' num2str(TRvec(i)) 'to'  num2str(TRvec(i+1))];
            i=i+2;
    end
end


% calculate new no. of volumes
while i < length(TRvec)
    newNoOfVolumes = newNoOfVolumes + TRvec(i+1) - TRvec(i) + 1;
	i=i+2;
end

% open the files for reading/writing  
fid = fopen([path vtc '.vtc'],'r');
nfid = fopen([path vtc new_suffix '.vtc'],'w');

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

voxelsNo = rows * cols * slices;

% CROP TIME COURSE

for voxel = 1:voxelsNo
   % read time course of current voxel
    fseek(fid, 0, 'cof');
    TC = fread(fid, NoOfVolumes, 'uint16');
    croppedTC = []; i=1;
	while i < length(TRvec)
        croppedTC = [croppedTC ; TC(TRvec(i):TRvec(i+1))];
        i=i+2;
	end
     fwrite(nfid, croppedTC, 'uint16');
end    
fclose('all');

⌨️ 快捷键说明

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