configure_classify.m 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469
  1. function varargout = configure_classify(varargin)
  2. % CONFIGURE_CLASSIFY M-file for configure_classify.fig
  3. % CONFIGURE_CLASSIFY, by itself, creates a new CONFIGURE_CLASSIFY or raises the existing
  4. % singleton*.
  5. %
  6. % H = CONFIGURE_CLASSIFY returns the handle to a new CONFIGURE_CLASSIFY or the handle to
  7. % the existing singleton*.
  8. %
  9. % CONFIGURE_CLASSIFY('CALLBACK',hObject,eventData,handles,...) calls the local
  10. % function named CALLBACK in CONFIGURE_CLASSIFY.M with the given input arguments.
  11. %
  12. % CONFIGURE_CLASSIFY('Property','Value',...) creates a new CONFIGURE_CLASSIFY or raises the
  13. % existing singleton*. Starting from the left, property value pairs are
  14. % applied to the GUI before configure_classify_OpeningFunction gets called. An
  15. % unrecognized property name or invalid value makes property application
  16. % stop. All inputs are passed to configure_classify_OpeningFcn via varargin.
  17. %
  18. % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
  19. % instance to run (singleton)".
  20. %
  21. % See also: GUIDE, GUIDATA, GUIHANDLES
  22. % Copyright 2002-2003 The MathWorks, Inc.
  23. % Edit the above text to modify the response to help configure_classify
  24. % Last Modified by GUIDE v2.5 01-May-2006 23:22:44
  25. % Begin initialization code - DO NOT EDIT
  26. gui_Singleton = 1;
  27. gui_State = struct('gui_Name', mfilename, ...
  28. 'gui_Singleton', gui_Singleton, ...
  29. 'gui_OpeningFcn', @configure_classify_OpeningFcn, ...
  30. 'gui_OutputFcn', @configure_classify_OutputFcn, ...
  31. 'gui_LayoutFcn', [] , ...
  32. 'gui_Callback', []);
  33. if nargin && ischar(varargin{1})
  34. gui_State.gui_Callback = str2func(varargin{1});
  35. end
  36. if nargout
  37. [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
  38. else
  39. gui_mainfcn(gui_State, varargin{:});
  40. end
  41. % End initialization code - DO NOT EDIT
  42. % --- Executes just before configure_classify is made visible.
  43. function configure_classify_OpeningFcn(hObject, eventdata, handles, varargin)
  44. % This function has no output args, see OutputFcn.
  45. % hObject handle to figure
  46. % eventdata reserved - to be defined in a future version of MATLAB
  47. % handles structure with handles and user data (see GUIDATA)
  48. % varargin command line arguments to configure_classify (see VARARGIN)
  49. % Choose default command line output for configure_classify
  50. handles.output = hObject;
  51. % Update handles structure
  52. guidata(hObject, handles);
  53. % UIWAIT makes configure_classify wait for user response (see UIRESUME)
  54. % uiwait(handles.figure1);
  55. % configure_classify(0,7500,400,500,44100,[0.01 0.001],[3 5],[0 20000])
  56. handles.lowerfreq = varargin{1}; % Lower frequency for zooming
  57. handles.upperfreq = varargin{2}; % Upper frequency for zooming
  58. handles.classified_height = varargin{3} ; % the height of the image in the classified axes
  59. handles.classified_width = varargin{4}; % the width of the image in the classified axes
  60. handles.Fs = varargin{5}; % Frequency of audio sampling per second
  61. handles.movingwin = varargin{6}; % Size of the moving window in seconds; the first number is the window size and the second is the step size
  62. handles.tapers = varargin{7}; % Tapers for smoothing
  63. handles.fpass = varargin{8}; % Range of frequency sampling
  64. handles.fixed = varargin{9}; % Fixed scaling of the classified axes
  65. set(handles.ZoomLowerFreq,'String',num2str(handles.lowerfreq));
  66. set(handles.ZoomUpperFreq,'String',num2str(handles.upperfreq));
  67. set(handles.ClassifiedWidth,'String',num2str(handles.classified_width));
  68. set(handles.ClassifiedHeight,'String',num2str(handles.classified_height));
  69. set(handles.Frequency,'String',num2str(handles.Fs));
  70. set(handles.WinSize,'String',num2str(handles.movingwin(1) * 1000));
  71. set(handles.StepSize,'String',num2str(handles.movingwin(2) * 1000));
  72. set(handles.TW,'String',num2str(handles.tapers(1)));
  73. set(handles.MinFreq,'String',num2str(handles.fpass(1)));
  74. set(handles.MaxFreq,'String',num2str(handles.fpass(2)));
  75. set(handles.FixedCheckbox,'Value',handles.fixed);
  76. % set(handles.ZoomLowerFreq,'Enable','off');
  77. % set(handles.ZoomUpperFreq,'Enable','off');
  78. % set(handles.ClassifiedWidth,'Enable','off');
  79. % set(handles.ClassifiedHeight,'Enable','off');
  80. % set(handles.Frequency,'Enable','off');
  81. % set(handles.WinSize,'Enable','off');
  82. % set(handles.StepSize,'Enable','off');
  83. % set(handles.TW,'Enable','off');
  84. % set(handles.MinFreq,'Enable','off');
  85. % set(handles.MaxFreq,'Enable','off');
  86. uiwait(handles.figure1);
  87. % --- Outputs from this function are returned to the command line.
  88. function varargout = configure_classify_OutputFcn(hObject, eventdata, handles)
  89. % varargout cell array for returning output args (see VARARGOUT);
  90. % hObject handle to figure
  91. % eventdata reserved - to be defined in a future version of MATLAB
  92. % handles structure with handles and user data (see GUIDATA)
  93. % Get default command line output from handles structure
  94. varargout{1} = handles.output;
  95. close;
  96. function WinSize_Callback(hObject, eventdata, handles)
  97. % hObject handle to WinSize (see GCBO)
  98. % eventdata reserved - to be defined in a future version of MATLAB
  99. % handles structure with handles and user data (see GUIDATA)
  100. % Hints: get(hObject,'String') returns contents of WinSize as text
  101. % str2double(get(hObject,'String')) returns contents of WinSize as a double
  102. % --- Executes during object creation, after setting all properties.
  103. function WinSize_CreateFcn(hObject, eventdata, handles)
  104. % hObject handle to WinSize (see GCBO)
  105. % eventdata reserved - to be defined in a future version of MATLAB
  106. % handles empty - handles not created until after all CreateFcns called
  107. % Hint: edit controls usually have a white background on Windows.
  108. % See ISPC and COMPUTER.
  109. if ispc
  110. set(hObject,'BackgroundColor','white');
  111. else
  112. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  113. end
  114. % --- Executes on button press in OKButton.
  115. function OKButton_Callback(hObject, eventdata, handles)
  116. % hObject handle to OKButton (see GCBO)
  117. % eventdata reserved - to be defined in a future version of MATLAB
  118. % handles structure with handles and user data (see GUIDATA)
  119. lowerfreq = str2num(get(handles.ZoomLowerFreq,'String')); % Lower frequency for zooming
  120. upperfreq = str2num(get(handles.ZoomUpperFreq,'String')); % Upper frequency for zooming
  121. classified_height = str2num(get(handles.ClassifiedHeight,'String')); % the height of the image in the classified axes
  122. classified_width = str2num(get(handles.ClassifiedWidth,'String')); % the width of the image in the classified axes
  123. Fs = str2num(get(handles.Frequency,'String')); % Frequency of audio sampling per second
  124. winsizeS = str2num(get(handles.WinSize,'String')) / 1000;
  125. stepS = str2num(get(handles.StepSize,'String')) / 1000;
  126. movingwin = [winsizeS stepS]; % Size of the moving window in seconds; the first number is the window size and the second is the step size
  127. tw = str2num(get(handles.TW,'String'));
  128. fpasslower = str2num(get(handles.MinFreq,'String')); % Range of frequency sampling
  129. fpassupper = str2num(get(handles.MaxFreq,'String'));
  130. fpass = [fpasslower fpassupper];
  131. ierror = 1; % Indicates no errors encountered
  132. if isempty(classified_height) || (classified_height < 1)
  133. ierror = 0;
  134. end
  135. if isempty(tw) || tw < 0
  136. ierror = 0;
  137. end
  138. if isempty(lowerfreq) || lowerfreq < 0
  139. ierror = 0;
  140. end
  141. if isempty(fpasslower) || fpasslower < 0
  142. ierror = 0;
  143. end
  144. if isempty(fpassupper) || fpassupper < fpasslower
  145. ierror = 0;
  146. end
  147. if isempty(upperfreq) || lowerfreq > upperfreq
  148. ierror = 0;
  149. end
  150. if isempty(winsizeS) || winsizeS < 0
  151. ierror = 0;
  152. end
  153. if isempty(stepS) || stepS < 0
  154. ierror = 0
  155. end
  156. if isempty(tw) || tw < 0
  157. ierror = 0
  158. else
  159. tapers = [tw,floor(2*tw-1)]; % Tapers for smoothing
  160. end
  161. fixed = get(handles.FixedCheckbox,'Value');
  162. if ierror == 0
  163. ;
  164. else
  165. handles.output = {lowerfreq,upperfreq,classified_height,classified_width,Fs,movingwin,tapers,fpass,fixed};
  166. guidata(hObject,handles);
  167. uiresume(handles.figure1);
  168. end
  169. %uiresume;
  170. %close;
  171. % --- Executes on button press in CancelButton.
  172. function CancelButton_Callback(hObject, eventdata, handles)
  173. % hObject handle to CancelButton (see GCBO)
  174. % eventdata reserved - to be defined in a future version of MATLAB
  175. % handles structure with handles and user data (see GUIDATA)
  176. handles.output = 0;
  177. guidata(hObject,handles);
  178. uiresume(handles.figure1);
  179. function StepSize_Callback(hObject, eventdata, handles)
  180. % hObject handle to StepSize (see GCBO)
  181. % eventdata reserved - to be defined in a future version of MATLAB
  182. % handles structure with handles and user data (see GUIDATA)
  183. % Hints: get(hObject,'String') returns contents of StepSize as text
  184. % str2double(get(hObject,'String')) returns contents of StepSize as a double
  185. % --- Executes during object creation, after setting all properties.
  186. function StepSize_CreateFcn(hObject, eventdata, handles)
  187. % hObject handle to StepSize (see GCBO)
  188. % eventdata reserved - to be defined in a future version of MATLAB
  189. % handles empty - handles not created until after all CreateFcns called
  190. % Hint: edit controls usually have a white background on Windows.
  191. % See ISPC and COMPUTER.
  192. if ispc
  193. set(hObject,'BackgroundColor','white');
  194. else
  195. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  196. end
  197. function TW_Callback(hObject, eventdata, handles)
  198. % hObject handle to TW (see GCBO)
  199. % eventdata reserved - to be defined in a future version of MATLAB
  200. % handles structure with handles and user data (see GUIDATA)
  201. % Hints: get(hObject,'String') returns contents of TW as text
  202. % str2double(get(hObject,'String')) returns contents of TW as a double
  203. % --- Executes during object creation, after setting all properties.
  204. function TW_CreateFcn(hObject, eventdata, handles)
  205. % hObject handle to TW (see GCBO)
  206. % eventdata reserved - to be defined in a future version of MATLAB
  207. % handles empty - handles not created until after all CreateFcns called
  208. % Hint: edit controls usually have a white background on Windows.
  209. % See ISPC and COMPUTER.
  210. if ispc
  211. set(hObject,'BackgroundColor','white');
  212. else
  213. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  214. end
  215. function MinFreq_Callback(hObject, eventdata, handles)
  216. % hObject handle to MinFreq (see GCBO)
  217. % eventdata reserved - to be defined in a future version of MATLAB
  218. % handles structure with handles and user data (see GUIDATA)
  219. % Hints: get(hObject,'String') returns contents of MinFreq as text
  220. % str2double(get(hObject,'String')) returns contents of MinFreq as a double
  221. % --- Executes during object creation, after setting all properties.
  222. function MinFreq_CreateFcn(hObject, eventdata, handles)
  223. % hObject handle to MinFreq (see GCBO)
  224. % eventdata reserved - to be defined in a future version of MATLAB
  225. % handles empty - handles not created until after all CreateFcns called
  226. % Hint: edit controls usually have a white background on Windows.
  227. % See ISPC and COMPUTER.
  228. if ispc
  229. set(hObject,'BackgroundColor','white');
  230. else
  231. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  232. end
  233. function MaxFreq_Callback(hObject, eventdata, handles)
  234. % hObject handle to MaxFreq (see GCBO)
  235. % eventdata reserved - to be defined in a future version of MATLAB
  236. % handles structure with handles and user data (see GUIDATA)
  237. % Hints: get(hObject,'String') returns contents of MaxFreq as text
  238. % str2double(get(hObject,'String')) returns contents of MaxFreq as a double
  239. % --- Executes during object creation, after setting all properties.
  240. function MaxFreq_CreateFcn(hObject, eventdata, handles)
  241. % hObject handle to MaxFreq (see GCBO)
  242. % eventdata reserved - to be defined in a future version of MATLAB
  243. % handles empty - handles not created until after all CreateFcns called
  244. % Hint: edit controls usually have a white background on Windows.
  245. % See ISPC and COMPUTER.
  246. if ispc
  247. set(hObject,'BackgroundColor','white');
  248. else
  249. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  250. end
  251. function ZoomLowerFreq_Callback(hObject, eventdata, handles)
  252. % hObject handle to ZoomLowerFreq (see GCBO)
  253. % eventdata reserved - to be defined in a future version of MATLAB
  254. % handles structure with handles and user data (see GUIDATA)
  255. % Hints: get(hObject,'String') returns contents of ZoomLowerFreq as text
  256. % str2double(get(hObject,'String')) returns contents of ZoomLowerFreq as a double
  257. % --- Executes during object creation, after setting all properties.
  258. function ZoomLowerFreq_CreateFcn(hObject, eventdata, handles)
  259. % hObject handle to ZoomLowerFreq (see GCBO)
  260. % eventdata reserved - to be defined in a future version of MATLAB
  261. % handles empty - handles not created until after all CreateFcns called
  262. % Hint: edit controls usually have a white background on Windows.
  263. % See ISPC and COMPUTER.
  264. if ispc
  265. set(hObject,'BackgroundColor','white');
  266. else
  267. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  268. end
  269. function ZoomUpperFreq_Callback(hObject, eventdata, handles)
  270. % hObject handle to ZoomUpperFreq (see GCBO)
  271. % eventdata reserved - to be defined in a future version of MATLAB
  272. % handles structure with handles and user data (see GUIDATA)
  273. % Hints: get(hObject,'String') returns contents of ZoomUpperFreq as text
  274. % str2double(get(hObject,'String')) returns contents of ZoomUpperFreq as a double
  275. % --- Executes during object creation, after setting all properties.
  276. function ZoomUpperFreq_CreateFcn(hObject, eventdata, handles)
  277. % hObject handle to ZoomUpperFreq (see GCBO)
  278. % eventdata reserved - to be defined in a future version of MATLAB
  279. % handles empty - handles not created until after all CreateFcns called
  280. % Hint: edit controls usually have a white background on Windows.
  281. % See ISPC and COMPUTER.
  282. if ispc
  283. set(hObject,'BackgroundColor','white');
  284. else
  285. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  286. end
  287. function ClassifiedWidth_Callback(hObject, eventdata, handles)
  288. % hObject handle to ClassifiedWidth (see GCBO)
  289. % eventdata reserved - to be defined in a future version of MATLAB
  290. % handles structure with handles and user data (see GUIDATA)
  291. % Hints: get(hObject,'String') returns contents of ClassifiedWidth as text
  292. % str2double(get(hObject,'String')) returns contents of ClassifiedWidth as a double
  293. % --- Executes during object creation, after setting all properties.
  294. function ClassifiedWidth_CreateFcn(hObject, eventdata, handles)
  295. % hObject handle to ClassifiedWidth (see GCBO)
  296. % eventdata reserved - to be defined in a future version of MATLAB
  297. % handles empty - handles not created until after all CreateFcns called
  298. % Hint: edit controls usually have a white background on Windows.
  299. % See ISPC and COMPUTER.
  300. if ispc
  301. set(hObject,'BackgroundColor','white');
  302. else
  303. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  304. end
  305. function ClassifiedHeight_Callback(hObject, eventdata, handles)
  306. % hObject handle to ClassifiedHeight (see GCBO)
  307. % eventdata reserved - to be defined in a future version of MATLAB
  308. % handles structure with handles and user data (see GUIDATA)
  309. % Hints: get(hObject,'String') returns contents of ClassifiedHeight as text
  310. % str2double(get(hObject,'String')) returns contents of ClassifiedHeight as a double
  311. % --- Executes during object creation, after setting all properties.
  312. function ClassifiedHeight_CreateFcn(hObject, eventdata, handles)
  313. % hObject handle to ClassifiedHeight (see GCBO)
  314. % eventdata reserved - to be defined in a future version of MATLAB
  315. % handles empty - handles not created until after all CreateFcns called
  316. % Hint: edit controls usually have a white background on Windows.
  317. % See ISPC and COMPUTER.
  318. if ispc
  319. set(hObject,'BackgroundColor','white');
  320. else
  321. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  322. end
  323. function Frequency_Callback(hObject, eventdata, handles)
  324. % hObject handle to Frequency (see GCBO)
  325. % eventdata reserved - to be defined in a future version of MATLAB
  326. % handles structure with handles and user data (see GUIDATA)
  327. % Hints: get(hObject,'String') returns contents of Frequency as text
  328. % str2double(get(hObject,'String')) returns contents of Frequency as a double
  329. % --- Executes during object creation, after setting all properties.
  330. function Frequency_CreateFcn(hObject, eventdata, handles)
  331. % hObject handle to Frequency (see GCBO)
  332. % eventdata reserved - to be defined in a future version of MATLAB
  333. % handles empty - handles not created until after all CreateFcns called
  334. % Hint: edit controls usually have a white background on Windows.
  335. % See ISPC and COMPUTER.
  336. if ispc
  337. set(hObject,'BackgroundColor','white');
  338. else
  339. set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
  340. end
  341. % --- Executes on button press in FixedCheckbox.
  342. function FixedCheckbox_Callback(hObject, eventdata, handles)
  343. % hObject handle to FixedCheckbox (see GCBO)
  344. % eventdata reserved - to be defined in a future version of MATLAB
  345. % handles structure with handles and user data (see GUIDATA)
  346. % Hint: get(hObject,'Value') returns toggle state of FixedCheckbox
  347. handles.fixed = get(hObject,'Value');
  348. guidata(gcbo,handles);