0001 function varargout = wave_browser(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 gui_Singleton = 1;
0031 gui_State = struct('gui_Name', mfilename, ...
0032 'gui_Singleton', gui_Singleton, ...
0033 'gui_OpeningFcn', @wave_browser_OpeningFcn, ...
0034 'gui_OutputFcn', @wave_browser_OutputFcn, ...
0035 'gui_LayoutFcn', [] , ...
0036 'gui_Callback', []);
0037 if nargin && ischar(varargin{1})
0038 gui_State.gui_Callback = str2func(varargin{1});
0039 end
0040
0041 if nargout
0042 [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
0043 else
0044 gui_mainfcn(gui_State, varargin{:});
0045 end
0046
0047
0048
0049
0050 function wave_browser_OpeningFcn(hObject, eventdata, handles, varargin)
0051
0052
0053
0054
0055
0056
0057 handles.firsttime = 0;
0058 handles.precomputed_spec = 0;
0059 handles.longfile = 0;
0060 handles.maxwavsize = 10 * 44100;
0061 handles.maxspec_t = 30;
0062
0063 handles.Fs = 44100;
0064
0065 handles.segments = [];
0066 handles.allsegments = [];
0067 handles.loadedsegment = 0;
0068
0069 handles.lastmarkerstart = 1;
0070
0071 handles.segmentmode = 0;
0072 handles.dontcutsegments = 0;
0073
0074 handles.automethod = 'threshold';
0075
0076 handles.indexthresh = 10;
0077 handles.lower_range = [10 10000];
0078 handles.upper_range = [15000 20000];
0079
0080 handles.nsmooth = 0;
0081
0082 positionP = get(handles.OptionsUiPanel,'Position');
0083 positionF = get(gcf,'Position');
0084
0085 positionF(3) = positionF(3) - positionP(3);
0086
0087
0088
0089
0090 handles.output = hObject;
0091
0092
0093
0094 guidata(hObject, handles);
0095
0096
0097
0098
0099
0100
0101 function varargout = wave_browser_OutputFcn(hObject, eventdata, handles)
0102
0103
0104 varargout{1} = handles.output;
0105
0106 function Frequency_Callback(hObject, eventdata, handles)
0107 handles.Fs = eval(get(hObject,'String'));
0108 guidata(gcbo,handles);
0109
0110 function Frequency_CreateFcn(hObject, eventdata, handles)
0111 set(hObject,'String', '44100');
0112 handles.Fs = 44100;
0113 guidata(gcbo,handles);
0114 if ispc
0115 set(hObject,'BackgroundColor','white');
0116 else
0117 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0118 end
0119
0120
0121 function LoadFile_Callback(hObject, eventdata, handles)
0122
0123 [fname pname]=uigetfile({'*.wav';'*.*'},'Load Time Series');
0124
0125 if fname == 0
0126 return
0127 end
0128
0129
0130
0131 set(handles.FileNameString, 'String',fname);
0132 handles.filename = [pname fname];
0133 [path] = cell2mat(regexp( handles.filename, '^.*\', 'match' ));
0134 [extension] = cell2mat(regexp( handles.filename, '\w+$', 'match' ));
0135 set(handles.Path,'String',path);
0136
0137
0138 handles.segments = [];
0139 handles.allsegments = [];
0140
0141 handles = loadfile(hObject, eventdata, handles);
0142 guidata(hObject,handles);
0143
0144 function [wavesize channels] = wavsizeget(filename);
0145
0146 wavesize = 0;
0147 [filestatus info] = wavfinfo(filename);
0148 info = regexp(info,'[0-9]+','match');
0149 channels = str2num(info{2});
0150 wavesize = str2num(info{1});
0151
0152 function handles = loadfile(hObject, eventdata, handles, varargin)
0153
0154
0155
0156
0157
0158
0159 [datasize channels] = wavsizeget(handles.filename);
0160 handles.wavsize = datasize;
0161
0162 try
0163 handles.maxwavsize = round(handles.Fs * str2num(get(handles.MaximumWavSize,'String')));
0164 catch
0165 handles.maxwavsize = 20;
0166 set(handles.MaximumWavSize,'String',num2str(handles.maxwavsize));
0167 handles.maxwavsize = handles.maxwavsize * handles.Fs;
0168 end
0169
0170 if isempty(varargin)
0171 handles.markerstart = 1;
0172 if datasize > handles.maxwavsize
0173 handles.markerend = handles.maxwavsize;
0174 handles.longfile = 1;
0175 else
0176 handles.markerend = datasize;
0177 end
0178 else
0179 handles.markervec = varargin{1};
0180 handles.markerstart = handles.markervec(1);
0181 handles.markerend = handles.markervec(2);
0182 end
0183
0184 if handles.markerstart <= 1
0185 handles.markerstart = 1;
0186 set(handles.PreviousChunk,'Enable','off');
0187 else
0188 set(handles.PreviousChunk,'Enable','on');
0189 end
0190
0191 if handles.markerend >= handles.wavsize
0192 handles.markerend = handles.wavsize;
0193 set(handles.NextChunk,'Enable','off');
0194 else
0195 set(handles.NextChunk,'Enable','on');
0196 end
0197
0198
0199 if handles.maxwavsize < handles.wavsize
0200 total_chunk = ceil(handles.wavsize / handles.maxwavsize);
0201 i = 1;
0202 while (i < total_chunk) && (handles.markerend >= (handles.maxwavsize * i))
0203 i = i + 1;
0204 end
0205
0206 current_chunk = i-1;
0207
0208 if handles.markerend == handles.wavsize
0209 current_chunk = total_chunk;
0210 end
0211
0212 set(handles.ChunkText,'String',['Chunk ' num2str(current_chunk) '/' num2str(total_chunk)]);
0213 end
0214
0215 try
0216 handles.maxseglength = round(handles.Fs * str2num(get(handles.MaxSegLength,'String')));
0217 catch
0218 handles.maxseglength = handles.Fs * 1;
0219 end
0220
0221 set(handles.RealDuration,'String',num2str(handles.wavsize/handles.Fs,'%.1f'));
0222
0223 if handles.segmentmode
0224 if (handles.markerstart - handles.lastmarkerstart > 0)
0225 if handles.dontcutsegments
0226 if not(isempty(handles.segments))
0227 maxsegend = handles.segments(1).end;
0228 for i = 2:length(handles.segments)
0229 if handles.segments(i).end > maxsegend
0230 maxsegend = handles.segments(i).end;
0231 end
0232 end
0233
0234 maxsegend = round(maxsegend * handles.Fs);
0235
0236 if (handles.lastmarkerend - maxsegend) < (handles.lastmarkerend - handles.maxseglength)
0237 handles.markerstart = (handles.lastmarkerstart + maxsegend) + 1;
0238 else
0239 handles.markerstart = handles.lastmarkerend - handles.maxseglength;
0240 end
0241 else
0242 handles.markerstart = handles.lastmarkerend - handles.maxseglength;
0243 end
0244
0245 handles.markerend = handles.markerstart + handles.maxwavsize - 1;
0246 if handles.markerend > handles.wavsize
0247 handles.markerend = handles.wavsize;
0248 end
0249 end
0250 end
0251 end
0252
0253 hw=waitbar(0,'Loading ...'); waitbar(0.5,hw); drawnow;
0254
0255 [handles.markerstart handles.markerend]/handles.Fs
0256 [handles.ts,handles.Fs] = wavread(handles.filename, [handles.markerstart handles.markerend]);
0257 channel = str2double(get(handles.channel,'String'));
0258 handles.ts = handles.ts(:,channel);
0259
0260 count = length(handles.ts);
0261 handles.ts = handles.ts/std(handles.ts);
0262 set(handles.Frequency,'String', num2str(handles.Fs));
0263 set( handles.Duration, 'String', count/handles.Fs );
0264 Tim=eval(get(handles.DisplayWindow,'String'));
0265 display_frac = 1;
0266
0267 set( handles.slider1, 'Value', 0 );
0268 set( handles.SegmentButton, 'Enable', 'on' );
0269
0270 if handles.longfile
0271 set(handles.SeekButton,'Enable', 'on');
0272 end
0273
0274 set(handles.LoadNext, 'Enable', 'on' );
0275 set(handles.PlayAll, 'Enable', 'on' );
0276 set(handles.PlayWindow, 'Enable', 'on' );
0277 set(handles.Plot, 'Enable', 'on' );
0278 set(handles.PlotAllButton, 'Enable', 'on');
0279 set(handles.Precompute, 'Enable','on');
0280 set(handles.Jump,'Enable','on');
0281 set(handles.JumpBack,'Enable','on');
0282
0283 handles.segments = [];
0284 handles.segments = filtersegments(handles,handles.allsegments);
0285
0286 set(handles.Precompute,'Value',1);
0287
0288 Precompute_Callback(handles.Precompute, eventdata, handles);
0289 handles = guidata(gcbo);
0290
0291
0292
0293 handles.precomputed_spec = 1;
0294 handles.dontcutsegments = 1;
0295 handles.lastmarkerstart = handles.markerstart;
0296 handles.lastmarkerend = handles.markerend;
0297
0298 close(hw);
0299
0300
0301
0302
0303
0304
0305 function endian_Callback(hObject, eventdata, handles)
0306
0307
0308 function endian_CreateFcn(hObject, eventdata, handles)
0309 if ispc
0310 set(hObject,'BackgroundColor','white');
0311 else
0312 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0313 end
0314
0315
0316 function edit2_Callback(hObject, eventdata, handles)
0317 function edit2_CreateFcn(hObject, eventdata, handles)
0318 if ispc
0319 set(hObject,'BackgroundColor','white');
0320 else
0321 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0322 end
0323
0324 function FileNameString_Callback(hObject, eventdata, handles)
0325
0326 function FileNameString_CreateFcn(hObject, eventdata, handles)
0327 if ispc
0328 set(hObject,'BackgroundColor','white');
0329 else
0330 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0331 end
0332
0333 function WinSize_Callback(hObject, eventdata, handles)
0334
0335 function WinSize_CreateFcn(hObject, eventdata, handles)
0336 if ispc
0337 set(hObject,'BackgroundColor','white');
0338 else
0339 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0340 end
0341
0342
0343
0344 function slider1_Callback(hObject, eventdata, handles)
0345
0346 function slider1_CreateFcn(hObject, eventdata, handles)
0347 usewhitebg = 1;
0348 if usewhitebg
0349 set(hObject,'BackgroundColor',[.9 .9 .9]);
0350 else
0351 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0352 end
0353
0354 function StepSize_Callback(hObject, eventdata, handles)
0355
0356 function StepSize_CreateFcn(hObject, eventdata, handles)
0357 if ispc
0358 set(hObject,'BackgroundColor','white');
0359 else
0360 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0361 end
0362
0363 function TW_Callback(hObject, eventdata, handles)
0364
0365 function TW_CreateFcn(hObject, eventdata, handles)
0366 if ispc
0367 set(hObject,'BackgroundColor','white');
0368 else
0369 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0370 end
0371
0372 function DisplayWindow_Callback(hObject, eventdata, handles)
0373
0374 function DisplayWindow_CreateFcn(hObject, eventdata, handles)
0375 set(hObject, 'String', '4');
0376 if ispc
0377 set(hObject,'BackgroundColor','white');
0378 else
0379 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0380 end
0381
0382
0383
0384
0385
0386 function indexinS = getindexpre_c(t,timestart,timeend)
0387
0388 tlen = length(t);
0389
0390 i=1;
0391
0392 while (i <= tlen) && (t(i) < timestart)
0393 i = i + 1;
0394 end
0395
0396 firstindex = i;
0397
0398 while (i <= tlen) && (t(i) < timeend)
0399 i = i + 1;
0400 end
0401
0402 secondindex = i;
0403
0404 indexinS = [firstindex secondindex];
0405
0406 function Plot_Callback(hObject, eventdata, handles)
0407
0408 hw=waitbar(0.5,'Spectrogram calculation');drawnow
0409
0410 params.Fs=handles.Fs;
0411
0412 window=eval(get(handles.WinSize,'String'));
0413 winstep=eval(get(handles.StepSize,'String'));
0414 movingwin=[window winstep]*0.001;
0415
0416 fmin=eval(get(handles.MinFreq,'String'));
0417 fmax=eval(get(handles.MaxFreq,'String'));
0418 params.fpass=[fmin fmax];
0419
0420 p=eval(get(handles.TW,'String'));
0421 params.tapers=[p floor(2*p-1)];
0422
0423 params.pad=1;
0424
0425 Tslider=get(handles.slider1,'Value');
0426 Tim=eval(get(handles.DisplayWindow,'String'));
0427 NT=min(round(Tim*handles.Fs),length(handles.ts));
0428 handles.Tmin=1+floor(Tslider*length(handles.ts));
0429 handles.Tmax=min(handles.Tmin+NT,length(handles.ts));
0430
0431 if handles.Tmax < length(handles.ts)
0432 set( handles.Jump, 'Enable', 'on' );
0433 else
0434 set( handles.Jump, 'Enable', 'off' );
0435 end
0436 if handles.Tmin > 1
0437 set( handles.JumpBack, 'Enable', 'on' );
0438 else
0439 set( handles.JumpBack, 'Enable', 'off' );
0440 end
0441
0442 data=handles.ts(handles.Tmin:handles.Tmax);data=data(:);
0443
0444 handles.upper_range = eval(get(handles.RatioLower,'String'));
0445 handles.lower_range = eval(get(handles.RatioUpper,'String'));
0446 handles.indexthresh = eval(get(handles.RatioThresh,'String'));
0447 handles.nsmooth = eval(get(handles.SmoothFactor,'String'));
0448
0449
0450
0451 contents=get(handles.SpectrumType,'String');
0452 stype=contents{get(handles.SpectrumType,'Value')};
0453
0454 axes(handles.axesW); plot(((handles.markerstart - 1)/handles.Fs) + [handles.Tmin:handles.Tmax]/handles.Fs,handles.ts(handles.Tmin:handles.Tmax)); axis tight;
0455
0456 switch stype
0457 case 'Original'
0458
0459 if not(handles.precomputed_spec) || handles.firsttime
0460 [S,t,f]=mtspecgramc(diff(data),movingwin,params);
0461 timeax=(handles.Tmin/handles.Fs)+t;
0462 else
0463 indexinS = getindexpre_c(handles.t,(handles.Tmin-1)/handles.Fs,(handles.Tmax-1)/handles.Fs);
0464
0465
0466 if indexinS(1) < 1
0467 indexinS(1) = 1;
0468 end
0469
0470 SLen = length(handles.S(:,1));
0471
0472 if indexinS(2) > SLen
0473 indexinS(2) = SLen;
0474 end
0475
0476 f = handles.f;
0477 t = handles.t(indexinS(1):indexinS(2));
0478 S = handles.S(indexinS(1):indexinS(2),:);
0479
0480 timeax=t;
0481 end
0482
0483 cmap='default';
0484
0485 th=eval(get(handles.AmpThresh,'String'));
0486
0487
0488 if strcmp(handles.automethod,'threshold')
0489 [Stot boxcurve] = compute_threshold_free(S,th,handles.nsmooth);
0490 axes(handles.axesP);
0491 semilogy(timeax,Stot);
0492 axis tight;
0493 elseif strcmp(handles.automethod,'ratiof')
0494 [ratiof boxcurve] = compute_index(S,handles.lower_range,handles.upper_range,fmin,fmax,handles.indexthresh,handles.nsmooth);
0495 axes(handles.axesP);
0496 semilogy(timeax,ratiof);
0497 axis tight;
0498 end
0499
0500
0501 hold on; semilogy(timeax,boxcurve,'r'); hold off;
0502 axes(handles.axesS);
0503 imagesc(timeax,f,log(S)'); axis xy; colormap(cmap);
0504
0505
0506
0507
0508 case 'Time Derivative'
0509
0510 if not(handles.precomputed_spec) || handles.firsttime
0511 [S,t,f]=mtdspecgramc(diff(data),movingwin,0,params);S = S';
0512 timeax=handles.Tmin/handles.Fs+t;
0513 else
0514 indexinS = getindexpre_c(handles.t,(handles.Tmin-1)/handles.Fs,(handles.Tmax-1)/handles.Fs);
0515
0516
0517 if indexinS(1) < 1
0518 indexinS(1) = 1;
0519 end
0520
0521 SLen = length(handles.S(1,:));
0522
0523 if indexinS(2) > SLen
0524 indexinS(2) = SLen;
0525 end
0526
0527 f = handles.f;
0528 t = handles.t(indexinS(1):indexinS(2));
0529 S = handles.S(:,indexinS(1):indexinS(2));
0530 timeax = t;
0531 end
0532
0533 cmap='gray';
0534 th=eval(get(handles.TDerThresh,'String'));
0535
0536 if strcmp(handles.automethod,'threshold')
0537 [Stot boxcurve] = compute_threshold_free(abs(S'),th.handles.nsmooth);
0538 axes(handles.axesP);
0539 semilogy(timeax,Stot);
0540 axis tight;
0541 elseif strcmp(handles.automethod,'ratiof')
0542 [ratiof boxcurve] = compute_index(abs(S)',handles.lower_range,handles.upper_range,fmin,fmax,handles.indexthresh,handles.nsmooth);
0543 axes(handles.axesP);
0544 semilogy(timeax,ratiof);
0545 axis tight;
0546 end
0547
0548 hold on; semilogy(timeax,boxcurve,'r'); hold off;
0549 axes(handles.axesS);
0550 imagesc(timeax,f,S); axis xy; colormap(cmap);
0551 cmin=0.02*min(min(S)); cmax=0.02*max(max(S)); caxis([cmin cmax]);
0552
0553 case 'Frequency Derivative'
0554
0555 if not(handles.precomputed_spec) || handles.firsttime
0556 [S,t,f]=mtdspecgramc(diff(data),movingwin,pi/2,params);S=S';
0557 timeax=handles.Tmin/handles.Fs+t;
0558 else
0559 indexinS = getindexpre_c(handles.t,(handles.Tmin-1)/handles.Fs,(handles.Tmax-1)/handles.Fs);
0560
0561 if indexinS(1) < 1
0562 indexinS(1) = 1;
0563 end
0564
0565 SLen = length(handles.S(1,:));
0566
0567 if indexinS(2) > SLen
0568 indexinS(2) = SLen;
0569 end
0570
0571 f = handles.f;
0572 t = handles.t(indexinS(1):indexinS(2));
0573 S = handles.S(:,indexinS(1):indexinS(2));
0574 timeax = t;
0575 end
0576
0577 cmap='gray';
0578 th=eval(get(handles.TDerThresh,'String'));
0579
0580 if strcmp(handles.automethod,'threshold')
0581 [Stot boxcurve] = compute_threshold_free(abs(S'),th,handles.nsmooth);
0582 axes(handles.axesP);
0583 semilogy(timeax,Stot);
0584 axis tight;
0585 elseif strcmp(handles.automethod,'ratiof')
0586 [ratiof boxcurve] = compute_index(abs(S)',handles.lower_range,handles.upper_range,fmin,fmax,handles.indexthresh,handles.nsmooth);
0587 axes(handles.axesP);
0588 semilogy(timeax,ratiof);
0589 axis tight;
0590 end
0591
0592 hold on; semilogy(timeax,boxcurve,'r'); hold off;
0593 axes(handles.axesS);
0594 imagesc(timeax,f,S); axis xy; colormap(cmap);
0595 cmin=0.02*min(min(S)); cmax=0.02*max(max(S)); caxis([cmin cmax]);
0596
0597 end;
0598
0599 if handles.firsttime
0600 handles.S = S;
0601 handles.t = t;
0602 handles.f = f;
0603 handles.precomputed_spec = 1;
0604 handles.firstime = 0;
0605 end
0606
0607
0608
0609
0610
0611
0612
0613
0614
0615 handles.times=timeax(:);
0616 handles.transition=[diff(boxcurve(:)); 0];
0617
0618 set( handles.axesS, 'XTick', [] );
0619 set( handles.axesP, 'XTick', [] );
0620
0621 if exist('handles.datacursor')
0622 delete( handles.datacursor );
0623 delete( handles.segmentLineP );
0624 delete( handles.segmentLineS );
0625 delete( handles.segmentLineW );
0626 end
0627
0628 handles.datacursor=datacursormode(handles.figure1);
0629 axes(handles.axesP);
0630 handles.segmentLineP = line('Visible','off');
0631 axes(handles.axesS);
0632 handles.segmentLineS = line('Visible','off');
0633 axes(handles.axesW);
0634 handles.segmentLineW = line('Visible','off');
0635
0636 if get( handles.SegmentButton, 'Value' )
0637 set(handles.datacursor,'Enable','on','DisplayStyle','datatip','SnapToDataVertex','off','UpdateFcn',@datacursorfunc);
0638 end
0639
0640 guidata(gcbo,handles);
0641 close(hw);
0642 handles = draw_segments(handles);
0643
0644 function [Stot boxcurve] = compute_threshold_free(S,th,n)
0645
0646
0647 Stot=sum(S,2);
0648 boxcurve=Stot;
0649 smax=max(Stot);
0650
0651 Stot = smooth_curve(Stot',n);
0652
0653 boxcurve(find(Stot<th*smax))= smax*th;
0654 boxcurve(find(Stot>th*smax))= smax;
0655
0656 function [ratiof boxcurve] = compute_index(S,lower_range,upper_range,lowerfreq,upperfreq,indexthresh,n)
0657
0658
0659
0660 S = S';
0661 nfreqs = length(S(:,1));
0662 freqspern = (upperfreq - lowerfreq) / nfreqs;
0663
0664 indexinlower = fliplr(nfreqs - round((lower_range - lowerfreq)/freqspern));
0665 indexinupper = fliplr(nfreqs - round((upper_range - lowerfreq)/freqspern)) + 1;
0666
0667 nrangelower = indexinlower(2)-indexinlower(1);
0668 nrangeupper = indexinupper(2)-indexinupper(1);
0669
0670 ratiof = ( sum(S(indexinupper(1) : indexinupper(2),:)) / nrangeupper )...
0671 ./ ( sum(S( indexinlower(1) : indexinlower(2),:)) / nrangelower );
0672
0673
0674 ratiof = smooth_curve(ratiof,n);
0675
0676 maxrf = max(ratiof);
0677
0678 boxcurve = ratiof;
0679
0680 boxcurve(find(ratiof<indexthresh))= indexthresh;
0681 boxcurve(find(ratiof>=indexthresh))= maxrf;
0682
0683 function smoothedcurve = smooth_curve(curve2smooth,n);
0684
0685
0686
0687 m = length(curve2smooth);
0688 if m > 0
0689 curve2smooth = [repmat(curve2smooth(1),1,n) curve2smooth repmat(curve2smooth(m),1,n)];
0690 smoothedcurve = zeros(m,1);
0691
0692 for i = 1:m
0693 smoothedcurve(i) = sum(curve2smooth(i:i + 2 * n)) / (2 * n + 1);
0694 end
0695 else
0696 smoothed_curve = curve2smooth;
0697 end
0698
0699 function MinFreq_Callback(hObject, eventdata, handles)
0700
0701 function MinFreq_CreateFcn(hObject, eventdata, handles)
0702 if ispc
0703 set(hObject,'BackgroundColor','white');
0704 else
0705 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0706 end
0707
0708 function MaxFreq_Callback(hObject, eventdata, handles)
0709 function MaxFreq_CreateFcn(hObject, eventdata, handles)
0710 if ispc
0711 set(hObject,'BackgroundColor','white');
0712 else
0713 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0714 end
0715
0716
0717 function SpectrumType_Callback(hObject, eventdata, handles)
0718 function SpectrumType_CreateFcn(hObject, eventdata, handles)
0719 if ispc
0720 set(hObject,'BackgroundColor','white');
0721 else
0722 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0723 end
0724
0725 function AmpThresh_Callback(hObject, eventdata, handles)
0726 function AmpThresh_CreateFcn(hObject, eventdata, handles)
0727 if ispc
0728 set(hObject,'BackgroundColor','white');
0729 else
0730 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0731 end
0732
0733 function TDerThresh_Callback(hObject, eventdata, handles)
0734
0735
0736 function TDerThresh_CreateFcn(hObject, eventdata, handles)
0737 if ispc
0738 set(hObject,'BackgroundColor','white');
0739 else
0740 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
0741 end
0742
0743
0744 function PlayAll_Callback(hObject, eventdata, handles)
0745 wavplay(handles.ts,handles.Fs);
0746
0747
0748
0749 function PlayWindow_Callback(hObject, eventdata, handles)
0750 wavplay(handles.ts(handles.Tmin:handles.Tmax),handles.Fs,'async');
0751
0752
0753
0754 function txt = datacursorfunc(empt,event_obj)
0755 pos = get(event_obj,'Position');
0756 handles=guidata(get(event_obj,'Target'));
0757
0758 set(handles.segmentLineP,'Xdata',[pos(1) pos(1)],'Ydata',[0.00000000000001*pos(2) 1000000000000*pos(2)],'Visible','on' );
0759 set(handles.segmentLineS,'Xdata',[pos(1) pos(1)],'Ydata',[0.00000000000001*pos(2) 1000000000000*pos(2)],'Visible','on' );
0760 set(handles.segmentLineW,'Xdata',[pos(1) pos(1)],'Ydata',[-100000000000*pos(2) 1000000000000*pos(2)],'Visible','on' );
0761
0762 if handles.start_stop_enable == 1
0763 set( handles.SegStartButton, 'Enable', 'on' );
0764 else
0765 set( handles.SegEndButton, 'Enable', 'on' );
0766 end
0767
0768 txt = {[num2str(pos(1))]};
0769 guidata(gcbo,handles);
0770
0771 function handles = draw_segments( handles )
0772 n = 1;
0773 while n <= length( handles.segments )
0774 handles.segments(n).lines=[];
0775 handles.segments(n) = draw_all_x( handles, handles.segments(n) );
0776 n = n + 1;
0777 end
0778 guidata(gcbo,handles);
0779
0780
0781 function SegmentButton_Callback(hObject, eventdata, handles)
0782 toggled = get( handles.SegmentButton, 'Value' );
0783
0784 if toggled
0785 handles.segments = [];
0786 handles.segmentmode = 1;
0787 set( handles.SegmentButton, 'String', 'Segment On' );
0788 set( handles.SegmentButton, 'Enable', 'off' );
0789 if not(exist([handles.filename '.seg.txt']));
0790 set( handles.LoadSegments, 'Enable', 'off' );
0791 else
0792 set( handles.LoadSegments, 'Enable', 'on' );
0793 end
0794 set( handles.AutoSegmentFile, 'Enable','on');
0795 set( handles.AutoSegButton, 'Enable', 'on' );
0796 set( handles.SegmentLengthEdit, 'Enable', 'on' );
0797 set( handles.SegmentLengthText, 'Enable', 'on ' );
0798 set( handles.SaveSegments, 'Enable', 'on' );
0799 set( handles.DeleteSegment, 'Enable', 'on' );
0800 set( handles.DeleteAllButton, 'Enable', 'on' );
0801 set( handles.SegCancel, 'Enable', 'on' );
0802 set( handles.PlotSegments, 'Enable', 'on' );
0803 set( handles.LoadFile, 'Enable', 'off' );
0804 set( handles.LoadNext, 'Enable', 'off' );
0805 handles.start_stop_enable = 1;
0806 set(handles.datacursor,'Enable','on','DisplayStyle','datatip','SnapToDataVertex','off','UpdateFcn',@datacursorfunc);
0807 fprintf( 'Segment mode on!\n' );
0808 else
0809 handles.segmentmode = 0;
0810 set( handles.SegmentButton, 'String', 'Segment Off' );
0811 set( handles.AutoSegButton, 'Enable', 'off' );
0812 set( handles.AutoSegmentFile, 'Enable','off');
0813 set( handles.SegmentLengthEdit, 'Enable', 'off' );
0814 set( handles.SegmentLengthText, 'Enable', 'off' );
0815 set( handles.LoadSegments, 'Enable', 'off' );
0816 set( handles.SaveSegments, 'Enable', 'off' );
0817 set( handles.SegStartButton, 'Enable', 'off' );
0818 set( handles.SegEndButton, 'Enable', 'off' );
0819 set( handles.DeleteSegment, 'Enable', 'off' );
0820 set( handles.DeleteAllButton, 'Enable', 'off' );
0821 set( handles.SegCancel, 'Enable', 'off' );
0822 set( handles.PlotSegments, 'Enable', 'off' );
0823 set( handles.LoadFile, 'Enable', 'on' );
0824 set( handles.LoadNext, 'Enable', 'on' );
0825 set(handles.datacursor,'Enable','off')
0826 fprintf( 'Segment mode off!\n' );
0827 end
0828 guidata(gcbo,handles);
0829
0830
0831
0832 function SegStartButton_Callback(hObject, eventdata, handles)
0833 set( handles.LoadSegments, 'Enable', 'off' );
0834 set( handles.SegStartButton, 'Enable', 'off' );
0835 handles.start_stop_enable = 0;
0836 xy=get(handles.segmentLineP,'Xdata');
0837 handles.segment.start=xy(1);
0838 handles.segment.lines=[];
0839 axes(handles.axesP);
0840 set(handles.segmentLineP,'LineWidth',3);
0841 handles.segment.lines(1) = handles.segmentLineP;
0842 handles.segmentLineP = line('Visible','off');
0843 axes(handles.axesS);
0844 set(handles.segmentLineS,'LineWidth',3);
0845 handles.segment.lines(2) = handles.segmentLineS;
0846 handles.segmentLineS = line('Visible','off');
0847 axes(handles.axesW);
0848 set(handles.segmentLineW,'LineWidth',3);
0849 handles.segment.lines(3) = handles.segmentLineW;
0850 handles.segmentLineW = line('Visible','off');
0851
0852 guidata(gcbo,handles);
0853
0854
0855 function SegEndButton_Callback(hObject, eventdata, handles)
0856 set( handles.SegEndButton, 'Enable', 'off' );
0857 handles.start_stop_enable = 1;
0858 xy=get(handles.segmentLineP,'Xdata');
0859 handles.segment.end=xy(1);
0860 handles.segment=draw_all_x( handles, handles.segment );
0861 handles.segments = [handles.segments handles.segment];
0862 guidata(gcbo,handles);
0863
0864 function out=draw_all_x( handles, segment )
0865 segment=draw_x( handles.axesP, segment );
0866 segment=draw_x( handles.axesS, segment );
0867 segment=draw_x( handles.axesW, segment );
0868 out=segment;
0869
0870 function out=draw_x( theaxes, segment )
0871 axes(theaxes);
0872 ylim = get(theaxes,'YLim');
0873 segment.lines = [segment.lines line('Xdata',[segment.start segment.start],'Ydata',ylim,'LineWidth',3)];
0874 segment.lines = [segment.lines line('Xdata',[segment.end segment.end],'Ydata',ylim,'LineWidth',3)];
0875 segment.lines = [segment.lines line('Xdata',[segment.start segment.end],'Ydata',ylim,'LineWidth',3)];
0876 segment.lines = [segment.lines line('Xdata',[segment.start segment.end],'Ydata',[ylim(2) ylim(1)],'LineWidth',3)];
0877 out=segment;
0878
0879
0880 function JumpBack_Callback(hObject, eventdata, handles)
0881 Jump_shared(hObject, eventdata, handles, -1 )
0882
0883
0884 function Jump_Callback(hObject, eventdata, handles)
0885 Jump_shared(hObject, eventdata, handles, 1 )
0886
0887 function Jump_shared(hObject, eventdata, handles, jump_dir )
0888 Tim=eval(get(handles.DisplayWindow,'String'));
0889 tDuration = str2num(get(handles.Duration,'String'));
0890 maxTslider = (tDuration - Tim)/tDuration;
0891 NT=min(round(Tim*handles.Fs),length(handles.ts));
0892 Tslider=get(handles.slider1,'Value');
0893 Tslider = Tslider + jump_dir * Tim * handles.Fs / length(handles.ts);
0894
0895 if Tim > tDuration
0896 set(handles.DisplayWindow,'String',num2str(tDuration));
0897 Tslider = 0;
0898 end
0899
0900
0901 if jump_dir == 1
0902 if Tslider > maxTslider
0903 Tslider = maxTslider;
0904 end
0905 end
0906
0907 if jump_dir == -1
0908 if Tslider < 0
0909 Tslider = 0
0910 end
0911 end
0912
0913
0914
0915
0916
0917
0918
0919
0920 set(handles.slider1,'Value',Tslider);
0921 guidata(gcbo,handles);
0922 Plot_Callback(hObject, eventdata, handles)
0923
0924
0925 function LoadNext_Callback(hObject, eventdata, handles)
0926
0927
0928
0929
0930 exclude_name = [handles.filename, get(handles.ExcludeExt,'String')];
0931 if not(exist(exclude_name))
0932 fid=fopen( exclude_name, 'w' );
0933 fclose( fid);
0934 end
0935
0936 [path] = cell2mat(regexp( handles.filename, '^.*\', 'match' ));
0937 [extension] = cell2mat(regexp( handles.filename, '\w+$', 'match' ));
0938 dirlist = dir( [path '*' extension] );
0939 ndir = length(dirlist);
0940 n = 1;
0941 while n <= ndir
0942 file = dirlist(n).name;
0943 if not(exist([path file get(handles.ExcludeExt,'String')]))
0944 break;
0945 end
0946 n = n + 1;
0947 end
0948 if n <= ndir
0949 set( handles.FileNameString, 'String',file);
0950 handles.filename = [path file];
0951 guidata(gcbo,handles);
0952 handles = loadfile(hObject, eventdata, handles);
0953 else
0954 error('No more files found matching desired pattern');
0955 end
0956
0957
0958 function Precompute_Callback(hObject, eventdata, handles)
0959
0960 toggled = get( hObject, 'Value' );
0961 if toggled
0962
0963
0964
0965
0966 set(handles.WinSize, 'Enable', 'off');
0967 set(handles.StepSize, 'Enable', 'off');
0968 set(handles.TW, 'Enable', 'off');
0969 set(handles.MinFreq, 'Enable', 'off');
0970 set(handles.MaxFreq, 'Enable', 'off');
0971 set(handles.SpectrumType, 'Enable', 'off');
0972
0973
0974 set(handles.LoadNext, 'Enable','off');
0975
0976
0977 valueTslider = get(handles.slider1,'Value');
0978 set(handles.slider1,'Value',0);
0979 strDuration = get(handles.Duration,'String');
0980 strWindow = get(handles.DisplayWindow,'String');
0981
0982 handles.firsttime = 1;
0983
0984 if str2num(strDuration) > handles.maxspec_t
0985 strDuration = num2str(handles.maxspec_t);
0986 end
0987
0988 set(handles.DisplayWindow,'String',strDuration);
0989
0990 Plot_Callback(handles.Plot, eventdata, handles);
0991
0992 handles = guidata(hObject);
0993
0994 handles.firsttime = 0;
0995 handles.precomputed_spec = 1;
0996 set(handles.DisplayWindow,'String',strWindow);
0997 set(handles.slider1,'Value',valueTslider);
0998 Plot_Callback(handles.Plot, eventdata, handles);
0999 handles = guidata(hObject);
1000 handles.precomputed_spec = 1;
1001 else
1002 handles.precomputed_spec = 0;
1003
1004
1005
1006
1007 handles.S = [];
1008 handles.t = [];
1009 handles.f = [];
1010
1011 set(handles.WinSize, 'Enable', 'on');
1012 set(handles.StepSize, 'Enable', 'on');
1013 set(handles.TW, 'Enable', 'on');
1014 set(handles.MinFreq, 'Enable', 'on');
1015 set(handles.MaxFreq, 'Enable', 'on');
1016 set(handles.SpectrumType, 'Enable', 'on');
1017
1018 set(handles.TDerThresh, 'Enable', 'on');
1019 set(handles.LoadNext, 'Enable','on');
1020 set(handles.LoadFile, 'Enable','on');
1021
1022 end
1023
1024 guidata(hObject,handles);
1025
1026 function Precompute_CreateFcn(hObject, eventdata, handles)
1027
1028 function Path_Callback(hObject, eventdata, handles)
1029 path=get(hObject,'String')
1030
1031
1032 function Path_CreateFcn(hObject, eventdata, handles)
1033 set(hObject,'String',pwd);
1034 if ispc
1035 set(hObject,'BackgroundColor','white');
1036 else
1037 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1038 end
1039
1040 function Extensions_Callback(hObject, eventdata, handles)
1041
1042 function Extensions_CreateFcn(hObject, eventdata, handles)
1043 set(hObject,'String','wav');
1044 if ispc
1045 set(hObject,'BackgroundColor','white');
1046 else
1047 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1048 end
1049
1050 function Duration_CreateFcn(hObject, eventdata, handles)
1051 if ispc
1052 set(hObject,'BackgroundColor','white');
1053 else
1054 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1055 end
1056
1057 function LoadSegments_Callback(hObject, eventdata, handles)
1058
1059 handles = load_segment(handles, [handles.filename '.seg.txt'] );
1060 set( handles.LoadSegments, 'Enable', 'off' );
1061 handles = draw_segments( handles );
1062 guidata(gcbo,handles);
1063
1064 function handles=load_segment(handles,filename)
1065 fid=fopen( filename, 'r' );
1066 segments = [];
1067 scanned=fscanf( fid, '%g %g',[2 inf] );
1068 n = 1;
1069
1070 while n <= size(scanned, 2)
1071 segment.start = scanned(1,n);
1072 segment.end = scanned(2,n);
1073 segment.lines = [];
1074 segments = [ segments segment ];
1075 n = n + 1;
1076 end
1077
1078 handles.allsegments = segments;
1079 handles.segments = filtersegments(handles,handles.allsegments);
1080 handles.loadedsegment = 1;
1081
1082 guidata(gcf,handles);
1083
1084
1085 function filteredsegments = filtersegments(handles,segments)
1086
1087
1088
1089 realstart = handles.markerstart / handles.Fs;
1090 realend = handles.markerend / handles.Fs;
1091
1092 filteredsegments = [];
1093
1094 for i = 1:length(segments)
1095 if (segments(i).start >= realstart) && (segments(i).end <= realend)
1096 filteredsegments = [filteredsegments segments(i)];
1097 end
1098 end
1099
1100 for i=1:length(filteredsegments)
1101 filteredsegments(i).start = filteredsegments(i).start - realstart;
1102 filteredsegments(i).end = filteredsegments(i).end - realstart;
1103 end
1104
1105 function ExcludeExt_Callback(hObject, eventdata, handles)
1106
1107
1108
1109
1110 function ExcludeExt_CreateFcn(hObject, eventdata, handles)
1111
1112 if ispc
1113 set(hObject,'BackgroundColor','white');
1114 else
1115 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1116 end
1117
1118
1119 function DeleteSegment_Callback(hObject, eventdata, handles)
1120
1121
1122 pos=get(handles.segmentLineP,'Xdata');
1123 n = 1;
1124 while n <= length( handles.segments )
1125 if pos(1) >= handles.segments(n).start && pos(1) <= handles.segments(n).end
1126 handles=delete_segment( handles, n );
1127 else
1128 n = n + 1;
1129 end
1130 end
1131 drawnow;
1132 guidata(gcbo,handles);
1133
1134 function handles=delete_segment( handles, n )
1135 nl = 1;
1136 while nl <= length( handles.segments(n).lines )
1137 set( handles.segments(n).lines(nl), 'Visible', 'off');
1138 nl = nl + 1;
1139 end
1140 handles.segments(n) = [];
1141 fprintf('deleted!\n');
1142
1143 function SaveSegments_Callback(hObject, eventdata, handles)
1144
1145
1146
1147 handles = savesegments2mem(handles);
1148
1149 segment_file = fopen( [handles.filename '.seg.txt'], 'wt' );
1150 n = 1;
1151 while n <= size(handles.allsegments, 2)
1152 fprintf( segment_file, '%f %f\n', handles.allsegments(n).start, handles.allsegments(n).end );
1153 n = n + 1;
1154 end
1155 fclose(segment_file);
1156 set( handles.SegmentButton, 'Enable', 'on' );
1157 guidata(gcbo,handles);
1158
1159 function handles=savesegments2mem(handles)
1160
1161
1162
1163
1164 oldsegments = [];
1165
1166 realstart = handles.markerstart / handles.Fs;
1167 realend = handles.markerend / handles.Fs;
1168
1169 for i = 1:length(handles.allsegments)
1170 if not((handles.allsegments(i).start) >= realstart && (handles.allsegments(i).end <= realend))
1171 oldsegments = [oldsegments handles.allsegments(i)];
1172 end
1173 end
1174
1175
1176
1177 newsegments = [];
1178
1179 for i = 1:length(handles.segments)
1180 segment = handles.segments(i);
1181 segment.start = segment.start + realstart;
1182 segment.end = segment.end + realstart;
1183 newsegments = [newsegments segment];
1184 end
1185
1186 handles.allsegments = [oldsegments newsegments];
1187
1188 function SegCancel_Callback(hObject, eventdata, handles)
1189 set( handles.SegmentButton, 'Enable', 'on' );
1190 guidata(gcbo,handles);
1191
1192
1193 function PlotSegments_Callback(hObject, eventdata, handles)
1194
1195
1196
1197 [path] = cell2mat(regexp( handles.filename, '^.*\', 'match' ));
1198 [extension] = cell2mat(regexp( handles.filename, '\w+$', 'match' ));
1199
1200 path=get(handles.Path,'String');
1201 extension=get(handles.Extensions,'String');
1202 dirlist = dir( [path '\*' extension '.seg.txt'] );
1203 ndir = length(dirlist);
1204 n = 1;
1205 all_segments = [];
1206 while n <= ndir
1207 file = dirlist(n).name;
1208 segments = load_segment([path '\' file]);
1209 all_segments = [all_segments segments];
1210 n = n + 1;
1211 end
1212
1213
1214 if length(all_segments) > 2
1215
1216 figure();
1217 axes();
1218 nbin= max(length([all_segments.end])/5,10);
1219 syllable_lengths=[all_segments.end]-[all_segments.start];
1220 hi=hist( syllable_lengths ,nbin);
1221 tl=min( syllable_lengths );
1222 th=max( syllable_lengths );
1223 times=tl:((th-tl)/(nbin-1)):th;
1224 plot(times,hi);
1225 xlabel('Segment Length (s)');
1226 ylabel('N');
1227 title(['All segments in ' path]);
1228 else
1229 error('too few segments to plot');
1230 end
1231 guidata(gcbo,handles);
1232
1233
1234
1235 function AutoSegButton_Callback(hObject, eventdata, handles)
1236
1237 n = 1;
1238 segments = [];
1239 segment.start = 0;
1240 segment.end = 0;
1241 segment.lines = [];
1242 minlen = eval(get( handles.SegmentLengthEdit, 'String' ));
1243 while n < length( handles.times )
1244
1245 if ( handles.transition(n) > 0 )
1246 segment.start = handles.times(n);
1247 end
1248 if ( handles.transition(n) < 0 )
1249 segment.end = handles.times(n);
1250 end
1251 if (segment.start > 0) && (segment.end) > 0 && (segment.end - segment.start) > minlen
1252 segments = [ segments segment ];
1253 segment.start = 0;
1254 segment.end = 0;
1255 end
1256 n = n + 1;
1257 end
1258
1259 handles.segments = [handles.segments segments];
1260 handles = draw_segments( handles );
1261 guidata(gcbo,handles);
1262
1263 function DeleteAllButton_Callback(hObject, eventdata, handles)
1264
1265 while length( handles.segments )
1266 handles = delete_segment( handles, 1 );
1267 end
1268 guidata(gcf,handles);
1269
1270
1271
1272 function PlotAllButton_Callback(hObject, eventdata, handles)
1273
1274
1275
1276
1277 set(handles.slider1,'Value',0);
1278
1279 strDuration = get(handles.Duration,'String');
1280
1281 if str2num(strDuration) > handles.maxspec_t
1282 strDuration = num2str(handles.maxspec_t);
1283 end
1284
1285
1286 set(handles.DisplayWindow,'String',strDuration);
1287 Plot_Callback(hObject, eventdata, handles);
1288
1289
1290
1291 function PreviousChunk_Callback(hObject, eventdata, handles)
1292
1293
1294
1295
1296
1297 handles = savesegments2mem(handles);
1298 handles = loadfile(hObject, eventdata, handles,[handles.markerstart-handles.maxwavsize-1,handles.markerstart-1]);
1299
1300 ;
1301 guidata(gcf,handles);
1302
1303
1304 function NextChunk_Callback(hObject, eventdata, handles)
1305
1306
1307
1308
1309 handles = savesegments2mem(handles);
1310 handles = loadfile(hObject, eventdata, handles, [handles.markerend+1,handles.markerend+1+handles.maxwavsize]);
1311 guidata(gcf,handles);
1312
1313
1314 function AutoSegmentFile_Callback(hObject, eventdata, handles)
1315
1316
1317
1318
1319 while (handles.markerend < handles.wavsize)
1320
1321 PlotAllButton_Callback(hObject, eventdata, handles);
1322 handles = guidata(gcbo);
1323 AutoSegButton_Callback(hObject, eventdata, handles);
1324 handles = guidata(gcbo);
1325 NextChunk_Callback(hObject, eventdata, handles);
1326 handles = guidata(gcbo);
1327
1328 end
1329
1330
1331 PlotAllButton_Callback(hObject, eventdata, handles);
1332 handles = guidata(gcbo);
1333 AutoSegButton_Callback(hObject, eventdata, handles);
1334 handles = guidata(gcbo);
1335 guidata(gcbo,handles);
1336
1337
1338 function MaxSegLength_Callback(hObject, eventdata, handles)
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348 function MaxSegLength_CreateFcn(hObject, eventdata, handles)
1349
1350
1351
1352
1353
1354
1355 if ispc
1356 set(hObject,'BackgroundColor','white');
1357 else
1358 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1359 end
1360
1361 function MaximumWavSize_Callback(hObject, eventdata, handles)
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371 function MaximumWavSize_CreateFcn(hObject, eventdata, handles)
1372
1373
1374
1375
1376
1377
1378 if ispc
1379 set(hObject,'BackgroundColor','white');
1380 else
1381 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1382 end
1383
1384
1385 function SeekButton_Callback(hObject, eventdata, handles)
1386
1387
1388
1389
1390
1391
1392 handles = savesegments2mem(handles);
1393
1394 try
1395 timetoseek = str2num(get(handles.SeektoEdit,'String'));
1396 catch
1397 timetoseek = 0;
1398 set(handles.SeektoEdit,'String','0');
1399 end
1400
1401 if timetoseek < 0
1402 timetoseek = 0;
1403 set(handles.SeektoEdit,'String','0');
1404 end
1405
1406 timetoseek = round(timetoseek * handles.Fs);
1407
1408 if timetoseek >= handles.wavsize
1409 timetoseek = timetoseek - handles.maxwavsize;
1410 end
1411
1412 timetoseek = timetoseek + 1;
1413 timetoseekend = timetoseek + handles.maxwavsize;
1414
1415 if timetoseekend > handles.wavsize
1416 timetoseekend = handles.wavsize;
1417 end
1418
1419 oldstate = handles.dontcutsegments;
1420 handles.dontcutsegments = 0;
1421 handles = loadfile(hObject,eventdata,handles,[timetoseek timetoseekend]);
1422 handles.dontcutsegments = oldstate;
1423
1424 guidata(gcbo,handles);
1425
1426 function SeektoEdit_Callback(hObject, eventdata, handles)
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436 function SeektoEdit_CreateFcn(hObject, eventdata, handles)
1437
1438
1439
1440
1441
1442
1443 if ispc
1444 set(hObject,'BackgroundColor','white');
1445 else
1446 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1447 end
1448
1449
1450
1451
1452
1453 function RealDuration_Callback(hObject, eventdata, handles)
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463 function RealDuration_CreateFcn(hObject, eventdata, handles)
1464
1465
1466
1467
1468
1469
1470 if ispc
1471 set(hObject,'BackgroundColor','white');
1472 else
1473 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1474 end
1475
1476
1477
1478
1479
1480 function AutoMethodPopupMenu_Callback(hObject, eventdata, handles)
1481
1482
1483
1484
1485
1486
1487 contents = get(hObject,'String');
1488 method = contents{get(hObject,'Value')}
1489
1490 if strcmp(method,'Summed intensity')
1491 handles.automethod = 'threshold';
1492 set(handles.AmpThresh,'Visible','on');
1493 set(handles.RatioThresh,'Visible','off');
1494 elseif strcmp(method,'Ratio')
1495 handles.automethod = 'ratiof';
1496 set(handles.AmpThresh,'Visible','off');
1497 set(handles.RatioThresh,'Visible','on');
1498 end
1499
1500 guidata(gcbo,handles);
1501
1502
1503 function AutoMethodPopupMenu_CreateFcn(hObject, eventdata, handles)
1504
1505
1506
1507
1508
1509
1510 if ispc
1511 set(hObject,'BackgroundColor','white');
1512 else
1513 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1514 end
1515
1516
1517
1518 function RatioThresh_Callback(hObject, eventdata, handles)
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528 function RatioThresh_CreateFcn(hObject, eventdata, handles)
1529
1530
1531
1532
1533
1534
1535 if ispc
1536 set(hObject,'BackgroundColor','white');
1537 else
1538 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1539 end
1540
1541
1542
1543 function RatioLower_Callback(hObject, eventdata, handles)
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553 function RatioLower_CreateFcn(hObject, eventdata, handles)
1554
1555
1556
1557
1558
1559
1560 if ispc
1561 set(hObject,'BackgroundColor','white');
1562 else
1563 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1564 end
1565
1566
1567
1568 function RatioUpper_Callback(hObject, eventdata, handles)
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578 function RatioUpper_CreateFcn(hObject, eventdata, handles)
1579
1580
1581
1582
1583
1584
1585 if ispc
1586 set(hObject,'BackgroundColor','white');
1587 else
1588 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1589 end
1590
1591
1592
1593 function OptionsDisplay_Callback(hObject, eventdata, handles)
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603 state = get(hObject,'Value');
1604
1605 if state
1606 set(handles.OptionsUiPanel,'Visible','on');
1607
1608 else
1609 set(handles.OptionsUiPanel,'Visible','off');
1610
1611 end
1612
1613
1614
1615 guidata(gcbo,handles)
1616
1617
1618
1619 function Duration_Callback(hObject, eventdata, handles)
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631 function SmoothFactor_Callback(hObject, eventdata, handles)
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641 function SmoothFactor_CreateFcn(hObject, eventdata, handles)
1642
1643
1644
1645
1646
1647
1648 if ispc
1649 set(hObject,'BackgroundColor','white');
1650 else
1651 set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
1652 end
1653
1654
1655
1656
1657
1658 function channel_Callback(hObject, eventdata, handles)
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669 function channel_CreateFcn(hObject, eventdata, handles)
1670
1671
1672
1673
1674
1675
1676 if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
1677 set(hObject,'BackgroundColor','white');
1678 end
1679
1680