annotate aim-mat/tools/saimovie.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 % tool
tomwalters@0 2 %
tomwalters@0 3 % INPUT VALUES:
tomwalters@0 4 %
tomwalters@0 5 % RETURN VALUE:
tomwalters@0 6 %
tomwalters@0 7 %
bleeck@3 8 % This external file is included as part of the 'aim-mat' distribution package
bleeck@3 9 % (c) 2011, University of Southampton
bleeck@3 10 % Maintained by Stefan Bleeck (bleeck@gmail.com)
bleeck@3 11 % download of current version is on the soundsoftware site:
bleeck@3 12 % http://code.soundsoftware.ac.uk/projects/aimmat
bleeck@3 13 % documentation and everything is on http://www.acousticscale.org
tomwalters@0 14
tomwalters@0 15 function saimakeaimmovie(varargin)
tomwalters@0 16
tomwalters@0 17 temp_sound_file_name='temp_sound.wav'; % must be the same as in getaiffs!!!
tomwalters@0 18
tomwalters@0 19 if nargin<2 % only one parameter -> read file
tomwalters@0 20 if size(varargin)==1
tomwalters@0 21 makefilename=varargin{1};
tomwalters@0 22 else
tomwalters@0 23 makefilename='lastrun.genmovie';
tomwalters@0 24 end
tomwalters@0 25 % fprintf('movie is produced from file %s from aifffile "makemovie_temp.aif"\n!',makefilename);
tomwalters@0 26 % fprintf('movie is produced from file ''%s''\n',makefilename);
tomwalters@0 27 else
tomwalters@0 28 makefilename='lastrun.genmovie';
tomwalters@0 29 generateparameterfile(makefilename,varargin);
tomwalters@0 30 end
tomwalters@0 31 arguments=readparameterfile(makefilename);
tomwalters@0 32
tomwalters@0 33
tomwalters@0 34 str_moviefile=getargument(arguments,'moviefile');
tomwalters@0 35 str_aifffile=getargument(arguments,'aifffile');
tomwalters@0 36 str_movie_duration=getargument(arguments,'movie_duration');
tomwalters@0 37 str_movie_start_time=getargument(arguments,'movie_start_time');
tomwalters@0 38 str_AuditoryImageFormat=getargument(arguments,'AuditoryImageFormat');
tomwalters@0 39 str_TimeIntervalUnits=getargument(arguments,'TimeIntervalUnits');
tomwalters@0 40 str_colormap=getargument(arguments,'colormap');
tomwalters@0 41 str_minimum_time_interval=getargument(arguments,'minimum_time_interval');
tomwalters@0 42 str_maximum_time_interval=getargument(arguments,'maximum_time_interval');
tomwalters@0 43 str_sound_sample_rate=getargument(arguments,'sound_sample_rate');
tomwalters@0 44 str_sound_endian=getargument(arguments,'sound_endian');
tomwalters@0 45 str_linewidth=getargument(arguments,'linewidth');
tomwalters@0 46 str_echo=getargument(arguments,'echo');
tomwalters@0 47 str_showtime=getargument(arguments,'showtime');
tomwalters@0 48 str_showtextname=getargument(arguments,'showtextname');
tomwalters@0 49 str_showtexttime=getargument(arguments,'showtexttime');
tomwalters@0 50 str_plotscale=getargument(arguments,'plotscale');
tomwalters@0 51 str_profile_scale=getargument(arguments,'profile_scale');
tomwalters@0 52 str_producemovie=getargument(arguments,'producemovie');
tomwalters@0 53
tomwalters@0 54 % data originally used in readaiff, but needed here also:
tomwalters@0 55 str_framespersecond=getargument(arguments,'framespersecond');
tomwalters@0 56 str_sai_picturespersecond=getargument(arguments,'sai_picturespersecond');
tomwalters@0 57 str_nap_picturespersecond=getargument(arguments,'nap_picturespersecond');
tomwalters@0 58 str_model=getargument(arguments,'modelfile');
tomwalters@0 59 str_soundcommand=getargument(arguments,'soundfile');
tomwalters@0 60
tomwalters@0 61 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 62
tomwalters@0 63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 64 % if a movie is produced at all, or just the sais
tomwalters@0 65 if isempty(str_producemovie) %
tomwalters@0 66 producemovie='sai_and_nap';
tomwalters@0 67 else
tomwalters@0 68 producemovie=str_producemovie;
tomwalters@0 69 end
tomwalters@0 70
tomwalters@0 71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 72 % scale the amplitude of the whole picture up
tomwalters@0 73 if isempty(str_plotscale) % default frames per second
tomwalters@0 74 plot_scale=1;
tomwalters@0 75 else
tomwalters@0 76 eval(sprintf('plot_scale=%s;',str_plotscale));
tomwalters@0 77 end
tomwalters@0 78
tomwalters@0 79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 80 % scale the amplitude of the profiles (only when profiles are plotted of course)
tomwalters@0 81 if isempty(str_profile_scale) % default frames per second
tomwalters@0 82 profile_scale=1;
tomwalters@0 83 else
tomwalters@0 84 eval(sprintf('profile_scale=%s;',str_profile_scale));
tomwalters@0 85 end
tomwalters@0 86
tomwalters@0 87 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 88 % show time and number of frame
tomwalters@0 89 if isempty(str_showtime) % default frames per second
tomwalters@0 90 showtime=1;
tomwalters@0 91 else
tomwalters@0 92 if strcmp(str_showtime,'off')
tomwalters@0 93 showtime=0;
tomwalters@0 94 else
tomwalters@0 95 showtime=1;
tomwalters@0 96 end
tomwalters@0 97 end
tomwalters@0 98
tomwalters@0 99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 100 % frames per second
tomwalters@0 101 if isempty(str_framespersecond) % default frames per second
tomwalters@0 102 framespersecond=12;
tomwalters@0 103 else
tomwalters@0 104 eval(sprintf('framespersecond=%s;',str_framespersecond));
tomwalters@0 105 end
tomwalters@0 106 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 107 % pictures per second
tomwalters@0 108 if isempty(str_sai_picturespersecond) % default every ms
tomwalters@0 109 sai_picturespersecond=1000;
tomwalters@0 110 else
tomwalters@0 111 eval(sprintf('sai_picturespersecond=%s;',str_sai_picturespersecond));
tomwalters@0 112 end
tomwalters@0 113 if isempty(str_nap_picturespersecond) % default every ms
tomwalters@0 114 nap_picturespersecond=1000;
tomwalters@0 115 else
tomwalters@0 116 eval(sprintf('nap_picturespersecond=%s;',str_nap_picturespersecond));
tomwalters@0 117 end
tomwalters@0 118
tomwalters@0 119 if isempty(str_moviefile) % default name of the movie
tomwalters@0 120 [dumy_path,tempmodelname,ext,versn] = fileparts(str_model);
tomwalters@0 121 [dumy_path,tempsoundname,ext,versn] = fileparts(str_soundcommand);
tomwalters@0 122 moviefile=sprintf('soundfile_%s_model_%s.mov',tempsoundname,tempmodelname);
tomwalters@0 123 else
tomwalters@0 124 [dumy_path,tempmodelname,ext,versn] = fileparts(str_moviefile);
tomwalters@0 125 if strcmp(ext,'')
tomwalters@0 126 moviefile=sprintf('%s.mov',str_moviefile);
tomwalters@0 127 else
tomwalters@0 128 moviefile=str_moviefile;
tomwalters@0 129 end
tomwalters@0 130 end
tomwalters@0 131 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 132 % sound-file. can be a command or a file
tomwalters@0 133 if isempty(str_soundcommand) %
tomwalters@0 134 error('soundcommand must be given');
tomwalters@0 135 else
tomwalters@0 136 soundcommand=str_soundcommand;
tomwalters@0 137 end
tomwalters@0 138
tomwalters@0 139
tomwalters@0 140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 141 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 142 % construct the aiff-file with a call to the dsam-routine:
tomwalters@0 143
tomwalters@0 144 % if aifffile is given from a previous run, than simply load it:
tomwalters@0 145 if ~isempty(str_aifffile)
tomwalters@0 146 allframes=SBReadAiff(str_aifffile); % returns all info in a struct
tomwalters@0 147 else
tomwalters@0 148 allframes=getaiffs(makefilename);
tomwalters@0 149 end
tomwalters@0 150 complete_nap=allframes(1);
tomwalters@0 151 nr_channels=getnrchannels(complete_nap);
tomwalters@0 152 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 153
tomwalters@0 154
tomwalters@0 155 % grafix=1;
tomwalters@0 156 select_channels=1:nr_channels;
tomwalters@0 157 select_single_channels=3;
tomwalters@0 158
tomwalters@0 159
tomwalters@0 160 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 161 % read the sound command and transfere the data to the buffer
tomwalters@0 162 if ~isempty(str_movie_duration) % default frames per second
tomwalters@0 163 eval(sprintf('movie_duration=%s;',str_movie_duration));
tomwalters@0 164 eval(sprintf('movie_start_time=%s;',str_movie_start_time));
tomwalters@0 165 [sounddata,samplerate,bits,endian]=producesounddata(soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian,movie_start_time,movie_duration);
tomwalters@0 166 else
tomwalters@0 167 movie_start_time=0;
tomwalters@0 168 [sounddata,samplerate,bits,endian]=producesounddata(soundcommand,temp_sound_file_name,str_sound_sample_rate,str_sound_endian);
tomwalters@0 169 movie_duration=length(sounddata)/samplerate;
tomwalters@0 170 end
tomwalters@0 171 sampletime=1/samplerate;
tomwalters@0 172 % the duration of the whole video
tomwalters@0 173 videolength=size(sounddata,1)/samplerate;
tomwalters@0 174 % so long is one picture:
tomwalters@0 175
tomwalters@0 176 if ~strcmp(producemovie,'sai_only')
tomwalters@0 177 sai_pictureduration=1/sai_picturespersecond;
tomwalters@0 178 else
tomwalters@0 179 sai_pictureduration=1/framespersecond;
tomwalters@0 180 end
tomwalters@0 181 % so many frames is the video size in the end:
tomwalters@0 182 nr_sai_pictures=floor(videolength/sai_pictureduration);
tomwalters@0 183
tomwalters@0 184
tomwalters@0 185 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 186 % start processing the data
tomwalters@0 187 % first: 2DAT on the nap:
tomwalters@0 188 clear napoptions;
tomwalters@0 189 napoptions.time_constant_factor=6; %makes the time constant for the time adaption longer
tomwalters@0 190 % napoptions.frequency_constant_factor=0.8; % the influence of the neighboring channels
tomwalters@0 191 napoptions.frequency_constant_factor=0.0; % the influence of the neighboring channels
tomwalters@0 192
tomwalters@0 193 disp('calculating 2D adaptive threshold...');
tomwalters@0 194 sharpnap=twoDat(complete_nap,napoptions); % two dimensional adaptive thresholding
tomwalters@0 195
tomwalters@0 196 % strobeoptions
tomwalters@0 197 strobeoptions.strobe_decay_time=0.02; % in this time the strobe threshold decreases to 0
tomwalters@0 198 strobeoptions.parabel_heigth=1.2; % times the nap height at that point
tomwalters@0 199 % strobeoptions.parabel_width=0.01; % ms
tomwalters@0 200 strobeoptions.parabel_width_in_cycles=1.5; % cycles
tomwalters@0 201 strobeoptions.influence_nap_heigth=0; % influcence of the height of the nap at the point, where the strobe was elicited
tomwalters@0 202 strobeoptions.nr_cyclyes_to_wait=1.5; % wait a little longer then once cycle for the real strobe
tomwalters@0 203 strobeoptions.select_channels=select_channels;
tomwalters@0 204
tomwalters@0 205 disp('calculating strobes...');
tomwalters@0 206 [allstrobeprocesses,allthresholds]=findstrobes(sharpnap,strobeoptions);
tomwalters@0 207
tomwalters@0 208
tomwalters@0 209 % figure(1);clf
tomwalters@0 210 % plotwithstrobes(sharpnap,allstrobeprocesses);
tomwalters@0 211 %
tomwalters@0 212 % return
tomwalters@0 213 if strcmp(producemovie,'sai_and_nap')
tomwalters@0 214 step=1/nap_picturespersecond;
tomwalters@0 215 graphic_times=movie_start_time:step:movie_start_time+movie_duration;
tomwalters@0 216 maxheight=5;
tomwalters@0 217 maxnap=max(sharpnap);
tomwalters@0 218 next_nap_picture=step;
tomwalters@0 219 current_graphic=1;
tomwalters@0 220 f1=figure(1);clf;
tomwalters@0 221 set(f1,'position',[ 640 1 640 400])
tomwalters@0 222 else
tomwalters@0 223 next_nap_picture=inf; % never this graphic
tomwalters@0 224 end
tomwalters@0 225
tomwalters@0 226
tomwalters@0 227
tomwalters@0 228 % set a variable for the current starting time of each frame for plotting
tomwalters@0 229 for i=1:nr_sai_pictures
tomwalters@0 230 start_times(i)=(i-1)*sai_pictureduration+movie_start_time;
tomwalters@0 231 sai_graphic_times(i)=start_times(i)+sai_pictureduration-sampletime;
tomwalters@0 232 end
tomwalters@0 233
tomwalters@0 234 next_sai_graphic=sai_graphic_times(1);
tomwalters@0 235 current_sai_graphic=1;
tomwalters@0 236
tomwalters@0 237 fprintf('producing stobed image:\n');
tomwalters@0 238 % We start the time at zero:
tomwalters@0 239 current_time=movie_start_time;
tomwalters@0 240 nr_dots=getnrpoints(sharpnap);
tomwalters@0 241 clear saioptions;
tomwalters@0 242 saioptions.start_time=start_times(i);
tomwalters@0 243 saioptions.maxdelay=0.035;
tomwalters@0 244 saioptions.strobe_weight_alpha=1; % alpha parameter in the weightening of the single strobes
tomwalters@0 245 saioptions.phase_adjustment=1.5; % after so many cycles the change of weight takes effect
tomwalters@0 246 saioptions.mindelay_in_cycles=1.5; % so many cycles are not filled in the sai-buffer
tomwalters@0 247 saioptions.buffer_memory_decay=0.04; % time for the buffer to go from 100% to 0
tomwalters@0 248 saioptions.weightthreshold=0.001; % only thresholds bigger than 1%
tomwalters@0 249 if ~strcmp(producemovie,'no')
tomwalters@0 250 saioptions.grafix=1; % no graphical outout during processing
tomwalters@0 251 end
tomwalters@0 252 saioptions.select_channels=select_channels;
tomwalters@0 253 saioptions.const_memory_decay=power(0.5,1/(saioptions.buffer_memory_decay*samplerate)); % the amount per sampletime
tomwalters@0 254 saioptions.signal_start_time=movie_start_time;
tomwalters@0 255
tomwalters@0 256 % construct the starting SAI with zeros
tomwalters@0 257 nrdots_insai=round(saioptions.maxdelay*samplerate);
tomwalters@0 258 svals=zeros(getnrchannels(sharpnap),nrdots_insai);
tomwalters@0 259 fstruct.outputTimeOffset=0;
tomwalters@0 260 fstruct.totalframetime=saioptions.maxdelay;
tomwalters@0 261 current_sai=frame(svals,fstruct,getcf(sharpnap));
tomwalters@0 262 current_sai_struct.data=current_sai;
tomwalters@0 263 for i=select_channels
tomwalters@0 264 if length(allstrobeprocesses{i}.strobes) > 0
tomwalters@0 265 info.next_strobe=allstrobeprocesses{i}.strobes(1); % the next strobe in line
tomwalters@0 266 else
tomwalters@0 267 info.next_strobe=inf; % no strobe
tomwalters@0 268 end
tomwalters@0 269 info.current_strobe_nr=0; % the current number of the strobe which is processed
tomwalters@0 270 info.strobeprocesses=[]; % no active strobes in queue
tomwalters@0 271 info.strobe_adjust_phase=inf; % the next update of weights
tomwalters@0 272 info.was_adjusted=0;
tomwalters@0 273 current_sai_struct.info{i}=info;
tomwalters@0 274 end
tomwalters@0 275
tomwalters@0 276
tomwalters@0 277 if ~strcmp(producemovie,'no')
tomwalters@0 278 MakeQTMovie('start',moviefile);
tomwalters@0 279 MakeQTMovie('size', [640 400]);
tomwalters@0 280 MakeQTMovie('quality', 0.9); % reduces the size
tomwalters@0 281 % only, to know, how many channels we have:
tomwalters@0 282 for i=1:nr_sai_pictures
tomwalters@0 283 fprintf('*');
tomwalters@0 284 end
tomwalters@0 285 fprintf('\n');
tomwalters@0 286 end
tomwalters@0 287
tomwalters@0 288 for i=1:nr_dots
tomwalters@0 289 % fprintf('*');
tomwalters@0 290 current_time=current_time+sampletime;
tomwalters@0 291 current_sai_struct=updatesai2(sharpnap,current_sai_struct,allstrobeprocesses,saioptions,current_time);
tomwalters@0 292
tomwalters@0 293 if ~strcmp(producemovie,'no')
tomwalters@0 294 if current_time>=next_nap_picture
tomwalters@0 295 if current_graphic<length(graphic_times)
tomwalters@0 296 next_nap_picture=graphic_times(current_graphic+1);
tomwalters@0 297 current_graphic=current_graphic+1;
tomwalters@0 298 else
tomwalters@0 299 next_nap_picture=inf;
tomwalters@0 300 end
tomwalters@0 301 disp_start_time=current_time-0.035;
tomwalters@0 302 if disp_start_time < movie_start_time
tomwalters@0 303 disp_start_time = movie_start_time;
tomwalters@0 304 end
tomwalters@0 305 disp_duration=0.05 ;
tomwalters@0 306 maxtime=getmaximumtime(sharpnap);
tomwalters@0 307 if disp_start_time+disp_duration > maxtime
tomwalters@0 308 disp_start_time = maxtime-disp_duration;
tomwalters@0 309 end
tomwalters@0 310
tomwalters@0 311 plotoptions.sharpnap=sharpnap;
tomwalters@0 312 plotoptions.allthresholds=allthresholds;
tomwalters@0 313 plotoptions.current_sai_struct=current_sai_struct;
tomwalters@0 314 plotoptions.allstrobeprocesses=allstrobeprocesses;
tomwalters@0 315 plotoptions.maxnap=maxnap;
tomwalters@0 316 plotoptions.maxheight=maxheight;
tomwalters@0 317 plotoptions.current_time=current_time;
tomwalters@0 318 plotoptions.saioptions=saioptions;
tomwalters@0 319 plotoptions.select_channels=select_single_channels;
tomwalters@0 320 plotoptions.disp_start_time=disp_start_time;
tomwalters@0 321 plotoptions.disp_duration=disp_duration;
tomwalters@0 322
tomwalters@0 323 plotoptions=doplot(plotoptions);
tomwalters@0 324 end
tomwalters@0 325 if current_time > next_sai_graphic
tomwalters@0 326 fprintf('*');
tomwalters@0 327 current_sai_struct.data=setcurrentframestarttime(current_sai_struct.data,current_time);
tomwalters@0 328 all_finished_frames(current_sai_graphic)=current_sai_struct.data;
tomwalters@0 329 if current_sai_graphic<length(sai_graphic_times)
tomwalters@0 330 current_sai_graphic=current_sai_graphic+1;
tomwalters@0 331 next_sai_graphic=sai_graphic_times(current_sai_graphic);
tomwalters@0 332 saiplotoptions.bla=0;
tomwalters@0 333
tomwalters@0 334 if strcmp(producemovie,'sai_and_nap')
tomwalters@0 335 saiplotoptions=plotsai(current_sai_struct,current_time,saiplotoptions);
tomwalters@0 336 elseif strcmp(producemovie,'dualprofile')
tomwalters@0 337 plotsaiprofiles(current_sai_struct,current_time);
tomwalters@0 338 else
tomwalters@0 339 plotsaionly(current_sai_struct,current_time);
tomwalters@0 340 end
tomwalters@0 341 else
tomwalters@0 342 next_sai_graphic=inf;
tomwalters@0 343 end
tomwalters@0 344 MakeQTMovie('addframe'); % and add it to the movie
tomwalters@0 345 % fprintf('\n');
tomwalters@0 346 end
tomwalters@0 347 end
tomwalters@0 348 end
tomwalters@0 349
tomwalters@0 350 if ~strcmp(producemovie,'no')
tomwalters@0 351 % add one, to fill the last picture (the sound is longer than n*nr_frames)
tomwalters@0 352 MakeQTMovie('addframe');
tomwalters@0 353 MakeQTMovie('framerate', framespersecond);
tomwalters@0 354 if strcmp(producemovie,'sai_only')
tomwalters@0 355 MakeQTMovie('addsound',sounddata,samplerate);
tomwalters@0 356 end
tomwalters@0 357
tomwalters@0 358 MakeQTMovie('finish');
tomwalters@0 359 MakeQTMovie('cleanup');
tomwalters@0 360 end
tomwalters@0 361
tomwalters@0 362 return
tomwalters@0 363
tomwalters@0 364
tomwalters@0 365
tomwalters@0 366 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
tomwalters@0 367 function options=doplot(options)
tomwalters@0 368 sharpnap=options.sharpnap;
tomwalters@0 369 current_sai_struct=options.current_sai_struct;
tomwalters@0 370 allthresholds=options.allthresholds;
tomwalters@0 371 allstrobeprocesses=options.allstrobeprocesses;
tomwalters@0 372 maxnap=options.maxnap;
tomwalters@0 373 maxheight=options.maxheight;
tomwalters@0 374 current_time=options.current_time;
tomwalters@0 375 saioptions=options.saioptions;
tomwalters@0 376 select_channels=options.select_channels;
tomwalters@0 377 disp_start_time=options.disp_start_time;
tomwalters@0 378 disp_duration=options.disp_duration;
tomwalters@0 379 if ~isfield(options,'oldhandle1')
tomwalters@0 380 options.oldhandle1=0;
tomwalters@0 381 end
tomwalters@0 382 if ~isfield(options,'oldhandle2')
tomwalters@0 383 options.oldhandle2=0;
tomwalters@0 384 end
tomwalters@0 385
tomwalters@0 386 % Graphic Output
tomwalters@0 387
tomwalters@0 388 if length(select_channels)==1
tomwalters@0 389 saibuffer=getsinglechannel(current_sai_struct.data,select_channels);
tomwalters@0 390 saibuffer=setnrxticks(saibuffer,8);
tomwalters@0 391 sr=getsr(saibuffer);
tomwalters@0 392 nr_active_strobes=length(current_sai_struct.info{select_channels}.strobeprocesses);
tomwalters@0 393 orgsignal=getsinglechannel(sharpnap,select_channels);
tomwalters@0 394 single_channel=getpart(orgsignal,disp_start_time,disp_start_time+disp_duration);
tomwalters@0 395 single_channel=setname(single_channel,getname(saibuffer));
tomwalters@0 396 saibuffer=setname(saibuffer,'SAI');
tomwalters@0 397 saibuffer=setstarttime(saibuffer,0);
tomwalters@0 398 threshold=getsinglechannel(allthresholds,select_channels);
tomwalters@0 399 single_channel=setnrxticks(single_channel,5);
tomwalters@0 400 threshold=getpart(threshold,disp_start_time,current_time);
tomwalters@0 401 strobe_process=options.current_sai_struct.info{select_channels}.strobeprocesses;
tomwalters@0 402
tomwalters@0 403 mysubplot(1,1,1,[0.65 0.1 0.35 0.3]);
tomwalters@0 404 if options.oldhandle1~=0
tomwalters@0 405 delete(options.oldhandle1);
tomwalters@0 406 end
tomwalters@0 407 options.oldhandle1=gca;
tomwalters@0 408 plot(saibuffer);
tomwalters@0 409 set(gca,'DrawMode','fast');
tomwalters@0 410 set(gca,'NextPlot','add');
tomwalters@0 411 ylabel('');
tomwalters@0 412 if max(saibuffer)>maxheight
tomwalters@0 413 maxheight=maxheight*1.1;
tomwalters@0 414 end
tomwalters@0 415 axis([1 getnrpoints(saibuffer),0,maxheight]);
tomwalters@0 416 % text(300,maxheight/1.5,sprintf('sum: %3.2f',sum(saibuffer)));
tomwalters@0 417 text(300,maxheight/2,sprintf('#time: %dms',floor(current_time*1000)));
tomwalters@0 418 text(300,maxheight/2.8,sprintf('#Strobes: %d',nr_active_strobes));
tomwalters@0 419
tomwalters@0 420 mysubplot(1,1,1,[0.65 0.5 0.35 0.3]);
tomwalters@0 421 if options.oldhandle2~=0
tomwalters@0 422 delete(options.oldhandle2);
tomwalters@0 423 end
tomwalters@0 424 options.oldhandle2=gca;
tomwalters@0 425 set(gca,'Xtick',[]);
tomwalters@0 426 set(gca,'Ytick',[]);
tomwalters@0 427 plot(threshold,'g');
tomwalters@0 428 hold on
tomwalters@0 429 plot(single_channel,'-');
tomwalters@0 430 ylabel('');
tomwalters@0 431 if max(single_channel)>maxnap
tomwalters@0 432 maxnap=maxnap*1.1;
tomwalters@0 433 end
tomwalters@0 434 if max(threshold)>maxnap
tomwalters@0 435 maxnap=maxnap*1.1;
tomwalters@0 436 end
tomwalters@0 437 axis([1 getnrpoints(single_channel),0,maxnap]);
tomwalters@0 438 for k=1:length(strobe_process)
tomwalters@0 439 gc=plot(time2bin(single_channel,strobe_process(k).time),strobe_process(k).nap_value,'.r');
tomwalters@0 440 suze=log(200*strobe_process(k).weight)*5;
tomwalters@0 441 suze=max(suze,5);
tomwalters@0 442 set(gc,'MarkerSize',suze);
tomwalters@0 443 end
tomwalters@0 444 drawnow;
tomwalters@0 445 else % end only one channel
tomwalters@0 446 % from here: more then one channel
tomwalters@0 447 % figure(1);clf;
tomwalters@0 448 % partthres=getpart(allthresholds,disp_start_time,current_time);
tomwalters@0 449 % str.plotcolor='g';
tomwalters@0 450 % plot(partthres,str); hold on
tomwalters@0 451 % partnap=getpart(sharpnap,disp_start_time,disp_start_time+disp_duration);
tomwalters@0 452 % plot(partnap); hold on
tomwalters@0 453 %
tomwalters@0 454 % % for k=1:length(strobe_process)
tomwalters@0 455 % % gc=plot(time2bin(single_channel,strobe_process(k).time),strobe_process(k).nap_value,'.r');
tomwalters@0 456 % % suze=log(200*strobe_process(k).weight)*5;
tomwalters@0 457 % % suze=max(suze,5);
tomwalters@0 458 % % set(gc,'MarkerSize',suze);
tomwalters@0 459 % % end
tomwalters@0 460 %
tomwalters@0 461 %
tomwalters@0 462 %
tomwalters@0 463 % sai=current_sai_struct.data;
tomwalters@0 464 % % figure(2);clf;
tomwalters@0 465 % plot(sai);
tomwalters@0 466 %
tomwalters@0 467 % drawnow;
tomwalters@0 468 end
tomwalters@0 469 return
tomwalters@0 470
tomwalters@0 471
tomwalters@0 472
tomwalters@0 473 function options=plotsai(current_sai_struct,current_time,options)
tomwalters@0 474 mysubplot(1,1,1,[-0.05 0 0.7 0.9]);
tomwalters@0 475 gopt.current_frame = current_sai_struct.data;
tomwalters@0 476 gopt.maximum_time_interval = 35;
tomwalters@0 477 gopt.minimum_time_interval= 0;
tomwalters@0 478 gopt.is_log=0;
tomwalters@0 479 gopt.plot_scale=1/5;
tomwalters@0 480 gopt.show_time=1;
tomwalters@0 481 gopt.time_reversed=1;
tomwalters@0 482 gopt.frequency_profile_scale=400;
tomwalters@0 483 gopt.time_profile_scale=0.03;
tomwalters@0 484 gopt.options=options;
tomwalters@0 485 options=AIFrePtiP(gopt);
tomwalters@0 486 drawnow;
tomwalters@0 487 return
tomwalters@0 488
tomwalters@0 489 function plotsaionly(current_sai_struct,current_time)
tomwalters@0 490 gopt.current_frame = current_sai_struct.data;
tomwalters@0 491 gopt.maximum_time_interval = 35;
tomwalters@0 492 gopt.minimum_time_interval= 0;
tomwalters@0 493 gopt.is_log=0;
tomwalters@0 494 gopt.plot_scale=1/5;
tomwalters@0 495 gopt.show_time=1;
tomwalters@0 496 gopt.time_reversed=1;
tomwalters@0 497 gopt.frequency_profile_scale=400;
tomwalters@0 498 gopt.time_profile_scale=0.03;
tomwalters@0 499 clf
tomwalters@0 500 AIFrePtiP(gopt);
tomwalters@0 501 drawnow;
tomwalters@0 502 return
tomwalters@0 503
tomwalters@0 504 function plotsaiprofiles(current_sai_struct,current_time)
tomwalters@0 505 gopt.current_frame = current_sai_struct.data;
tomwalters@0 506 gopt.frequency_profile_scale=0.002;
tomwalters@0 507 gopt.time_profile_scale=0.01;clf
tomwalters@0 508 combFrePtiP(gopt);
tomwalters@0 509 drawnow;
tomwalters@0 510 return