annotate demo/plot_strobes.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 74dedb26614d
children
rev   line source
tomwalters@0 1 % demonstration file for 'aim-mat'
tomwalters@0 2 %
tomwalters@0 3 % (c) 2006-2008, University of Cambridge, Medical Research Council
tomwalters@0 4 % Written by Tom Walters (tcw24@cam.ac.uk)
tomwalters@0 5 % http://www.pdn.cam.ac.uk/cnbh/aim2006
tomwalters@0 6 % $Date: 2008-06-10 18:00:16 +0100 (Tue, 10 Jun 2008) $
tomwalters@0 7 % $Revision: 585 $
tomwalters@0 8
tomwalters@0 9 function plot_strobes(input, options, current_scale, titlestr)
tomwalters@0 10
tomwalters@0 11 start_time=options.minimum_time;
tomwalters@0 12 stop_time=options.maximum_time;
tomwalters@0 13
tomwalters@0 14 sig=input.data.signal;
tomwalters@0 15 current_frame=input.data.nap;
tomwalters@0 16 strobes=input.data.strobes;
tomwalters@0 17 input.info.current_plot=4;
tomwalters@0 18 str=get_graphics_options(input,input.info.current_strobes_module);
tomwalters@0 19 str.minimum_time_interval=start_time;
tomwalters@0 20 str.maximum_time_interval=stop_time;
tomwalters@0 21 duration=stop_time-start_time;
tomwalters@0 22 sig=getpart(sig,start_time,stop_time);
tomwalters@0 23 nrchan=getnrchannels(current_frame);
tomwalters@0 24 temp_scale=1; % for debugging
tomwalters@0 25 % make the dots of a size of constant ratio to the window size
tomwalters@0 26 axpos=get(gcf,'Position');
tomwalters@0 27 marker_dot_size=axpos(3)/168;
tomwalters@0 28
tomwalters@0 29 %several channels
tomwalters@0 30 hand=plot(current_frame/temp_scale,str);hold on
tomwalters@0 31 xlabel('time (ms)');ylabel('Frequency (kHz)');title(titlestr);
tomwalters@0 32 colscale=length(hsv)/nrchan;
tomwalters@0 33 for i=1:nrchan
tomwalters@0 34 if isfield(strobes,'grouped')
tomwalters@0 35 nr_sources=size(strobes.cross_strobes{1}.source_cross_channel_value,2);
tomwalters@0 36 cols=hsv;
tomwalters@0 37 % first plot the originals
tomwalters@0 38 % herestrobes=strobes.original{i};
tomwalters@0 39 % nr_here=length(herestrobes.strobes);
tomwalters@0 40 % col=cols(round(i*colscale),:);
tomwalters@0 41 % xoffs=-0.001;
tomwalters@0 42 % for j=1:nr_here
tomwalters@0 43 % time=herestrobes.strobes(j);
tomwalters@0 44 % if time>start_time & time<start_time+duration
tomwalters@0 45 % val=herestrobes.strobe_vals(j);%/current_scale*max(current_frame);
tomwalters@0 46 % plot3(time2bin(sig,time+xoffs),i,val,'Marker','o','MarkerFaceColor',col,'MarkerEdgeColor',col,'MarkerSize',3);
tomwalters@0 47 % end
tomwalters@0 48 % end
tomwalters@0 49
tomwalters@0 50 % then plot all the different connections
tomwalters@0 51 herestrobesproces=strobes.cross_strobes{i};
tomwalters@0 52 herestrobes=herestrobesproces.strobe_times;
tomwalters@0 53 col=cols(round(i*colscale),:);
tomwalters@0 54 cursize=1;
tomwalters@0 55 nr_here=length(herestrobes);
tomwalters@0 56 for j=1:nr_here
tomwalters@0 57 count=0;
tomwalters@0 58 for k=1:nr_sources
tomwalters@0 59 target_chan_act=herestrobesproces.source_cross_channel_value(j,k);
tomwalters@0 60 if target_chan_act>1
tomwalters@0 61 colnr=round(k*length(hsv)/nr_sources);
tomwalters@0 62 colnr=min(colnr,length(hsv));
tomwalters@0 63 colnr=max(colnr,1);
tomwalters@0 64 col=cols(colnr,:);
tomwalters@0 65 cursize=target_chan_act/100;
tomwalters@0 66 else
tomwalters@0 67 continue
tomwalters@0 68 end
tomwalters@0 69 time=herestrobes(j);
tomwalters@0 70 if time>start_time & time<start_time+duration
tomwalters@0 71 offx=(stop_time-start_time)/80*count;
tomwalters@0 72 count=count+1;
tomwalters@0 73 val=herestrobesproces.strobe_vals(j)/temp_scale;%/current_scale*max(current_frame);
tomwalters@0 74 if strcmp(handles.screen_modus,'paper')
tomwalters@0 75 p=plot3(time2bin(sig,time+offx),i,val,'Marker','o','MarkerSize',4,'MarkerFaceColor','k','MarkerEdgeColor','k','LineWidth',1);
tomwalters@0 76 else
tomwalters@0 77 plot3(time2bin(sig,time+offx),i,val,'Marker','o','MarkerFaceColor','r','MarkerEdgeColor','w','MarkerSize',cursize);
tomwalters@0 78 end
tomwalters@0 79 end
tomwalters@0 80 end
tomwalters@0 81 end
tomwalters@0 82 else % only one set of strobes
tomwalters@0 83 herestrobes=strobes{i};
tomwalters@0 84 nr_here=length(herestrobes.strobes);
tomwalters@0 85 % marker_dot_size=4;
tomwalters@0 86 for j=1:nr_here
tomwalters@0 87 time=herestrobes.strobes(j);
tomwalters@0 88 if time>start_time & time<stop_time
tomwalters@0 89 % if j<=length(herestrobes.strobe_vals)
tomwalters@0 90 val=herestrobes.strobe_vals(j);%/current_scale*max(current_frame);
tomwalters@0 91 %if strcmp(handles.screen_modus,'paper')
tomwalters@0 92 % p=plot3(time2bin(sig,time),i,val/temp_scale,'Marker','o','MarkerSize',4,'MarkerFaceColor','k','MarkerEdgeColor','k','LineWidth',1);
tomwalters@0 93 %else
tomwalters@0 94 plot3(time2bin(sig,time),i,val,'Marker','o','MarkerSize',marker_dot_size,'MarkerFaceColor','r','MarkerEdgeColor','r','LineWidth',1);
tomwalters@0 95 %end
tomwalters@0 96 % end
tomwalters@0 97 end
tomwalters@0 98 end
tomwalters@0 99 end % one or two strobe sources
tomwalters@0 100 end
tomwalters@0 101 zmin=0;zmax=max(current_frame)/current_scale;
tomwalters@0 102
tomwalters@0 103 % TCW AIM 2006
tomwalters@0 104 % if hand_scaling == 1
tomwalters@0 105 set(gca,'Zlim',[zmin,1/current_scale]);
tomwalters@0 106 % else
tomwalters@0 107 % set(gca,'Zlim',[zmin,zmax]);
tomwalters@0 108 % end
tomwalters@0 109
tomwalters@0 110 %set(gca,'Zlim',[zmin,zmax]);
tomwalters@0 111 % if strcmp(handles.screen_modus,'paper')
tomwalters@0 112 % par=get(hand,'parent');
tomwalters@0 113 % set(par,'FontSize',12);xlab=get(par,'xlabel');set(xlab,'FontSize',12);ylab=get(par,'ylabel');set(ylab,'FontSize',12);
tomwalters@0 114 % end
tomwalters@0 115
tomwalters@0 116 hold off
tomwalters@0 117