annotate aim-mat/gui/single_channel_gui.m @ 4:537f939baef0 tip

various bug fixes and changed copyright message
author Stefan Bleeck <bleeck@gmail.com>
date Tue, 16 Aug 2011 14:37:17 +0100
parents 20ada0af3d7d
children
rev   line source
tomwalters@0 1 % procedure for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
tomwalters@0 8 % (c) 2011, University of Southampton
bleeck@3 9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 10 % download of current version is on the soundsoftware site:
bleeck@3 11 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 12 % documentation and everything is on http://www.acousticscale.org
bleeck@3 13
bleeck@3 14
tomwalters@0 15
tomwalters@0 16
tomwalters@0 17 function varargout = W(varargin)
tomwalters@0 18
tomwalters@0 19 % Begin initialization code - DO NOT EDIT
tomwalters@0 20 gui_Singleton = 1;
tomwalters@0 21 gui_State = struct('gui_Name', mfilename, ...
tomwalters@0 22 'gui_Singleton', gui_Singleton, ...
tomwalters@0 23 'gui_OpeningFcn', @single_channel_gui_OpeningFcn, ...
tomwalters@0 24 'gui_OutputFcn', @single_channel_gui_OutputFcn, ...
tomwalters@0 25 'gui_LayoutFcn', [] , ...
tomwalters@0 26 'gui_Callback', []);
tomwalters@0 27 if nargin & isstr(varargin{1})
tomwalters@0 28 gui_State.gui_Callback = str2func(varargin{1});
tomwalters@0 29 end
tomwalters@0 30
tomwalters@0 31 if nargout
tomwalters@0 32 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
tomwalters@0 33 else
tomwalters@0 34 gui_mainfcn(gui_State, varargin{:});
tomwalters@0 35 end
tomwalters@0 36 % End initialization code - DO NOT EDIT
tomwalters@0 37
tomwalters@0 38
tomwalters@0 39 % --- Executes just before single_channel_gui is made visible.
tomwalters@0 40 function single_channel_gui_OpeningFcn(hObject, eventdata, handles, varargin)
tomwalters@0 41
tomwalters@0 42 % Choose default command line output for single_channel_gui
tomwalters@0 43 handles.output = hObject;
tomwalters@0 44
tomwalters@0 45 set(handles.figure1,'Name','select channel');
tomwalters@0 46
tomwalters@0 47 import_options=varargin{1};
tomwalters@0 48 handles.output=-1;
tomwalters@0 49 if isstruct(import_options)
tomwalters@0 50 handles.import_options=import_options;
tomwalters@0 51 else
tomwalters@0 52 if strcmp(import_options,'close');
tomwalters@0 53 close(handles.figure1);
tomwalters@0 54 return
tomwalters@0 55 end
tomwalters@0 56 if strcmp(import_options,'getchannelnumber')
tomwalters@0 57 if ~isfield(handles,'slideredit')
tomwalters@0 58 handles.output=1;
tomwalters@0 59 else
tomwalters@0 60 handles.output=slidereditcontrol_get_value(handles.slideredit);
tomwalters@0 61 end
tomwalters@0 62 guidata(hObject, handles);
tomwalters@0 63 return
tomwalters@0 64 end
tomwalters@0 65 end
tomwalters@0 66
tomwalters@0 67 % if ~isfield(import_options.info.children.single_channel,'windowhandle')
tomwalters@0 68 % fig=figure(import_options.info.children.single_channel.windowhandle);
tomwalters@0 69 % import_options.info.children.single_channel.windowhandle=fig;
tomwalters@0 70 % end
tomwalters@0 71 %
tomwalters@0 72 if ~isfield(handles,'figure_handle') || ~ishandle(handles.figure_handle)
tomwalters@0 73 handles.figure_handle=import_options.info.children.single_channel.windowhandle;
tomwalters@0 74 % set the window next to the graphic window
tomwalters@0 75 set(handles.figure1,'units','pixels');
tomwalters@0 76 set(handles.figure_handle,'units','pixels');
tomwalters@0 77 orgpos=get(handles.figure1,'position');
tomwalters@0 78 winpos=get(handles.figure_handle,'position');
tomwalters@0 79 newpos(1)=winpos(1)+winpos(3);
tomwalters@0 80 newpos(2)=winpos(2);
tomwalters@0 81 movegui(handles.figure1,newpos);
tomwalters@0 82 % newpos(3:4)=orgpos(3:4);
tomwalters@0 83 % set(handles.figure1,'position',orgpos);
tomwalters@0 84 end
tomwalters@0 85
tomwalters@0 86 % this is an indicator for the main function, that it is called from a
tomwalters@0 87 % child
tomwalters@0 88 handles.import_options.info.iscallfromchild=1;
tomwalters@0 89
tomwalters@0 90 data=import_options.data;
tomwalters@0 91 nrchan=getnrchannels(data.bmm);
tomwalters@0 92 if isfield(import_options.info.children.single_channel,'channelnumber')
tomwalters@0 93 curr_chan=import_options.info.children.single_channel.channelnumber;
tomwalters@0 94 else
tomwalters@0 95 curr_chan=round(nrchan/2);
tomwalters@0 96 end
tomwalters@0 97
tomwalters@0 98 % handles.current_channel_nr=middle_chan;
tomwalters@0 99 handles.cfs=getcf(data.bmm);
tomwalters@0 100
tomwalters@0 101 % set up the slider edit control
tomwalters@0 102 handles.slideredit=slidereditcontrol_setup(...
tomwalters@0 103 handles.slider1,... % handle of the slider
tomwalters@0 104 handles.edit1,...% handle of the edit control
tomwalters@0 105 1, ... % min value
tomwalters@0 106 nrchan, ... % max value
tomwalters@0 107 curr_chan, ... % current value
tomwalters@0 108 0, ... % islog
tomwalters@0 109 1, ...% multiplier on the edit control
tomwalters@0 110 0); % nr digits in the edit control after comma
tomwalters@0 111
tomwalters@0 112 handles.slideredit=slidereditcontrol_set_range(handles.slideredit,10); % makes a stepsize of 1
tomwalters@0 113
tomwalters@0 114 set(handles.edit3,'String',1);
tomwalters@0 115
tomwalters@0 116 % plot the result
tomwalters@0 117 handles=update(handles);
tomwalters@0 118
tomwalters@0 119 % Update handles structure
tomwalters@0 120 guidata(hObject, handles);
tomwalters@0 121
tomwalters@0 122 % UIWAIT makes single_channel_gui wait for user response (see UIRESUME)
tomwalters@0 123 % uiwait(handles.figure1);
tomwalters@0 124
tomwalters@0 125
tomwalters@0 126 % --- Outputs from this function are returned to the command line.
tomwalters@0 127 function varargout = single_channel_gui_OutputFcn(hObject, eventdata, handles)
tomwalters@0 128
tomwalters@0 129 % Get default command line output from handles structure
tomwalters@0 130 if isstruct(handles)
tomwalters@0 131 varargout{1} = handles.output;
tomwalters@0 132 end
tomwalters@0 133
tomwalters@0 134
tomwalters@0 135 function edit1_Callback(hObject, eventdata, handles)
tomwalters@0 136 curval=get(hObject,'String');
tomwalters@0 137 curval=str2num(curval);
tomwalters@0 138 handles.slideredit=...
tomwalters@0 139 slidereditcontrol_set_raweditvalue(handles.slideredit,curval);
tomwalters@0 140 handles=update(handles);
tomwalters@0 141 guidata(hObject, handles);
tomwalters@0 142 function edit2_Callback(hObject, eventdata, handles)
tomwalters@0 143 curval=get(hObject,'String');
tomwalters@0 144 curval=str2num(curval);
tomwalters@0 145 nrchan=fre2chan(handles.import_options.data.bmm,curval);
tomwalters@0 146 nrchan=round(nrchan);
tomwalters@0 147 handles.slideredit=...
tomwalters@0 148 slidereditcontrol_set_value(handles.slideredit,nrchan);
tomwalters@0 149 handles=update(handles);
tomwalters@0 150 guidata(hObject, handles);
tomwalters@0 151 function edit3_Callback(hObject, eventdata, handles)
tomwalters@0 152 handles=update(handles);
tomwalters@0 153 guidata(hObject, handles);
tomwalters@0 154
tomwalters@0 155 function slider1_Callback(hObject, eventdata, handles)
tomwalters@0 156 curval=get(hObject,'Value');
tomwalters@0 157 % curval=round(curval);
tomwalters@0 158 handles.slideredit=...
tomwalters@0 159 slidereditcontrol_set_rawslidervalue(handles.slideredit,curval);
tomwalters@0 160 handles=update(handles);
tomwalters@0 161 guidata(hObject, handles);
tomwalters@0 162
tomwalters@0 163 % dynamic feature for the calculation of the sai
tomwalters@0 164 function pushbutton1_Callback(hObject, eventdata, handles)
tomwalters@0 165
tomwalters@0 166 stepsize=str2num(get(handles.edit3,'String'));
tomwalters@0 167
tomwalters@0 168
tomwalters@0 169 options=handles.import_options.all_options.sai;
tomwalters@0 170 % disp('generating and saving sai...');
tomwalters@0 171 generating_module=handles.import_options.info.current_sai_module;
tomwalters@0 172 handles.import_options.info.calculated_sai_module=generating_module; % this one is really calculated
tomwalters@0 173 generating_functionline=['options.' generating_module '.generatingfunction'];
tomwalters@0 174 eval(sprintf('generating_function=%s;',generating_functionline'));
tomwalters@0 175 nap=handles.import_options.data.nap;
tomwalters@0 176 strobes=handles.import_options.data.strobes;
tomwalters@0 177 optline=sprintf('coptions=%s.%s;','handles.import_options.all_options.sai',generating_module);
tomwalters@0 178 eval(optline);
tomwalters@0 179 coptions.single_channel_do=1;
tomwalters@0 180 coptions.single_channel_channel_nr=slidereditcontrol_get_value(handles.slideredit);
tomwalters@0 181 coptions.single_channel_time_step=stepsize/1000;
tomwalters@0 182 coptions.thresholds=handles.import_options.data.thresholds;
tomwalters@0 183 callline=sprintf('res=%s(nap,strobes,coptions);',generating_function);
tomwalters@0 184 eval(callline);
tomwalters@0 185
tomwalters@0 186
tomwalters@0 187
tomwalters@0 188
tomwalters@0 189 function slider1_CreateFcn(hObject, eventdata, handles)
tomwalters@0 190 usewhitebg = 1;if usewhitebg set(hObject,'BackgroundColor',[.9 .9 .9]);else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
tomwalters@0 191 function edit1_CreateFcn(hObject, eventdata, handles)
tomwalters@0 192 if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
tomwalters@0 193 function edit2_CreateFcn(hObject, eventdata, handles)
tomwalters@0 194 if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
tomwalters@0 195 function edit3_CreateFcn(hObject, eventdata, handles)
tomwalters@0 196 if ispc set(hObject,'BackgroundColor','white');else set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));end
tomwalters@0 197
tomwalters@0 198
tomwalters@0 199
tomwalters@0 200 function handles=update(handles)
tomwalters@0 201 nr_chan=slidereditcontrol_get_value(handles.slideredit);
tomwalters@0 202 nr_chan=round(nr_chan);
tomwalters@0 203 handles.slideredit=slidereditcontrol_set_value(handles.slideredit,nr_chan);
tomwalters@0 204 cf=handles.cfs(nr_chan);
tomwalters@0 205 set(handles.edit2,'String',num2str(cf));
tomwalters@0 206
tomwalters@0 207 options.figure_handle=handles.figure_handle;
tomwalters@0 208 options.withtime=0;
tomwalters@0 209 options.withfre=0;
tomwalters@0 210 options.withsignal=0;
tomwalters@0 211
tomwalters@0 212 options.display_single_channel=nr_chan;
tomwalters@0 213 switch handles.import_options.info.current_plot
tomwalters@0 214 case {3,4,5} % bmm
tomwalters@0 215 set(handles.edit3,'visible','off');
tomwalters@0 216 set(handles.text3,'visible','off');
tomwalters@0 217 set(handles.text5,'visible','off');
tomwalters@0 218 set(handles.pushbutton1,'visible','off');
tomwalters@0 219 case 6 %sai
tomwalters@0 220 set(handles.edit3,'visible','on');
tomwalters@0 221 set(handles.text3,'visible','on');
tomwalters@0 222 set(handles.text5,'visible','on');
tomwalters@0 223 set(handles.pushbutton1,'visible','on');
tomwalters@0 224 end
tomwalters@0 225 aim_replotgraphic(handles.import_options,options);
tomwalters@0 226
tomwalters@0 227 set(handles.figure1,'Name','select channel'); % repair
tomwalters@0 228
tomwalters@0 229 return
tomwalters@0 230