Hi & sorry for the second post...

 

...I made a typo in my fix. Should of course be

 

If nargout>1,...

 

Cheers,

               Matti

 

From: freesurfer-bounces@nmr.mgh.harvard.edu [mailto:freesurfer-bounces@nmr.mgh.harvard.edu] On Behalf Of Matti Stenroos
Sent: 29 September 2011 15:00
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Bug in freesurfer_read_surf.m & a quick fix

 

Hi,

 

In FreeSurfer 4.3.0, the Matlab routine “freesurfer_read_surf.m” crashes, when run with one output argument:

 

function [vertices, faces] = freesurfer_read_surf(fname)

 

The function help says:

% 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.

 

However, when the function is called in the form

 

vertices = freesurfer_read_surf(fname),

 

it crashes on line

152 faces = faces + 1;

 

because the variable “faces” is not defined.

 

A quick fix: wrap line 152 inside an if clause:

 

If nargin>1

faces=faces+1;

end

 

Unfortunately I don’t know, how to check, whether this has been fixed in later releases.

 

Cheers,

Matti