function data = optostim_compare(date_string, locations_index, first_trace_index, number_cycles, ... traces_plot, locations_plot) if nargin == 0 disp('usage: optostim_compare(''14-Apr-2005'', 7, 8, 4, [2 2 1 1], [3 3 2 2])'); disp('this will read locations from 007, 4 cycles of traces starting from 008'); disp('will plot traces in figure 2 suplot (2,1,1) and mark locations in figure 3 subplot (3,2,2)'); return end locations_index_string = sprintf('%03d', locations_index); locations_file = [date_string '_' locations_index_string '_locations.dat']; locations = load(locations_file) locations_x = zeros(1,0); locations_y = zeros(1,0); total_locations = size(locations,1); for index = 1:total_locations locations_x = [locations_x locations(index,1)]; locations_y = [locations_y locations(index,2)]; end locations_x = repmat(locations_x,2,1); locations_y = repmat(locations_y,2,1); if nargin > 5 figure(locations_plot(1)); subplot(locations_plot(2),locations_plot(3),locations_plot(4)); hold on set(gca, 'DefaultLineMarkerSize',12) plot(locations_x, locations_y, '*'); end if nargin > 4 figure(traces_plot(1)); subplot(traces_plot(2),traces_plot(3),traces_plot(4)); end empty = 1; for cycle = 1:number_cycles first_index = first_trace_index + (cycle-1) * total_locations ; for index = 1:total_locations current_index = first_index + (index-1); current_index_string = sprintf('%03d', current_index); trace_file = [date_string '_' current_index_string '_trace.mat']; trace = load(trace_file); if empty == 1 clear data data.time = trace.time_values; data.values(:,1) = trace.ch0; empty = 0; else data.values(:,(cycle-1)*total_locations+index) = trace.ch0 ; end end if nargin > 4 plot(data.time, data.values(:,(cycle-1)*total_locations+1:cycle*total_locations)) if (cycle == 1) hold on end end end if nargin > 4 grid on hold off end data.number_cycles = number_cycles; data.total_locations = total_locations; data.legend_string = sprintf('%d cycles for locations %s', number_cycles, locations_index_string); data.locations_x = locations_x; data.locations_y = locations_y;