<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi Darinka,
<div class=""><br class="">
</div>
<div class="">If I comment out one of the ‘fgets’ I can read the file. I suggest you check whether your reported issue is an isolated one, i.e. it only occurs in this specific file, or a more general. If the latter, I’d contact the freesurfer people to make
them aware of the problem. Even better would be to provide them with a patched version of read_surf.m (based on the slightly more recent version they host on
<a href="https://github.com/freesurfer/freesurfer" class="">https://github.com/freesurfer/freesurfer</a>), where code improvements can be suggested by means of a Pull Request. A not so elegant solution would be, to check whether the vnum and fnum are integers,
and if not, rewind to the beginning of the file and do the reading with a single fgets.</div>
<div class=""><br class="">
</div>
<div class="">Below screenshot shows some (old) documentation about the fileformat I found online. It seems that in your file the comment is terminated by a single “\n”, and not by two of them, as is expected currently in read_surf. It may be that Freeview
etc. did not suffer, because it is more robust.</div>
<div class=""><br class="">
</div>
<div class="">Further below, I have pasted a version of read_surf (based on the latest version of the freesurfer repo) that should work in your case.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><img apple-inline="yes" id="4368172F-A678-44AB-8FCF-8DE9DA8BD353" width="1229" height="490" src="cid:5F2F73D4-01CB-4D1A-9780-1332CB0D98D0@dccn.nl" class=""></div>
<div class=""><br class="">
<div>%%%%%%%%%%%%%%%%%%%%%</div>
<div>% PATCHED VERSION</div>
<div><br class="">
</div>
<div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">function</span> [vertex_coords, faces, magic] = read_surf(fname)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% [vertex_coords, faces] = read_surf(fname)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% reads a the vertex coordinates and face lists from a surface file</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% note that reading the faces from a quad file can take a very long</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% time due to the goofy format that they are stored in. If the faces</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% output variable is not specified, they will not be read so it </div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% should execute pretty quickly.</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% read_surf.m</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% Original Author: Bruce Fischl</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% CVS Revision Info:</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% $Author: fischl $</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% $Date: 2014/04/30 12:59:03 $</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% $Revision: 1.7 $</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% Copyright © 2011 The General Hospital Corporation (Boston, MA) "MGH"</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% Terms and conditions for use, reproduction, distribution and contribution</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% are found in the 'FreeSurfer Software License Agreement' contained</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% in the file 'LICENSE' found in the FreeSurfer distribution, and here:</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% <a href="https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense" class="">
https://surfer.nmr.mgh.harvard.edu/fswiki/FreeSurferSoftwareLicense</a></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% Reporting: <a href="mailto:freesurfer@nmr.mgh.harvard.edu" class="">freesurfer@nmr.mgh.harvard.edu</a></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%fid = fopen(fname, 'r') ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%nvertices = fscanf(fid, '%d', 1);</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%all = fscanf(fid, '%d %f %f %f %f\n', [5, nvertices]) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%curv = all(5, :)' ;</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
% open it as a big-endian file</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%QUAD_FILE_MAGIC_NUMBER = (-1 & 0x00ffffff) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45);" class="">
%NEW_QUAD_FILE_MAGIC_NUMBER = (-3 & 0x00ffffff) ;</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(37, 153, 45); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
TRIANGLE_FILE_MAGIC_NUMBER = 16777214 ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
QUAD_FILE_MAGIC_NUMBER = 16777215 ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
NEW_QUAD_FILE_MAGIC_NUMBER = 16777213 ;</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fid = fopen(fname, <span style="color: #b245f3" class="">'rb'</span>, <span style="color: #b245f3" class="">
'b'</span>) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">if</span> (fid < 0)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(178, 69, 243);" class="">
<span style="color: #000000" class=""> str = sprintf(</span>'could not open surface file %s.'<span style="color: #000000" class="">, fname) ;</span></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
error(str) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
end</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
magic = fread3(fid) ;</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">if</span>((magic == QUAD_FILE_MAGIC_NUMBER) | (magic == NEW_QUAD_FILE_MAGIC_NUMBER))</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vnum = fread3(fid) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fnum = fread3(fid) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vertex_coords = fread(fid, vnum*3, <span style="color: #b245f3" class="">'int16'</span>) ./ 100 ; </div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">if</span> (nargout > 1)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">for</span> i=1:fnum</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">for</span> n=1:4</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
faces(i,n) = fread3(fid) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">end</span></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">end</span></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
<span style="color: #000000" class=""> </span>end</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">elseif</span> (magic == TRIANGLE_FILE_MAGIC_NUMBER)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fgets(fid) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fgets(fid) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vnum = fread(fid, 1, <span style="color: #b245f3" class="">'int32'</span>) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fnum = fread(fid, 1, <span style="color: #b245f3" class="">'int32'</span>) ;</div>
<div style="margin: 0px; line-height: normal;" class=""><font face="Courier" size="1" class=""> </font><font color="#25992d" face="Courier" size="1" class="">% possibly the comment line was not followed by two \n’s, this patch is suggested by J.M.Schoffelen,
20190502</font><span style="font-family: Courier; font-size: x-small;" class=""> </span></div>
<div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Courier; font-size: 10px; color: rgb(4, 51, 255);" class=""> if</span><font face="Courier" size="1" class=""> ~isa(vnum,
</font><span style="font-family: Courier; font-size: 10px; color: rgb(178, 69, 243);" class="">'int32'</span><font face="Courier" size="1" class="">) || ~isa(fnum,
</font><span style="font-family: Courier; font-size: 10px; color: rgb(178, 69, 243);" class="">'int32</span><font color="#b245f3" face="Courier" size="1" class="">’</font><font face="Courier" size="1" class="">)</font></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: rgb(37, 153, 45);" class=""> </span>frewind(fid);</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fread3(fid);</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fgets(fid);</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vnum = fread(fid, 1, <span style="color: #b245f3" class="">'int32'</span>) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fnum = fread(fid, 1, <span style="color: #b245f3" class="">'int32'</span>) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
<span style="color: #000000" class=""> </span>end</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vertex_coords = fread(fid, vnum*3, <span style="color: #b245f3" class="">'float32'</span>) ; </div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
<span style="color: #0433ff" class="">if</span> (nargout > 1)</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
faces = fread(fid, fnum*3, <span style="color: #b245f3" class="">'int32'</span>) ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
faces = reshape(faces, 3, fnum)' ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
<span style="color: #000000" class=""> </span>end</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
else</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(178, 69, 243);" class="">
<span style="color: #000000" class=""> fprintf(</span>'ERROR: magic number %d unknown\n'<span style="color: #000000" class="">,magic);</span></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vertex_coords = [];</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
faces = [];</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
<span style="color: #000000" class=""> </span>return<span style="color: #000000" class="">;</span></div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255);" class="">
end</div>
<p style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier; color: rgb(4, 51, 255); min-height: 12px;" class="">
<br class="webkit-block-placeholder">
</p>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
vertex_coords = reshape(vertex_coords, 3, vnum)' ;</div>
<div style="margin: 0px; font-size: 10px; line-height: normal; font-family: Courier;" class="">
fclose(fid) ;</div>
<div class=""><br class="">
</div>
</div>
<div><br class="">
</div>
<div><br class="">
</div>
<div><br class="">
</div>
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 1 May 2019, at 16:56, Darinka Trübutschek <<a href="mailto:darinkat87@gmail.com" class="">darinkat87@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">Dear Jan,</div>
<div class=""><br class="">
</div>
<div class="">thanks for your reply. <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">Yes, I can confirm that I am calling the read_surf function included with the fieldtrip toolbox. I think the problem (perhaps specific to me?) might arise from the fact that the surface files I recently generated with freesurfer (e.g., the attached
lh.pial from sample subject bert) differ slightly in their format from previous ones?
<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">For example, when reading in a previously generated file (that works) into matlab using the read_surf function from fieldtrip, I get the following:</div>
<div class=""><br class="">
</div>
<div class="">fid = fopen(fname, 'rb', 'b') ;<br class="">
if (fid < 0)<br class="">
str = sprintf('could not open curvature file %s.', fname) ;<br class="">
error(str) ;<br class="">
end<br class="">
magic = fread3(fid) ;</div>
<div class=""><br class="">
</div>
<div class="">magic = 16777214;</div>
<div class=""><br class="">
</div>
<div class="">>> a = fgets(fid);<br class="">
>> a<br class="">
<br class="">
a =<br class="">
<br class="">
'created by dante on Fri Jul 20 21:37:20 2018<br class="">
'</div>
<div class="">>> b = fgets(fid);<br class="">
>> b<br class="">
<br class="">
b =<br class="">
<br class="">
'<br class="">
'</div>
<div class=""><br class="">
</div>
<div class="">>> vnum = fread(fid, 1, 'int32') ;<br class="">
fnum = fread(fid, 1, 'int32') ;<br class="">
>> vnum<br class="">
<br class="">
vnum =<br class="">
<br class="">
147285<br class="">
<br class="">
>> fnum<br class="">
<br class="">
fnum =<br class="">
<br class="">
294566<br class="">
</div>
<div class="">When I do the same with the surfaces I just generated (for example, for the attached lh_pial from sample subject bert), variable b no longer corresponds to a newline, but actually already contains some information.<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">fname =<br class="">
<br class="">
'/home/darinka/Test_Freesurfer/subjects/bert/surf/lh.pial'<br class="">
<br class="">
>> fid = fopen(fname, 'rb', 'b') ;<br class="">
if (fid < 0)<br class="">
str = sprintf('could not open curvature file %s.', fname) ;<br class="">
error(str) ;<br class="">
end<br class="">
magic = fread3(fid) ;<br class="">
>> a = fgets(fid);<br class="">
>> a<br class="">
<br class="">
a =<br class="">
<br class="">
'created by darinka on Fri Apr 5 15:33:41 2019<br class="">
'<br class="">
>> b = fgets(fid);<br class="">
>> b<br class="">
<br class="">
b =<br class="">
<br class="">
' XI ������� ����Z ��s����%��g� D�\ ¾=��ٴ���� "�ZR�B@¾����(�¿5����.{#�T��� ¾~��Z���P½���o��$¾@��h ���¾� ��<br class="">
'<br class="">
<br class="">
>> <br class="">
</div>
<div class=""><br class="">
</div>
<div class="">>> vnum = fread(fid, 1, 'int32') ;<br class="">
fnum = fread(fid, 1, 'int32') ;<br class="">
>> vnum<br class="">
<br class="">
vnum =<br class="">
<br class="">
-1.0516e+09<br class="">
<br class="">
>> fnum<br class="">
<br class="">
fnum =<br class="">
<br class="">
-1.0276e+09</div>
<div class=""><br class="">
</div>
<div class="">I am not sure as to why exactly this discrepancy seems to exist (especially given that the visualization in freeview works fine for either one) and whether it is specific to my setup or something more general, but I was hoping that someone with
more expertise in these specific functions might be able to point me in the right direction?</div>
<div class=""><br class="">
</div>
<div class="">Again, many thanks for your help and all the best,</div>
<div class="">Darinka<br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Wed, May 1, 2019 at 3:28 PM Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl" target="_blank" class="">jan.schoffelen@donders.ru.nl</a>> wrote:<br class="">
</div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="">Hi Darinka,
<div class=""><br class="">
</div>
<div class="">I cannot confirm your problem, although admittedly I have used different software versions (matlab/fieldtrip/freesurfer) etc.</div>
<div class="">The problem seems to occur in read_surf, which is not maintained by us, but comes from the freesurfer folks. Can you confirm that the version of read_surf that the call to ft_read_headshape ends up using is in external/freesurfer?</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">best wishes,</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div class="">
<blockquote type="cite" class="">
<div class="">On 1 May 2019, at 14:56, Darinka Trübutschek <<a href="mailto:darinkat87@gmail.com" target="_blank" class="">darinkat87@gmail.com</a>> wrote:</div>
<br class="gmail-m_4070395714673011906gmail-m_-8147963435700313580Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div class="">Dear fieldtrip community,</div>
<div class=""><br class="">
</div>
<div class="">Sorry for double-posting - my original message somehow seems to have been cut short...</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class="">I am currently trying to import cortical surfaces extracted with freesurfer (version: freesurfer-linux-centos7_x86_64-dev-20190403-dacefd1) into Matlab (version: R2018b) using the fieldtrip function ft_read_headshape (version: 20190329). All of
this is run in an Ubuntu 18.04.2 LTS environment. While all of the extracted surfaces seem fine upon visual inspection in freeview, the import into Matlab fails, throwing the following error message:</div>
<div class=""><br class="">
</div>
<div class="">pial = ft_read_headshape('freesurfer/surf/lh.pial');<br class="">
Error using fread<br class="">
Invalid size.<br class="">
<br class="">
Error in read_surf (line 72)<br class="">
vertex_coords = fread(fid, vnum*3, 'float32') ;<br class="">
<br class="">
Error in ft_read_headshape (line 909)<br class="">
[pos, tri] = read_surf(filename);<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">It is most certainly related to the fact that, both for the number of vertices (vnum) and the number of faces (fnum), the function read_surf returns non-sensible (?) values (i.e., vnum = -1.0263e+09 and fnum = -1.0529e+09). The same code produces
no error when run on the same pial surface extracted with a different version of freesurfer (freesurfer-Linux-centos6_x86_64-stable-pub-v6.0.0-2beb96c) in a different Ubuntu environment (Ubuntu 16.04 LTS). </div>
<div class=""><br class="">
</div>
<div class="">As visual inspection in Freeview of the 2 surfaces from the two different Freesurfer versions reveals no obvious differences, I am therefore at a loss as where exactly to start to fix this problem and would be grateful for any help.</div>
<div class=""><br class="">
</div>
<div class="">Many thanks!</div>
<div class="">Darinka</div>
<div class=""><br class="">
</div>
-- <br class="">
<div dir="ltr" class="gmail-m_4070395714673011906gmail-m_-8147963435700313580gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class=""><font face="tahoma, sans-serif" class="">Darinka Trübutschek, PhD</font></div>
<div dir="ltr" class=""><font face="tahoma, sans-serif" class=""><br class="">
</font>
<div class="">
<div class="">Department of Experimental Psychology</div>
<div class="">Anna Watts Building</div>
<div class="">Radcliffe Observatory Quarter</div>
<div class="">Woodstock Road</div>
<div class="">Oxford, OX2 6GG</div>
<div class="">UK</div>
</div>
<div class=""><font face="tahoma, sans-serif" class=""><br class="">
</font></div>
<div class=""><font face="tahoma, sans-serif" class="">website: <a href="https://sites.google.com/site/dtruebutschek/" target="_blank" class="">https://sites.google.com/site/dtruebutschek/</a></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
_______________________________________________<br class="">
fieldtrip mailing list<br class="">
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer" target="_blank" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br class="">
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer" target="_blank" class="">https://doi.org/10.1371/journal.pcbi.1002202</a><br class="">
</blockquote>
</div>
<br clear="all" class="">
<br class="">
-- <br class="">
<div dir="ltr" class="gmail-m_4070395714673011906gmail_signature">
<div dir="ltr" class="">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">
<div dir="ltr" class=""><font face="tahoma, sans-serif" class="">Darinka Trübutschek, PhD</font></div>
<div dir="ltr" class=""><font face="tahoma, sans-serif" class=""><br class="">
</font>
<div class="">
<div class="">Department of Experimental Psychology</div>
<div class="">Anna Watts Building</div>
<div class="">Radcliffe Observatory Quarter</div>
<div class="">Woodstock Road</div>
<div class="">Oxford, OX2 6GG</div>
<div class="">UK</div>
</div>
<div class=""><font face="tahoma, sans-serif" class=""><br class="">
</font></div>
<div class=""><font face="tahoma, sans-serif" class="">website: <a href="https://sites.google.com/site/dtruebutschek/" target="_blank" class="">https://sites.google.com/site/dtruebutschek/</a></font></div>
</div>
</div>
</div>
</div>
</div>
</div>
<span id="cid:f_jv5bp40a0"><lh.pial></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>