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

📄 vtcaddmeanpoint.m

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

% syntax: vtcAddMeanPoints(path, vtc, noOfPoints, location);
% default values: noOfPoints =1, location = 'end'
%
% this func adds 'noOfPoints' points with the timecourse mean
% in the 'location' ('beginning'/'end' ) of each timecourse
% 
% This function was written by:
% Hagar Gelbard
% Rafi Malach's Lab
% Weizmann Institute of Science
% Rehovot, Israel
% hagar.gelbard@weizmann.ac.il

if nargin < 4, location = 'end'; end
if nargin < 3, noOfPoints = 1; end

% open the file for reading  
fid = fopen([path vtc '.vtc'],'r');
% open a new file for writing the cropped file
suffix = ['_' num2str(noOfPoints) 'meanPoints_' location];
nfid = fopen([path vtc suffix '.vtc'],'w');

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

voxelsNo = rows * cols * slices;

% timecourse manipulation

for voxel = 1:voxelsNo
   % read time course of current voxel
    fseek(fid, 0, 'cof');
    TC = fread(fid, NoOfVolumes, 'uint16');
    if strcmp(location,'beginning')
        newTC = [ones(noOfPoints,1)*mean(TC); TC];
    else
        newTC = [TC; ones(noOfPoints,1)*mean(TC)];
    end
    fwrite(nfid, newTC, 'uint16');
end    
fclose('all');

⌨️ 快捷键说明

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