fs=getenv('FREESURFER_HOME');
setenv('FS_QT_HOME',fullfile(fs,'lib','qt'));
setenv('QTLIBPATH',fullfile(fs,'lib','qt','lib'))
setenv('qtplugin',fullfile(fs,'lib','qt','plugins'))
setenv('vtk',fullfile(fs,'lib','vtk'))
lib=getenv('LD_LIBRARY_PATH');
qtlib=getenv('QTLIBPATH');
plugins=getenv('qtplugin');
setenv('LD_LIBRARY_PATH',strcat(lib,':',qtlib,':',plugins,fullfile(fs,'lib','vtk')))
if upper < fdrtreshold
upper = fdrtreshold + 1;
fdrtreshold=num2str(fdrtreshold);upper=num2str(upper);
fdrtreshold=sprintf('%s,%s',fdrtreshold,upper);
leftcommand=sprintf('%s/%s/surf/lh.%s:annot=aparc.annot:annot_outline=1:overlay=%s:overlay_threshold=%s',SUBJECTS_DIR,template,surface,leftmgh,fdrtreshold);
rightcommand=sprintf('%s/%s/surf/rh.%s:annot=aparc.annot:annot_outline=1:overlay=%s:overlay_threshold=%s ',SUBJECTS_DIR,template,surface,rightmgh,fdrtreshold);
freeview='freeview';
commandline=sprintf('%s -f %s -f %s -viewport 3d &',freeview,leftcommand,rightcommand);
system(commandline)