-
Notifications
You must be signed in to change notification settings - Fork 0
/
getComments.m
37 lines (32 loc) · 996 Bytes
/
getComments.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
function fcomments = getComments( fname, conn )
%getComments retrieves comments for a particular file from a txt file in
%the file's directory
fcomments = '';
subj = whichSubj(fname(1));
ssdir = getSsdir( conn );
fhandle = fopen([ssdir subj '\comments.txt']);
if fhandle ~= -1
thisline = fgetl(fhandle);
foundit = false;
done = false;
while ischar(thisline) && (~foundit || ~done)
if ~isempty(regexp(thisline, fname)) && ~foundit
foundit = true;
end
thisline = fgetl(fhandle);
if ~ischar(thisline)
continue;
end
if ~isempty(regexp(thisline, '.smr'))
done = true;
end
if foundit && ~done
fcomments = [fcomments sprintf('\n') thisline];
end
end
fclose(fhandle);
end
if isempty(fcomments)
fcomments = ' ';
end
end