This was fixed in 7.11. You can use that version or copy the attached file to this location
$FREESURFER_HOME/matlab/freesurfer_read_surf.m

On 5/11/2021 2:28 PM, Zeng, Victor (BIDMC - Keshavan - Psychiatry) wrote:

Hi,


I am using Matlab R2014a, and FS7.1.0


and receiving this error when I try to run -localGI. Is there a package I might be missing? Or am I using an outdated version of Matlab?


=================
mris_smooth -nw -n 30 /mnt/V/Datasets/BSNIP2/Processing/Finished/24015_S5437DFD_ASSET/surf/tmp-mris_compute_lgi-lh.pial/lh.pial-outer-main ./lh.pial-outer-smoothed
=================
smoothing for 30 iterations
smoothing surface tessellation for 30 iterations...
smoothing complete - recomputing first and second fundamental forms...
=================
mris_euler_number ./lh.pial-outer-smoothed
=================
euler # = v-e+f = 2g-2: 61554 - 184656 + 123104 = 2 --> 0 holes
      F =2V-4:          123104 = 123108-4 (0)
      2E=3F:            369312 = 369312 (0)

total defect index = 0
=================
mris_convert -n lh.pial-outer-smoothed /mnt/V/Datasets/BSNIP2/Processing/Finished/24015_S5437DFD_ASSET/surf/tmp-mris_compute_lgi-lh.pial/lh.pial-outer-smoothed-normals.asc
=================
=================
find_corresponding_center_FSformat('lh.pial','lh.pial-outer-smoothed',100,'/mnt/V/Datasets/BSNIP2/Processing/Finished/24015_S5437DFD_ASSET/surf/tmp-mris_compute_lgi-lh.pial','/tmp/mrc_30700_.m'); exit
=================

                            < M A T L A B (R) >
                  Copyright 1984-2014 The MathWorks, Inc.
                    R2014a (8.3.0.532) 64-bit (glnxa64)
                             February 11, 2014
.

.

.

To get started, type one of these: helpwin, helpdesk, or demo.
For product information, visit www.mathworks.com.

>> Warning: Input argument must be a string.
> In ver at 41
  In freesurfer_read_surf at 70
  In find_corresponding_center_FSformat at 26
Error using fprintf
Function is not defined for 'struct' inputs.

Error in freesurfer_read_surf (line 70)
fprintf('FREESURFER_READ_SURF [v %s]\n',ver(11:15));

Error in find_corresponding_center_FSformat (line 26)
[mesh_pial.vertices, mesh_pial.faces] = freesurfer_read_surf(pial);

>>
ERROR: find_corresponding_center_FSformat did not complete successfully!
Command exited with non-zero status 1
@#@FSTIME  2021:05:11:17:18:12 mris_compute_lgi N 2 e 31.58 S 6.20 U 53.23 P 188% M 1319608 F 0 R 1468406 W 0 c 71733 w 7023 I 8832 O 30496 L 17.98 17.99 18.00
@#@FSLOADPOST 2021:05:11:17:18:44 mris_compute_lgi N 2 17.35 17.83 17.95
Linux Gamma 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2+deb8u3 (2016-07-02) x86_64 GNU/Linux

recon-all -s 24015_S5437DFD_ASSET exited with ERRORS at Tue May 11 17:18:44 EDT 2021

For more details, see the log file /mnt/V/Datasets/BSNIP2/Processing/Finished/24015_S5437DFD_ASSET/scripts/recon-all.log To report a problem, see http://surfer.nmr.mgh.harvard.edu/fswiki/BugReporting


Victor Zeng
Beth Israel Deaconess Medical Center
Keshavan Lab
--

------------------------------------------------------------------------

This message is intended for the use of the person(s) to whom it may be addressed. It may contain information that is privileged, confidential, or otherwise protected from disclosure under applicable law. If you are not the intended recipient, any dissemination, distribution, copying, or use of this information is prohibited. If you have received this message in error, please permanently delete it and immediately notify the sender. Thank you.

_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

function [vertices, faces] = freesurfer_read_surf(fname)

