tomwalters@0: % procedure for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % tomwalters@0: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: bleeck@3: tomwalters@0: tomwalters@0: tomwalters@0: function varargout = W(varargin) tomwalters@0: tomwalters@0: % Begin initialization code - DO NOT EDIT tomwalters@0: gui_Singleton = 1; tomwalters@0: gui_State = struct('gui_Name', mfilename, ... tomwalters@0: 'gui_Singleton', gui_Singleton, ... tomwalters@0: 'gui_OpeningFcn', @single_channel_gui_OpeningFcn, ... tomwalters@0: 'gui_OutputFcn', @single_channel_gui_OutputFcn, ... tomwalters@0: 'gui_LayoutFcn', [] , ... tomwalters@0: 'gui_Callback', []); tomwalters@0: if nargin & isstr(varargin{1}) tomwalters@0: gui_State.gui_Callback = str2func(varargin{1}); tomwalters@0: end tomwalters@0: tomwalters@0: if nargout tomwalters@0: [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); tomwalters@0: else tomwalters@0: gui_mainfcn(gui_State, varargin{:}); tomwalters@0: end tomwalters@0: % End initialization code - DO NOT EDIT tomwalters@0: tomwalters@0: tomwalters@0: % --- Executes just before single_channel_gui is made visible. tomwalters@0: function single_channel_gui_OpeningFcn(hObject, eventdata, handles, varargin) tomwalters@0: tomwalters@0: % Choose default command line output for single_channel_gui tomwalters@0: handles.output = hObject; tomwalters@0: tomwalters@0: set(handles.figure1,'Name','select channel'); tomwalters@0: tomwalters@0: import_options=varargin{1}; tomwalters@0: handles.output=-1; tomwalters@0: if isstruct(import_options) tomwalters@0: handles.import_options=import_options; tomwalters@0: else tomwalters@0: if strcmp(import_options,'close'); tomwalters@0: close(handles.figure1); tomwalters@0: return tomwalters@0: end tomwalters@0: if strcmp(import_options,'getchannelnumber') tomwalters@0: if ~isfield(handles,'slideredit') tomwalters@0: handles.output=1; tomwalters@0: else tomwalters@0: handles.output=slidereditcontrol_get_value(handles.slideredit); tomwalters@0: end tomwalters@0: guidata(hObject, handles); tomwalters@0: return tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: % if ~isfield(import_options.info.children.single_channel,'windowhandle') tomwalters@0: % fig=figure(import_options.info.children.single_channel.windowhandle); tomwalters@0: % import_options.info.children.single_channel.windowhandle=fig; tomwalters@0: % end tomwalters@0: % tomwalters@0: if ~isfield(handles,'figure_handle') || ~ishandle(handles.figure_handle) tomwalters@0: handles.figure_handle=import_options.info.children.single_channel.windowhandle; tomwalters@0: % set the window next to the graphic window tomwalters@0: set(handles.figure1,'units','pixels'); tomwalters@0: set(handles.figure_handle,'units','pixels'); tomwalters@0: orgpos=get(handles.figure1,'position'); tomwalters@0: winpos=get(handles.figure_handle,'position'); tomwalters@0: newpos(1)=winpos(1)+winpos(3); tomwalters@0: newpos(2)=winpos(2); tomwalters@0: movegui(handles.figure1,newpos); tomwalters@0: % newpos(3:4)=orgpos(3:4); tomwalters@0: % set(handles.figure1,'position',orgpos); tomwalters@0: end tomwalters@0: tomwalters@0: % this is an indicator for the main function, that it is called from a tomwalters@0: % child tomwalters@0: handles.import_options.info.iscallfromchild=1; tomwalters@0: tomwalters@0: data=import_options.data; tomwalters@0: nrchan=getnrchannels(data.bmm); tomwalters@0: if isfield(import_options.info.children.single_channel,'channelnumber') tomwalters@0: curr_chan=import_options.info.children.single_channel.channelnumber; tomwalters@0: else tomwalters@0: curr_chan=round(nrchan/2); tomwalters@0: end tomwalters@0: tomwalters@0: % handles.current_channel_nr=middle_chan; tomwalters@0: handles.cfs=getcf(data.bmm); tomwalters@0: tomwalters@0: % set up the slider edit control tomwalters@0: handles.slideredit=slidereditcontrol_setup(... tomwalters@0: handles.slider1,... % handle of the slider tomwalters@0: handles.edit1,...% handle of the edit control tomwalters@0: 1, ... % min value tomwalters@0: nrchan, ... % max value tomwalters@0: curr_chan, ... % current value tomwalters@0: 0, ... % islog tomwalters@0: 1, ...% multiplier on the edit control tomwalters@0: 0); % nr digits in the edit control after comma tomwalters@0: tomwalters@0: handles.slideredit=slidereditcontrol_set_range(handles.slideredit,10); % makes a stepsize of 1 tomwalters@0: tomwalters@0: set(handles.edit3,'String',1); tomwalters@0: tomwalters@0: % plot the result tomwalters@0: handles=update(handles); tomwalters@0: tomwalters@0: % Update handles structure tomwalters@0: guidata(hObject, handles); tomwalters@0: tomwalters@0: % UIWAIT makes single_channel_gui wait for user response (see UIRESUME) tomwalters@0: % uiwait(handles.figure1); tomwalters@0: tomwalters@0: tomwalters@0: % --- Outputs from this function are returned to the command line. tomwalters@0: function varargout = single_channel_gui_OutputFcn(hObject, eventdata, handles) tomwalters@0: tomwalters@0: % Get default command line output from handles structure tomwalters@0: if isstruct(handles) tomwalters@0: varargout{1} = handles.output; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: function edit1_Callback(hObject, eventdata, handles) tomwalters@0: curval=get(hObject,'String'); tomwalters@0: curval=str2num(curval); tomwalters@0: handles.slideredit=... tomwalters@0: slidereditcontrol_set_raweditvalue(handles.slideredit,curval); tomwalters@0: handles=update(handles); tomwalters@0: guidata(hObject, handles); tomwalters@0: function edit2_Callback(hObject, eventdata, handles) tomwalters@0: curval=get(hObject,'String'); tomwalters@0: curval=str2num(curval); tomwalters@0: nrchan=fre2chan(handles.import_options.data.bmm,curval); tomwalters@0: nrchan=round(nrchan); tomwalters@0: handles.slideredit=... tomwalters@0: slidereditcontrol_set_value(handles.slideredit,nrchan); tomwalters@0: handles=update(handles); tomwalters@0: guidata(hObject, handles); tomwalters@0: function edit3_Callback(hObject, eventdata, handles) tomwalters@0: handles=update(handles); tomwalters@0: guidata(hObject, handles); tomwalters@0: tomwalters@0: function slider1_Callback(hObject, eventdata, handles) tomwalters@0: curval=get(hObject,'Value'); tomwalters@0: % curval=round(curval); tomwalters@0: handles.slideredit=... tomwalters@0: slidereditcontrol_set_rawslidervalue(handles.slideredit,curval); tomwalters@0: handles=update(handles); tomwalters@0: guidata(hObject, handles); tomwalters@0: tomwalters@0: % dynamic feature for the calculation of the sai tomwalters@0: function pushbutton1_Callback(hObject, eventdata, handles) tomwalters@0: tomwalters@0: stepsize=str2num(get(handles.edit3,'String')); tomwalters@0: tomwalters@0: tomwalters@0: options=handles.import_options.all_options.sai; tomwalters@0: % disp('generating and saving sai...'); tomwalters@0: generating_module=handles.import_options.info.current_sai_module; tomwalters@0: handles.import_options.info.calculated_sai_module=generating_module; % this one is really calculated tomwalters@0: generating_functionline=['options.' generating_module '.generatingfunction']; tomwalters@0: eval(sprintf('generating_function=%s;',generating_functionline')); tomwalters@0: nap=handles.import_options.data.nap; tomwalters@0: strobes=handles.import_options.data.strobes; tomwalters@0: optline=sprintf('coptions=%s.%s;','handles.import_options.all_options.sai',generating_module); tomwalters@0: eval(optline); tomwalters@0: coptions.single_channel_do=1; tomwalters@0: coptions.single_channel_channel_nr=slidereditcontrol_get_value(handles.slideredit); tomwalters@0: coptions.single_channel_time_step=stepsize/1000; tomwalters@0: coptions.thresholds=handles.import_options.data.thresholds; tomwalters@0: callline=sprintf('res=%s(nap,strobes,coptions);',generating_function); tomwalters@0: eval(callline); tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: function slider1_CreateFcn(hObject, eventdata, handles) tomwalters@0: usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end tomwalters@0: function edit1_CreateFcn(hObject, eventdata, handles) tomwalters@0: if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end tomwalters@0: function edit2_CreateFcn(hObject, eventdata, handles) tomwalters@0: if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end tomwalters@0: function edit3_CreateFcn(hObject, eventdata, handles) tomwalters@0: if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: function handles=update(handles) tomwalters@0: nr_chan=slidereditcontrol_get_value(handles.slideredit); tomwalters@0: nr_chan=round(nr_chan); tomwalters@0: handles.slideredit=slidereditcontrol_set_value(handles.slideredit,nr_chan); tomwalters@0: cf=handles.cfs(nr_chan); tomwalters@0: set(handles.edit2,'String',num2str(cf)); tomwalters@0: tomwalters@0: options.figure_handle=handles.figure_handle; tomwalters@0: options.withtime=0; tomwalters@0: options.withfre=0; tomwalters@0: options.withsignal=0; tomwalters@0: tomwalters@0: options.display_single_channel=nr_chan; tomwalters@0: switch handles.import_options.info.current_plot tomwalters@0: case {3,4,5} % bmm tomwalters@0: set(handles.edit3,'visible','off'); tomwalters@0: set(handles.text3,'visible','off'); tomwalters@0: set(handles.text5,'visible','off'); tomwalters@0: set(handles.pushbutton1,'visible','off'); tomwalters@0: case 6 %sai tomwalters@0: set(handles.edit3,'visible','on'); tomwalters@0: set(handles.text3,'visible','on'); tomwalters@0: set(handles.text5,'visible','on'); tomwalters@0: set(handles.pushbutton1,'visible','on'); tomwalters@0: end tomwalters@0: aim_replotgraphic(handles.import_options,options); tomwalters@0: tomwalters@0: set(handles.figure1,'Name','select channel'); % repair tomwalters@0: tomwalters@0: return tomwalters@0: