tomwalters@0: % procedure for 'aim-mat' tomwalters@0: %function handles=replotgraphic(handles,options) tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % handles tomwalters@0: % options: fields indicate, which graphic is to plot: tomwalters@0: % withtime=options.withtime; tomwalters@0: % withfre=options.withfre; tomwalters@0: % withsignal=options.withsignal; tomwalters@0: % figure_handle=options.figure_handle; tomwalters@0: % RETURN VALUE: tomwalters@0: % updated handles tomwalters@0: % tomwalters@0: % plots the current graphic in the GUI or in the current windowhandle bleeck@3: % 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: function handles=aim_replotgraphic(handles,options) tomwalters@0: tomwalters@0: withtime=options.withtime; tomwalters@0: withfre=options.withfre; tomwalters@0: withsignal=options.withsignal; tomwalters@0: figure_handle=options.figure_handle; tomwalters@0: tomwalters@0: %TCW AIM2006 - added hand scaling so that when on the slider scale value is absolutely tomwalters@0: %absolute. This is set in init_aim_gui (can we find anywhere better to do tomwalters@0: %this?) tomwalters@0: hand_scaling=handles.hand_scaling; tomwalters@0: tomwalters@0: if isfield(options,'display_single_channel') tomwalters@0: do_single_channel=1; tomwalters@0: else tomwalters@0: do_single_channel=0; tomwalters@0: options.display_single_channel=1; % in case, the frame has only one channel tomwalters@0: end tomwalters@0: tomwalters@0: % where tomwalters@0: current_plot=handles.info.current_plot; tomwalters@0: if ~ishandle(figure_handle) tomwalters@0: new_fig=figure; tomwalters@0: handles.info.current_figure=new_fig; tomwalters@0: end tomwalters@0: tomwalters@0: figure(figure_handle); tomwalters@0: clf tomwalters@0: set(gca,'Position',[0 0.1 0.92 0.89]); tomwalters@0: cur_axis=gca; tomwalters@0: tomwalters@0: win=get(cur_axis,'Parent'); tomwalters@0: set(win,'NumberTitle','off'); tomwalters@0: namestr=aim_getwindowtitle(handles); % get the title of the current window tomwalters@0: set(win,'Name',namestr); tomwalters@0: tomwalters@0: relative_axis=get(gca,'Position'); % the relative axis for the plot. Everything is plotted inside tomwalters@0: % define up to four graphic areas for the different plots inside the axis tomwalters@0: % given in 'relative_axis' tomwalters@0: [myaxes1,myaxes2,myaxes3,myaxes4]=aim_define_plot_areas(handles,relative_axis,options); tomwalters@0: % 1: signal window at top tomwalters@0: % 2: main window in middle tomwalters@0: % 3: temporal profile tomwalters@0: % 4: frequency profile tomwalters@0: tomwalters@0: % find out about the signal, length and duration tomwalters@0: sig=handles.data.signal; tomwalters@0: % len=getlength(sig); tomwalters@0: tomwalters@0: tomwalters@0: if current_plot>=6 tomwalters@0: sai=handles.data.sai; tomwalters@0: if handles.with_graphic==0 tomwalters@0: current_frame_number=handles.current_frame_nr; tomwalters@0: else tomwalters@0: current_frame_number=round(slidereditcontrol_get_value(handles.currentslidereditcombi)); tomwalters@0: end tomwalters@0: if current_frame_number<=length(sai) && current_frame_number>0 tomwalters@0: start_time=getcurrentframestarttime(sai{current_frame_number}); tomwalters@0: else tomwalters@0: start_time=getminimumtime(sig); tomwalters@0: current_frame_number=1; % error! tomwalters@0: handles.currentslidereditcombi=slidereditcontrol_set_value(handles.currentslidereditcombi,length(sai)); tomwalters@0: end tomwalters@0: duration=getlength(sai{current_frame_number}); tomwalters@0: else tomwalters@0: start_time=slidereditcontrol_get_value(handles.currentslidereditcombi); tomwalters@0: duration=slidereditcontrol_get_value(handles.slideredit_duration); tomwalters@0: end tomwalters@0: stop_time=start_time+duration; tomwalters@0: tomwalters@0: % in case of auditory image, we simply want the last part of the signal: tomwalters@0: if stop_time>getmaximumtime(sig); tomwalters@0: start_time=getmaximumtime(sig)-duration; tomwalters@0: stop_time=getmaximumtime(sig); tomwalters@0: end tomwalters@0: if start_time < getminimumtime(sig) tomwalters@0: start_time =getminimumtime(sig); tomwalters@0: end tomwalters@0: % sig=getpart(sig,start_time,stop_time); tomwalters@0: tomwalters@0: tomwalters@0: % The signal window tomwalters@0: if withsignal tomwalters@0: set(myaxes1,'Visible','on'); tomwalters@0: % axes(myaxes1); tomwalters@0: % sig=getpart(sig,start_time,stop_time); tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: h=plot(sig,[start_time stop_time],myaxes1); tomwalters@0: set(h,'Color','k'); tomwalters@0: set(h,'LineWidth',1.5); tomwalters@0: else tomwalters@0: plot(sig,[start_time stop_time],myaxes1); tomwalters@0: end tomwalters@0: if min(sig)==0 % for niceness: Clicktrains are cut away otherwise tomwalters@0: ax=axis; tomwalters@0: ax(3)=-0.1; tomwalters@0: axis(ax); tomwalters@0: end tomwalters@0: title('');set(gca,'XTick',[]);set(gca,'YTick',[]);xlabel('');ylabel(''); tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: % from here: plot in axes2: tomwalters@0: % axes(myaxes2); tomwalters@0: set(myaxes2,'XDir','normal') tomwalters@0: set(myaxes2,'XScale','lin'); tomwalters@0: if handles.with_graphic==1 tomwalters@0: current_scale=slidereditcontrol_get_value(handles.slideredit_scale); tomwalters@0: else tomwalters@0: current_scale=options.data_scale; tomwalters@0: end tomwalters@0: tomwalters@0: switch current_plot tomwalters@0: case {-1,0,1} % signal tomwalters@0: set(myaxes2,'Visible','off'); tomwalters@0: case 2% pcp tomwalters@0: sig=handles.data.pcp; tomwalters@0: % current_frame=getpart(sig,start_time,stop_time); tomwalters@0: ca=plot(sig,[start_time stop_time]); tomwalters@0: set(gca,'YTick',[]); tomwalters@0: ax=axis; tomwalters@0: ax(3)=ax(3)/current_scale; tomwalters@0: ax(4)=ax(4)/current_scale; tomwalters@0: axis(ax); tomwalters@0: title('');xlabel('');ylabel(''); tomwalters@0: case 3% bmm tomwalters@0: current_frame=handles.data.bmm; tomwalters@0: str=get_graphics_options(handles,handles.info.current_bmm_module); tomwalters@0: str.minimum_time_interval=start_time; tomwalters@0: str.maximum_time_interval=stop_time; tomwalters@0: nrchan=getnrchannels(handles.data.bmm); tomwalters@0: if do_single_channel || nrchan==1 tomwalters@0: sig=getsinglechannel(current_frame,options.display_single_channel); tomwalters@0: % sig=getpart(sig,start_time,stop_time); tomwalters@0: ymin=min(current_frame)*1.1;ymax=max(current_frame)*1.1; tomwalters@0: plot(sig,[start_time stop_time ymin ymax]); tomwalters@0: set(gca,'Ylim',[ymin,ymax]);set(gca,'YAxisLocation','right'); tomwalters@0: xlabel('time (ms)');ylabel('amplitude');title(''); tomwalters@0: else tomwalters@0: hand=plot(current_frame,str,myaxes2); tomwalters@0: zmin=min(current_frame)/current_scale;zmax=max(current_frame)/current_scale; tomwalters@0: tomwalters@0: %set(gca,'Zlim',[zmin,zmax]); tomwalters@0: tomwalters@0: %TCW AIM 2006 tomwalters@0: if hand_scaling == 1 tomwalters@0: set(gca,'Zlim',[0,1/current_scale]); tomwalters@0: else tomwalters@0: %TCW AIM 2006 to get this frequency axis correct, this lower tomwalters@0: %limit of the z axis really needs to be zero tomwalters@0: set(gca,'Zlim',[0,zmax]); tomwalters@0: end tomwalters@0: tomwalters@0: xlabel('time (ms)');ylabel('Frequency (kHz)');title(''); tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12);xlab=get(par,'xlabel');set(xlab,'FontSize',12);ylab=get(par,'ylabel');set(ylab,'FontSize',12); tomwalters@0: end tomwalters@0: end tomwalters@0: case 4% nap tomwalters@0: current_frame=handles.data.nap; tomwalters@0: str=get_graphics_options(handles,handles.info.current_nap_module); tomwalters@0: str.minimum_time_interval=start_time; tomwalters@0: str.maximum_time_interval=stop_time; tomwalters@0: nrchan=getnrchannels(current_frame); tomwalters@0: if do_single_channel || nrchan==1 tomwalters@0: sig=getsinglechannel(current_frame,options.display_single_channel); tomwalters@0: % sig=getpart(sig,start_time,stop_time); tomwalters@0: ymin=0; tomwalters@0: ymax=max(current_frame)*1.1; tomwalters@0: plot(sig,[start_time stop_time]); tomwalters@0: set(gca,'Ylim',[ymin,ymax]);set(gca,'YAxisLocation','right'); tomwalters@0: xlabel('time (ms)');ylabel('amplitude');title(''); tomwalters@0: else tomwalters@0: hand=plot(current_frame,str); tomwalters@0: zmin=0;zmax=max(current_frame)/current_scale; tomwalters@0: tomwalters@0: %TCW AIM 2006 tomwalters@0: if hand_scaling == 1 tomwalters@0: set(gca,'Zlim',[zmin,1/current_scale]); tomwalters@0: else tomwalters@0: set(gca,'Zlim',[zmin,zmax]); tomwalters@0: end tomwalters@0: tomwalters@0: %set(gca,'Zlim',[zmin,zmax]); tomwalters@0: tomwalters@0: tomwalters@0: xlabel('time (ms)');ylabel('Frequency (kHz)');title(''); tomwalters@0: tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12);xlab=get(par,'xlabel');set(xlab,'FontSize',12);ylab=get(par,'ylabel');set(ylab,'FontSize',12); tomwalters@0: end tomwalters@0: end tomwalters@0: case 5% strobes tomwalters@0: current_frame=handles.data.nap; tomwalters@0: strobes=handles.data.strobes; tomwalters@0: str=get_graphics_options(handles,handles.info.current_strobes_module); tomwalters@0: str.minimum_time_interval=start_time; tomwalters@0: str.maximum_time_interval=stop_time; tomwalters@0: nrchan=getnrchannels(current_frame); tomwalters@0: temp_scale=1; % for debugging tomwalters@0: % make the dots of a size of constant ratio to the window size tomwalters@0: axpos=get(gcf,'Position'); tomwalters@0: marker_dot_size=axpos(3)/168; tomwalters@0: if do_single_channel || nrchan==1 % only one channel tomwalters@0: tomwalters@0: chan_nr=options.display_single_channel; tomwalters@0: % chan_nr = [chan_nr-2 chan_nr-1 chan_nr chan_nr+1]; tomwalters@0: % chan_nr = [chan_nr-1 chan_nr]; tomwalters@0: chan_nr = chan_nr; tomwalters@0: chan_nr=chan_nr(chan_nr>0 & chan_nr < getnrchannels(current_frame)); tomwalters@0: options.display_single_channel=chan_nr; tomwalters@0: tomwalters@0: plot_single_channel_strobes(current_frame,options,handles,str,strobes,current_scale,duration); tomwalters@0: else %several channels tomwalters@0: hand=plot(current_frame/temp_scale,str,myaxes2);hold on tomwalters@0: xlabel('time (ms)');ylabel('Frequency (kHz)');title(''); tomwalters@0: colscale=length(hsv)/nrchan; tomwalters@0: for i=1:nrchan tomwalters@0: if isfield(strobes,'grouped') tomwalters@0: nr_sources=size(strobes.cross_strobes{1}.source_cross_channel_value,2); tomwalters@0: cols=hsv; tomwalters@0: % first plot the originals tomwalters@0: % herestrobes=strobes.original{i}; tomwalters@0: % nr_here=length(herestrobes.strobes); tomwalters@0: % col=cols(round(i*colscale),:); tomwalters@0: % xoffs=-0.001; tomwalters@0: % for j=1:nr_here tomwalters@0: % time=herestrobes.strobes(j); tomwalters@0: % if time>start_time & time1 tomwalters@0: colnr=round(k*length(hsv)/nr_sources); tomwalters@0: colnr=min(colnr,length(hsv)); tomwalters@0: colnr=max(colnr,1); tomwalters@0: col=cols(colnr,:); tomwalters@0: cursize=target_chan_act/100; tomwalters@0: else tomwalters@0: continue tomwalters@0: end tomwalters@0: time=herestrobes(j); tomwalters@0: if time>start_time && timestart_time && time1 && withtime tomwalters@0: % axes(myaxes2); tomwalters@0: set(myaxes2,'XTick',[]); tomwalters@0: set(get(myaxes2,'xlabel'),'string',''); tomwalters@0: tomwalters@0: if current_plot<6 tomwalters@0: str.minimum_time_interval=start_time; tomwalters@0: str.maximum_time_interval=start_time+duration; tomwalters@0: str.is_log=0; tomwalters@0: str.time_reversed=0; tomwalters@0: str.time_profile_scale=-1; % decide on your own! tomwalters@0: else tomwalters@0: if current_plot==6 tomwalters@0: str=get_graphics_options(handles,handles.info.calculated_sai_module); tomwalters@0: str.time_profile_scale=-1; %variable scaling tomwalters@0: % TCW AIM2006 WAS: tomwalters@0: %str.time_profile_scale=1; %fixed scaling tomwalters@0: else tomwalters@0: str=get_graphics_options(handles,handles.info.calculated_usermodule_module); tomwalters@0: end tomwalters@0: end tomwalters@0: hand=plottemporalprofile(current_frame,str,myaxes3); tomwalters@0: if current_plot<6 tomwalters@0: set(get(myaxes3,'xlabel'),'string','time (ms)'); tomwalters@0: % xlabel('time (ms)') tomwalters@0: elseif getxaxis(current_frame)=='0' tomwalters@0: set(get(myaxes3,'xlabel'),'string','Time-Interval, Peak-Frequency product, \ith'); tomwalters@0: % xlabel('Time-Interval, Peak-Frequency product, \ith') %brute force method change by Rich tomwalters@0: elseif strcmp(getxaxis(current_frame),'harmonic ratio') tomwalters@0: set(get(myaxes3,'xlabel'),'string','harmonic ratio'); tomwalters@0: % xlabel('harmonic ratio') %brute force method change by Stefan we must do something about this!! tomwalters@0: else tomwalters@0: set(get(myaxes3,'xlabel'),'string','time interval (ms)'); tomwalters@0: % xlabel('time interval (ms)') tomwalters@0: end tomwalters@0: title(''); tomwalters@0: set(gca,'XMinorTick','off'); tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: set(hand,'Color','k'); tomwalters@0: set(hand,'LineWidth',1.5); tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12); tomwalters@0: xlab=get(par,'xlabel'); tomwalters@0: set(xlab,'FontSize',12); tomwalters@0: end tomwalters@0: tomwalters@0: else tomwalters@0: set(myaxes2,'TickLength',[0.01,0.01]); tomwalters@0: end tomwalters@0: tomwalters@0: if current_plot>1 && withfre tomwalters@0: set(myaxes2,'YTick',[]); tomwalters@0: set(get(myaxes2,'ylabel'),'string',''); tomwalters@0: % ylabel(''); tomwalters@0: % axes(myaxes4); tomwalters@0: % cla tomwalters@0: tomwalters@0: tomwalters@0: if current_plot<6 tomwalters@0: str.minimum_time_interval=start_time; tomwalters@0: str.maximum_time_interval=start_time+duration; tomwalters@0: str.frequency_profile_scale=-1; % decide on your own according to momentan state tomwalters@0: else tomwalters@0: str.frequency_profile_scale=1; % fixed scaling tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: if getxaxis(current_frame)=='0' tomwalters@0: hand=plotfrequencyprofile(current_frame,str,myaxes4); tomwalters@0: set(get(myaxes4,'xlabel'),'string','Mellin variable c'); tomwalters@0: % set(get(myaxes4,'xlabel'),'string','Mellin variable, \it{c/2\pi'); tomwalters@0: % xlabel('Mellin variable, \it{c/2\pi}'); %brute force change by Rich tomwalters@0: str.shrink_range=-1; tomwalters@0: elseif strcmp(getxaxis(current_frame),'harmonic ratio') tomwalters@0: str.frequency_profile_scale=-1; tomwalters@0: hand=plotfrequencyprofile(current_frame,str,myaxes4); tomwalters@0: set(get(myaxes4,'xlabel'),'string','scale variable'); tomwalters@0: % xlabel('scale variable'); % tomwalters@0: else tomwalters@0: % str.shrink_range=1/0.85; tomwalters@0: str.shrink_range=1; tomwalters@0: hand=plotfrequencyprofile(current_frame,str,myaxes4); tomwalters@0: set(get(myaxes4,'xlabel'),'string','Frequency (kHz)'); tomwalters@0: % xlabel('Frequency (kHz)'); tomwalters@0: end tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: set(hand,'Color','k'); tomwalters@0: set(hand,'LineWidth',1.5); tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12); tomwalters@0: xlab=get(par,'xlabel'); tomwalters@0: set(xlab,'FontSize',12); tomwalters@0: % set(get(hand, tomwalters@0: end tomwalters@0: tomwalters@0: else tomwalters@0: set(myaxes2,'TickLength',[0.01,0.01]); tomwalters@0: end tomwalters@0: tomwalters@0: if isfield(handles.info,'domovie') % no more actions! tomwalters@0: return tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: % handles potential other windows tomwalters@0: if isfield(handles.info,'children') && ~isfield(handles.info,'iscallfromchild') && current_plot <7 tomwalters@0: % first check, whether the child is still there: tomwalters@0: if ~ishandle(handles.info.children.single_channel.windowhandle) tomwalters@0: rmfield(handles.info,'children'); tomwalters@0: return tomwalters@0: end tomwalters@0: channr=single_channel_gui('getchannelnumber'); tomwalters@0: handles.info.children.single_channel.channelnumber=channr; tomwalters@0: single_channel_gui(handles); tomwalters@0: tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: function str=get_graphics_options(handles,module_name) tomwalters@0: % returns the graphic options, if they exist tomwalters@0: tomwalters@0: str=[]; tomwalters@0: if isfield(handles.all_options.graphics,module_name) tomwalters@0: str=getfield(handles.all_options.graphics,module_name); tomwalters@0: else tomwalters@0: % disp(sprintf('graphics part for module %s not found. Check version',module_name)); tomwalters@0: switch handles.info.current_plot tomwalters@0: case {1,2,3,4,5} tomwalters@0: opstr.is_log=0; tomwalters@0: opstr.time_reversed=0; tomwalters@0: opstr.plotstyle='waterfall'; tomwalters@0: opstr.plotcolor='k'; tomwalters@0: opstr.display_time=0; tomwalters@0: case {6} tomwalters@0: opstr.is_log=1; tomwalters@0: opstr.time_reversed=1; tomwalters@0: opstr.plotstyle='waterfall'; tomwalters@0: opstr.plotcolor='k'; tomwalters@0: opstr.minimum_time=0.001; tomwalters@0: opstr.maximum_time=0.032; tomwalters@0: opstr.display_time=0; tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: function plot_single_channel_strobes(current_frame,options,handles,str,strobes,current_scale,duration) tomwalters@0: start_time=str.minimum_time_interval; tomwalters@0: stop_time=str.maximum_time_interval; tomwalters@0: tomwalters@0: nr_channels=length(options.display_single_channel); tomwalters@0: tomwalters@0: count=0; tomwalters@0: for channr=options.display_single_channel tomwalters@0: count=count+1; tomwalters@0: sig=getsinglechannel(current_frame,channr); tomwalters@0: sigpart=getpart(sig,start_time,stop_time); tomwalters@0: ymin=0;ymax=max(current_frame)*1.2; tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: % hand=plot(sigpart,[getminimumtime(sigpart),getminimumtime(sigpart)+getlength(sigpart)]); tomwalters@0: hand=plot(sig,[start_time stop_time]); tomwalters@0: set(hand,'Color','k'); tomwalters@0: set(hand,'LineWidth',1.5); tomwalters@0: ylabel('NAP amplitude'); tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12); tomwalters@0: xlab=get(par,'xlabel'); tomwalters@0: set(xlab,'FontSize',12); tomwalters@0: set(gca,'Ytick',[]); tomwalters@0: set(gca,'YAxisLocation','right'); tomwalters@0: else tomwalters@0: switch count tomwalters@0: case 1 tomwalters@0: color='b'; tomwalters@0: case 2 tomwalters@0: color='m'; tomwalters@0: end tomwalters@0: plot(sigpart,[getminimumtime(sigpart),getminimumtime(sigpart)+getlength(sigpart)],color); tomwalters@0: end tomwalters@0: hold on tomwalters@0: tomwalters@0: athres=handles.data.thresholds;%*current_scale/getallmaxvalue(current_frame); tomwalters@0: thres=getsinglechannel(athres,channr); tomwalters@0: thres=getpart(thres,start_time,stop_time); tomwalters@0: hand=plot(thres,[start_time stop_time 0 max(current_frame)/current_scale],'g'); tomwalters@0: if strcmp(handles.screen_modus,'paper') tomwalters@0: set(hand,'Color','k'); tomwalters@0: set(hand,'LineWidth',1.5); tomwalters@0: par=get(hand,'parent'); tomwalters@0: set(par,'FontSize',12); tomwalters@0: xlab=get(par,'xlabel'); tomwalters@0: ylabel('NAP amplitude'); tomwalters@0: set(xlab,'FontSize',12); tomwalters@0: else tomwalters@0: xlabel('time (ms)');ylabel('amplitude');title('');set(gca,'YAxisLocation','right'); tomwalters@0: end tomwalters@0: herestrobes=strobes{channr}; tomwalters@0: nr_here=length(herestrobes.strobes); tomwalters@0: for j=1:nr_here tomwalters@0: time=herestrobes.strobes(j); tomwalters@0: if time>start_time & time