% freesurfer_read_surf - FreeSurfer I/O function to read a surface file
% 
% [vertices, faces] = freesurfer_read_surf(fname)
% 
% Reads the vertex coordinates (mm) and face lists from a surface file.
% 
% Surface files are stored as either triangulations or quadrangulations.
% That is, for a triangulation, each face is defined by 3 vertices.  For a
% quadrangulation, each face is defined by 4 vertices.  The rows of 'faces'
% contain indices into the rows of 'vertices', the latter holds the XYZ
% coordinates of each vertex.
%
% The freesurfer faces index the vertices in counter-clockwise order (when
% viewed from the outside of the surface).  This is consistent with a
% right-hand rule.  If we have vertices
%
% C           B
%
%
%       A
%
% Then we can calculate an edge vector from A to B (ie, AB = B - A) and
% another edge vector from A to C (ie, AC = C - A).  If you form a "gun"
% with your thumb and forefinger of the right hand, then align your thumb
% with the AB vector and your forefinger with the AC vector, your palm is
% facing out of the screen and extending your middle finger in the
% orthogonal direction to the plane of the screen will give the outward
% surface normal of the triangle ABC.  (If you lookup "triangle" on
% Wolfram's mathworld, you can see that AB is referred to as c and AC is
% referred to as b.)
%
% However, if this surface is read into matlab, it will give INWARD surface
% normals in the matlab patch command.  For some reason, matlab is not
% following the right hand rule.  To get OUTWARD normals with the matlab
% patch command, use faces(:,[1 3 2]) (see below).
%
% The vertex coordinates are in mm.  The FreeSurfer coordinate
% system for surfaces is quite simple, but relating to their MRI
% cor-??? files is too confusing to explain here; see the FreeSurfer
% homepage or google the documentation by Graham Wideman.  For the
% surfaces, at least, the origin is somewhere in the center of the
% head, and the vertex XYZ coordinates are oriented such that +X is
% right, +Y is anterior and +Z is superior (this is the
% FreeSurfer RAS coordinate system).
%
% Note that reading the faces of a quad file can take a long
% time due to their compact storage format.  In this case, the return of
% vertices can be faster if the face output variable is not specified; in
% this case, the faces are not read.
% 
% Try this to visualize the surface:
% Hp = patch('vertices',vertices,'faces',faces(:,[1 3 2]),...
%       'facecolor',[.5 .5 .5],'edgecolor','none')
% camlight('headlight','infinite')
% vertnormals = get(Hp,'vertexnormals');
%
% See also freesurfer_write_surf, freesurfer_read_curv,
%          freesurfer_read_wfile
%


% Copyright (C) 2000  Darren L. Weber

% History:  08/2000, Darren.Weber_at_radiology.ucsf.edu
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% There used to be a line here where ver was set to the version of
% the file. Without it, "ver" reverts to a matlab defined structure
% and generates an error.
%fprintf('FREESURFER_READ_SURF [v %s]\n',ver(11:15));

if(nargin < 1)
    help freesurfer_read_surf;
    return;
end

%QUAD_FILE_MAGIC_NUMBER =  (-1 & 0x00ffffff) ;
%NEW_QUAD_FILE_MAGIC_NUMBER =  (-3 & 0x00ffffff) ;

TRIANGLE_FILE_MAGIC_NUMBER  =  16777214;
QUAD_FILE_MAGIC_NUMBER      =  16777215;


% open it as a big-endian file
fid = fopen(fname, 'rb', 'b');
if (fid < 0),
    str = sprintf('could not open surface file %s.', fname);
    error(str);
end

fprintf('...reading surface file: %s\n', fname);
tic;

magic = freesurfer_fread3(fid);

if (magic == QUAD_FILE_MAGIC_NUMBER),
    Nvertices = freesurfer_fread3(fid);
    Nfaces = freesurfer_fread3(fid);
    fprintf('...reading %d quad file vertices\n',Nvertices);
    vertices = fread(fid, Nvertices*3, 'int16') ./ 100 ; 
    if (nargout > 1),
        fprintf('...reading %d quad file faces (please wait)\n',Nfaces);
        faces = zeros(Nfaces,4);
        for iface = 1:Nfaces,
            for n=1:4,
                faces(iface,n) = freesurfer_fread3(fid) ;
            end
            if(~rem(iface, 10000)), fprintf(' %7.0f',iface); end
            if(~rem(iface,100000)), fprintf('\n'); end
        end
    end
elseif (magic == TRIANGLE_FILE_MAGIC_NUMBER),
    fprintf('...reading triangle file\n');
    tline = fgets(fid); % read creation date text line
    tline = fgets(fid); % read info text line
    
    Nvertices = fread(fid, 1, 'int32'); % number of vertices
    Nfaces = fread(fid, 1, 'int32'); % number of faces
    
    % vertices are read in column format and reshaped below
    vertices = fread(fid, Nvertices*3, 'float32');
    
    % faces are read in column format and reshaped
    faces = fread(fid, Nfaces*3, 'int32');
    faces = reshape(faces, 3, Nfaces)';
else
    str = sprintf('unknown magic number in surface file %s.', fname);
    error(str);
end

vertices = reshape(vertices, 3, Nvertices)';
fclose(fid);

fprintf('...adding 1 to face indices for matlab compatibility.\n');
faces = faces + 1;

t=toc; fprintf('...done (%6.2f sec)\n\n',t);

return
_______________________________________________
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
The information in this e-mail is intended only for the person to whom it is 
addressed. If you believe this e-mail was sent to you in error and the e-mail 
contains patient information, please contact the Mass General Brigham 
Compliance HelpLine at http://www.massgeneralbrigham.org/complianceline . If 
the e-mail was sent to you in error but does not contain patient information, 
please contact the sender and properly dispose of the e-mail.
Please note that this e-mail is not secure (encrypted).  If you do not wish to 
continue communication over unencrypted e-mail, please notify the sender of 
this message immediately.  Continuing to send or respond to e-mail after 
receiving this message means you understand and accept this risk and wish to 
continue to communicate over unencrypted e-mail. 

Reply via email to