📄 ctf_read_markerfile.m
字号:
function [ctf] = ctf_read_markerfile(folder,ctf);% ctf_read_markerfile - load data from MarkerFile.mrk in .ds folder%% [ctf] = ctf_read_markerfile([folder],[ctf]);%% folder is a .ds path, if it is omitted a gui prompts for the folder.% ctf is a struct generated by this and other ctf_read_*.m functions.%% Returns the ctf.markers struct:%% ctf.markers.number_markers - scalar% ctf.markers.number_samples - column array, number_markers x 1% ctf.markers.marker_names - cell array of strings, number_markers x 1% ctf.markers.trial_times - cell array of matrices, number_markers x 1 each% containing number_samples x 2 matrix, where column 1 indicates the trial% number containing the marker and column 2 indicates the offset (in sec).%% <>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>% < >% < DISCLAIMER: >% < >% < THIS PROGRAM IS INTENDED FOR RESEARCH PURPOSES ONLY. >% < THIS PROGRAM IS IN NO WAY INTENDED FOR CLINICAL OR >% < OFFICIAL USE. >% < >% <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<>%% $Revision: 1.7 $ $Date: 2004/07/18 06:10:17 $% Copyright (C) 2004 Darren L. Weber% % This program is free software; you can redistribute it and/or% modify it under the terms of the GNU General Public License% as published by the Free Software Foundation; either version 2% of the License, or (at your option) any later version.% % This program is distributed in the hope that it will be useful,% but WITHOUT ANY WARRANTY; without even the implied warranty of% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the% GNU General Public License for more details.% % You should have received a copy of the GNU General Public License% along with this program; if not, write to the Free Software% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.% Modified: 12/2003, Darren.Weber_at_radiology.ucsf.edu% - modified from NIH code readmarkerfile.m%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%ver = '$Revision: 1.7 $';fprintf('\nCTF_READ_MARKERFILE [v %s]\n',ver(11:15)); tic;if ~exist('folder','var'), ctf = ctf_folder;else ctf = ctf_folder(folder);end% check for a marker filemarkerFile = findmrkfile( ctf.folder, filesep);a = exist(markerFile);if a == 0, fprintf('...MarkerFile.mrk does not exist in this .ds folder.'); ctf.markers = []; returnend% read the marker file, delimited by carriage returns. This new array is% used below to extract relevant informationmarkerFileText = textread(markerFile,'%s','delimiter','\n');% extract the number of markersnumber_markers_index = strmatch('NUMBER OF MARKERS:',markerFileText,'exact');number_markers = str2num(markerFileText{number_markers_index + 1});% extract marker names (this can be an array, if number_markers > 1)marker_names_index = strmatch('NAME:',markerFileText,'exact');marker_names = markerFileText(marker_names_index + 1);% extract number of marker samples% (this can be an array, if number_markers > 1)number_samples_index = strmatch('NUMBER OF SAMPLES:',markerFileText,'exact');number_samples = str2num(char(markerFileText(number_samples_index + 1)));% check that all the marker samples are definedif ~all(number_samples), disp('One of the markers has no samples and was ignored.');end% extract marker trial number and time (sec), eg, find & read:% LIST OF SAMPLES:% TRIAL NUMBER TIME FROM SYNC POINT (in seconds)% +0 +0% +1 +0% +2 +0headerLines = 2;trial = strmatch('LIST OF SAMPLES:',markerFileText,'exact') + headerLines;for i = find(number_samples)' % extract the lines of the samples, where each line contains a trial % number in the first column and a time offset (sec) in the 2nd column sample_text_rows = markerFileText( trial(i):[trial(i) + number_samples(i)] ); trials{i} = str2num(char(sample_text_rows)); % add 1 to the trial numbers (which start at 0 for CTF software) trials{i}(:,1) = trials{i}(:,1) + 1;end% allocate marker information into the ctf stucturectf.markers = struct(... 'number_markers',number_markers,... 'number_samples',number_samples,... 'marker_names',marker_names,... 'trial_times',trials');t = toc; fprintf('...done (%6.2f sec)\n\n',t);return% find file name if truncated or with uppercase extension% added by Arnaud Delorme, June 15, 2004% -------------------------------------------------------function mrkname = findmrkfile( folder, filesep) mrkname = dir([ folder filesep '*.mrk' ]); if isempty(mrkname) mrkname = dir([ folder filesep '*.MRK' ]); end; if isempty(mrkname) disp('No file with extension .mrk or .MRK in selected folder for importing events'); mrkname = []; else mrkname = [ folder filesep mrkname.name ]; end;return
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -