<html><head></head><body><div style="color:#000; background-color:#fff; font-family:garamond, new york, times, serif;font-size:16px"><div id="yui_3_16_0_1_1452502996007_9345"><span id="yui_3_16_0_1_1452502996007_9351">Good morning everyone:</span></div><div id="yui_3_16_0_1_1452502996007_9352"><br><span id="yui_3_16_0_1_1452502996007_9351"></span></div><div id="yui_3_16_0_1_1452502996007_9372" dir="ltr"><span id="yui_3_16_0_1_1452502996007_9351">I am new to fieldtrip am having trouble loading EEG data in a GUI . While there is no trouble loading the same file in a script , when the same file is being loaded inside a simple GUI , Matlab hangs, and I have to press ctrl C to exit! I am really puzzled! I understand it could be the GUI issue and not fieldtrip function issue.</span></div><div id="yui_3_16_0_1_1452502996007_9405" dir="ltr"><span id="yui_3_16_0_1_1452502996007_9351">I thought if someone have come across this problem can save me time.</span></div><div id="yui_3_16_0_1_1452502996007_9406" dir="ltr"><br><span id="yui_3_16_0_1_1452502996007_9351"></span></div><div id="yui_3_16_0_1_1452502996007_9407" dir="ltr"><span id="yui_3_16_0_1_1452502996007_9351">I attached the two codes to compare.</span></div><div id="yui_3_16_0_1_1452502996007_9433" dir="ltr"><span id="yui_3_16_0_1_1452502996007_9351"></span></div><div id="yui_3_16_0_1_1452502996007_9344"><div id="yui_3_16_0_1_1452502996007_9442"> </div><div id="yui_3_16_0_1_1452502996007_9572">This is the script that works<br></div><div id="yui_3_16_0_1_1452502996007_9571">************************************</div><div id="yui_3_16_0_1_1452502996007_9570"><br></div><div id="yui_3_16_0_1_1452502996007_9495" dir="ltr"><br class="" id="yui_3_16_0_1_1452502996007_9444">clear all;<br class="" id="yui_3_16_0_1_1452502996007_9446">clc;<br class="" id="yui_3_16_0_1_1452502996007_9448">close all;<br class="" id="yui_3_16_0_1_1452502996007_9450">[filename, pathname] = uigetfile({'*.edf;*.e', 'Nicolete files (*.edf;*.e)'; '*.*', 'All files (*.*)'}, 'Select edf file');<br class="" id="yui_3_16_0_1_1452502996007_9539"><br class="" id="yui_3_16_0_1_1452502996007_9541">if isequal(filename, 0) || isequal(pathname, 0)<br class="" id="yui_3_16_0_1_1452502996007_9543"> disp('Exiting...');<br class="" id="yui_3_16_0_1_1452502996007_9545"> return;<br class="" id="yui_3_16_0_1_1452502996007_9547">end<br class="" id="yui_3_16_0_1_1452502996007_9549"><br class="" id="yui_3_16_0_1_1452502996007_9551">file = fullfile(pathname, filename)<br class="" id="yui_3_16_0_1_1452502996007_9553">cfg1 = [];<br class="" id="yui_3_16_0_1_1452502996007_9555">cfg1.trl = [1 61440 0];<br class="" id="yui_3_16_0_1_1452502996007_9557">cfg1.dataset = filename%'K_S_Event_Marker_1.edf';<br class="" id="yui_3_16_0_1_1452502996007_9559"> cfg1 = ft_definetrial( cfg1 );<br class="" id="yui_3_16_0_1_1452502996007_9561">cfg1.continuous = 'yes';<br class="" id="yui_3_16_0_1_1452502996007_9563"> data1 = ft_preprocessing(cfg1);<br class="" id="yui_3_16_0_1_1452502996007_9565"> display('Finished')</div><div id="yui_3_16_0_1_1452502996007_9581" dir="ltr"><br></div><div id="yui_3_16_0_1_1452502996007_9582" dir="ltr">***************************** Here is the GUI code, which does not work<br></div><div id="yui_3_16_0_1_1452502996007_9722" dir="ltr"><br></div><div id="yui_3_16_0_1_1452502996007_9924" dir="ltr"><br></div><div id="yui_3_16_0_1_1452502996007_9911" dir="ltr">function varargout = loadDataGUI(varargin)<br class="" id="yui_3_16_0_1_1452502996007_9724"><br class="" id="yui_3_16_0_1_1452502996007_9726">% Begin initialization code - DO NOT EDIT<br class="" id="yui_3_16_0_1_1452502996007_9728">gui_Singleton = 1;<br class="" id="yui_3_16_0_1_1452502996007_9730">gui_State = struct('gui_Name', mfilename, ...<br class="" id="yui_3_16_0_1_1452502996007_9732"> 'gui_Singleton', gui_Singleton, ...<br class="" id="yui_3_16_0_1_1452502996007_9734"> 'gui_OpeningFcn', @loadDataGUI_OpeningFcn, ...<br class="" id="yui_3_16_0_1_1452502996007_9736"> 'gui_OutputFcn', @loadDataGUI_OutputFcn, ...<br class="" id="yui_3_16_0_1_1452502996007_9738"> 'gui_LayoutFcn', [] , ...<br class="" id="yui_3_16_0_1_1452502996007_9740"> 'gui_Callback', []);<br class="" id="yui_3_16_0_1_1452502996007_9742">if nargin && ischar(varargin{1})<br class="" id="yui_3_16_0_1_1452502996007_9744"> gui_State.gui_Callback = str2func(varargin{1});<br class="" id="yui_3_16_0_1_1452502996007_9746">end<br class="" id="yui_3_16_0_1_1452502996007_9748"><br class="" id="yui_3_16_0_1_1452502996007_9750">if nargout<br class="" id="yui_3_16_0_1_1452502996007_9752"> [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});<br class="" id="yui_3_16_0_1_1452502996007_9754">else<br class="" id="yui_3_16_0_1_1452502996007_9756"> gui_mainfcn(gui_State, varargin{:});<br class="" id="yui_3_16_0_1_1452502996007_9758">end<br class="" id="yui_3_16_0_1_1452502996007_9760">% End initialization code - DO NOT EDIT<br class="" id="yui_3_16_0_1_1452502996007_9762"><br class="" id="yui_3_16_0_1_1452502996007_9764"><br class="" id="yui_3_16_0_1_1452502996007_9766">% --- Executes just before loadDataGUI is made visible.<br class="" id="yui_3_16_0_1_1452502996007_9768">function loadDataGUI_OpeningFcn(hObject, eventdata, handles, varargin)<br class="" id="yui_3_16_0_1_1452502996007_9770">% This function has no output args, see OutputFcn.<br class="" id="yui_3_16_0_1_1452502996007_9772">% hObject handle to figure<br class="" id="yui_3_16_0_1_1452502996007_9774">% eventdata reserved - to be defined in a future version of MATLAB<br class="" id="yui_3_16_0_1_1452502996007_9776">% handles structure with handles and user data (see GUIDATA)<br class="" id="yui_3_16_0_1_1452502996007_9778">% varargin command line arguments to loadDataGUI (see VARARGIN)<br class="" id="yui_3_16_0_1_1452502996007_9780"><br class="" id="yui_3_16_0_1_1452502996007_9782">% Choose default command line output for loadDataGUI<br class="" id="yui_3_16_0_1_1452502996007_9784">handles.output = hObject;<br class="" id="yui_3_16_0_1_1452502996007_9786"><br class="" id="yui_3_16_0_1_1452502996007_9788">% Update handles structure<br class="" id="yui_3_16_0_1_1452502996007_9790">guidata(hObject, handles);<br class="" id="yui_3_16_0_1_1452502996007_9792"><br class="" id="yui_3_16_0_1_1452502996007_9794">% UIWAIT makes loadDataGUI wait for user response (see UIRESUME)<br class="" id="yui_3_16_0_1_1452502996007_9796">% uiwait(handles.figure1);<br class="" id="yui_3_16_0_1_1452502996007_9798"><br class="" id="yui_3_16_0_1_1452502996007_9800">% --- Outputs from this function are returned to the command line.<br class="" id="yui_3_16_0_1_1452502996007_9802">function varargout = loadDataGUI_OutputFcn(hObject, eventdata, handles) <br class="" id="yui_3_16_0_1_1452502996007_9804">% varargout cell array for returning output args (see VARARGOUT);<br class="" id="yui_3_16_0_1_1452502996007_9806">% hObject handle to figure<br class="" id="yui_3_16_0_1_1452502996007_9808">% eventdata reserved - to be defined in a future version of MATLAB<br class="" id="yui_3_16_0_1_1452502996007_9810">% handles structure with handles and user data (see GUIDATA)<br class="" id="yui_3_16_0_1_1452502996007_9812"><br class="" id="yui_3_16_0_1_1452502996007_9814">% Get default command line output from handles structure<br class="" id="yui_3_16_0_1_1452502996007_9816">varargout{1} = handles.output;<br class="" id="yui_3_16_0_1_1452502996007_9818"><br class="" id="yui_3_16_0_1_1452502996007_9820"><br class="" id="yui_3_16_0_1_1452502996007_9822">% --- Executes on button press in loadData.<br class="" id="yui_3_16_0_1_1452502996007_9824">function loadData_Callback(hObject, eventdata, handles)<br class="" id="yui_3_16_0_1_1452502996007_9826">% hObject handle to loadData (see GCBO)<br class="" id="yui_3_16_0_1_1452502996007_9828">% eventdata reserved - to be defined in a future version of MATLAB<br class="" id="yui_3_16_0_1_1452502996007_9830">% handles structure with handles and user data (see GUIDATA)<br class="" id="yui_3_16_0_1_1452502996007_9832"><br class="" id="yui_3_16_0_1_1452502996007_9834"><br class="" id="yui_3_16_0_1_1452502996007_9836">%Load the EEG file<br class="" id="yui_3_16_0_1_1452502996007_9838">if isempty(handles)<br class="" id="yui_3_16_0_1_1452502996007_9840"> disp('ERROR:::Please select a valid Montage');<br class="" id="yui_3_16_0_1_1452502996007_9842">end<br class="" id="yui_3_16_0_1_1452502996007_9844">[filename, pathname] = uigetfile({'*.edf;*.e', 'Nicolete files (*.edf;*.e)'; '*.*', 'All files (*.*)'}, 'Select edf file');<br class="" id="yui_3_16_0_1_1452502996007_9846"><br class="" id="yui_3_16_0_1_1452502996007_9848">if isequal(filename, 0) || isequal(pathname, 0)<br class="" id="yui_3_16_0_1_1452502996007_9850"> disp('Exiting...');<br class="" id="yui_3_16_0_1_1452502996007_9852"> return;<br class="" id="yui_3_16_0_1_1452502996007_9854">end<br class="" id="yui_3_16_0_1_1452502996007_9856"><br class="" id="yui_3_16_0_1_1452502996007_9858">file = fullfile(pathname, filename)<br class="" id="yui_3_16_0_1_1452502996007_9860">cfg1 = [];<br class="" id="yui_3_16_0_1_1452502996007_9862"><br class="" id="yui_3_16_0_1_1452502996007_9864"><br class="" id="yui_3_16_0_1_1452502996007_9866">% beginSample=1; %The indice of sample to begin<br class="" id="yui_3_16_0_1_1452502996007_9868">% endSample=61440; %The indice of sample to end (1 min data to load, 60*1024=61440)<br class="" id="yui_3_16_0_1_1452502996007_9870">% <br class="" id="yui_3_16_0_1_1452502996007_9872">cfg1.trl = [1 61440 0];<br class="" id="yui_3_16_0_1_1452502996007_9874">cfg1.dataset = filename%'K_S_Event_Marker_1.edf';<br class="" id="yui_3_16_0_1_1452502996007_9876"> cfg1 = ft_definetrial( cfg1 );<br class="" id="yui_3_16_0_1_1452502996007_9878">cfg1.continuous = 'yes';<br class="" id="yui_3_16_0_1_1452502996007_9880"> data1 = ft_preprocessing(cfg1);<br class="" id="yui_3_16_0_1_1452502996007_9882">%set(handles.filePath,'string',file );<br class="" id="yui_3_16_0_1_1452502996007_9884"><br class="" id="yui_3_16_0_1_1452502996007_9886"><br class="" id="yui_3_16_0_1_1452502996007_9888"><br class="" id="yui_3_16_0_1_1452502996007_9890">function filePath_Callback(hObject, eventdata, handles)<br class="" id="yui_3_16_0_1_1452502996007_9892">% hObject handle to filePath (see GCBO)<br class="" id="yui_3_16_0_1_1452502996007_9894">% eventdata reserved - to be defined in a future version of MATLAB<br class="" id="yui_3_16_0_1_1452502996007_9896">% handles structure with handles and user data (see GUIDATA)<br class="" id="yui_3_16_0_1_1452502996007_9898"><br class="" id="yui_3_16_0_1_1452502996007_9900">% Hints: get(hObject,'String') returns contents of filePath as text<br class="" id="yui_3_16_0_1_1452502996007_9902">% str2double(get(hObject,'String')) returns contents of filePath as a double<br class="" id="yui_3_16_0_1_1452502996007_9904">% global handles;<br class="" id="yui_3_16_0_1_1452502996007_9906">% display(handles.file)<br class="" id="yui_3_16_0_1_1452502996007_9908"> set(handles.filePath,'string',handles.file );<br class="" id="yui_3_16_0_1_1452502996007_9910"><br></div><div id="yui_3_16_0_1_1452502996007_9496" dir="ltr"><br></div><div id="yui_3_16_0_1_1452502996007_9520" dir="ltr"><br></div><div id="yui_3_16_0_1_1452502996007_9530" dir="ltr">*************************************************************<br></div></div><div id="yui_3_16_0_1_1452502996007_9384" class="signature"><div id="yui_3_16_0_1_1452502996007_9383"><font id="yui_3_16_0_1_1452502996007_9382" color="#000000"><div id="yui_3_16_0_1_1452502996007_9387" style="font-family:'bookman old style', 'new york', times, serif;margin-top:0cm;margin-right:0cm;margin-bottom:0pt;margin-left:0cm;" class="MsoPlainText"><span id="yui_3_16_0_1_1452502996007_9390" style=""><font id="yui_3_16_0_1_1452502996007_9389" face="times new roman, new york, times, serif"><font id="yui_3_16_0_1_1452502996007_9388" size="2">__________________________________________________</font></font></span></div> <div id="yui_3_16_0_1_1452502996007_9386" style="font-family:'bookman old style', 'new york', times, serif;margin-top:0cm;margin-right:0cm;margin-bottom:0pt;margin-left:0cm;" class="MsoPlainText"><span id="yui_3_16_0_1_1452502996007_9393" style=""><font id="yui_3_16_0_1_1452502996007_9392" face="times new roman, new york, times, serif"><font id="yui_3_16_0_1_1452502996007_9391" size="2">Leila Ayoubian, PhD.<br>Institute of Psychiatry, Psychology and Neuroscience<br>King's College London<br></font></font></span></div> <div id="yui_3_16_0_1_1452502996007_9381" style="margin-top:0cm;margin-right:0cm;margin-bottom:0pt;margin-left:0cm;" class="MsoPlainText"><font class="Apple-style-span" size="2" face="'times new roman', 'new york', times, serif"><br></font></div></font></div><div id="yui_3_16_0_1_1452502996007_9385" style="MARGIN:0cm 0cm 0pt;" class="MsoPlainText"><font color="#000000"><font style="" face="bookman old style, new york, times, serif"><font face="bookman old style, new york, times, serif"><font color="#000000"><span style="color:rgb(84, 140, 214);font-size:9pt;font-family:Arial;" lang="EN-US"><span style="font-size:10pt;font-family:sans-serif;"><br></span></span></font></font></font></font></div></div></div></body></html>