this patch fixes an issue when using MATLAB 2013 or higher.
Details in https://mail.nmr.mgh.harvard.edu/pipermail//freesurfer/2016-March/044183.html
--- freesurfer.orig/matlab/SearchProjectionOnPial.m	2013-05-13 23:34:06.000000000 +0200
+++ freesurfer/matlab/SearchProjectionOnPial.m	2016-12-20 21:37:40.732901000 +0100
@@ -4,7 +4,11 @@
 % limit redundancies in the resulting path file.
 
 verticeslist=[];
-for t=1:step:size(perim,2)
+% this file has been patched as described in 
+% https://mail.nmr.mgh.harvard.edu/pipermail//freesurfer/2016-March/044183.html
+%for t=1:step:size(perim,2)
+si=max(size(perim));
+for t=1:step:si
     [nearestIndexMT,nearestValuesMT]=mesh_vertex_nearest(mesh_total.vertices,mesh_outer.vertices(perim(t),:));
     verticeslist= [verticeslist nearestIndexMT];
 end
