-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfs_load_subj.m
67 lines (57 loc) · 1.77 KB
/
fs_load_subj.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
function [surf] = fs_load_subj(subj,hemi,surfname,nverts_only,subjdir)
%function [surf] = fs_load_subj(subj,hemi,[surfname],[nverts_only],[subjdir])
%
% Required input:
% subj is a string specifying the subject name
% hemi should be either 'lh' for left hemisphere or 'rh' for right hemi
%
% Optional parameters:
% surfname - surface file to be loaded
% {default: white}
% nverts_only - if 1, don't actually load surface, just get number of vertices
% {default = 0}
% subjdir - subjects directory (override SUBJECTS_DIR environment variable)
% subjdir/subj should contain the freesurfer subject directory
% {default = $SUBJECTS_DIR}
%
% Output:
% surf is a structure containing:
% nverts: number of vertices
% nfaces: number of faces (triangles)
% faces: vertex numbers for each face (3 corners)
% vertices: x,y,z coordinates for each vertex
% nbrs: vertex numbers of neighbors for each vertex
%
% created: 06/11/06 Don Hagler
% last modified: 02/24/10 Don Hagler
%
% see also: fs_read_surf()
%
if nargin < 2, help(mfilename); return; end;
surf = [];
if ~exist('surfname','var') || isempty(surfname)
surfname = 'white';
end;
if ~exist('nverts_only','var') || isempty(nverts_only)
nverts_only = 0;
end;
if ~ismember(hemi,{'lh','rh'})
error('hemi must be lh or rh (is %s)',hemi);
end;
if ~exist('subjdir','var') || isempty(subjdir)
subjdir = getenv('SUBJECTS_DIR');
if isempty(subjdir)
error('SUBJECTS_DIR not defined as an environment variable');
end;
end;
surffile = sprintf('%s/%s/surf/%s.%s',subjdir,subj,hemi,surfname);
if ~exist(surffile,'file')
error('surface file %s not found',surffile);
end
if nverts_only
surf = fs_read_surf_nverts(surffile);
else
surf = fs_read_surf(surffile);
surf = fs_find_neighbors(surf);
end;
return;