comparison userProgramsTim/plotIFRAN.m @ 38:c2204b18f4a2 tip

End nov big change
author Ray Meddis <rmeddis@essex.ac.uk>
date Mon, 28 Nov 2011 13:34:28 +0000
parents
children
comparison
equal deleted inserted replaced
37:771a643d5c29 38:c2204b18f4a2
1 function plotIFRAN(data_matrix,start_time,end_time,sfreq,BFlist,plothandle)
2
3 %function that produces a plot similar to the plots in Secker-Walker, JASA
4 %1990 Fig.2 (Neurograms) from a IFRAN data matrix
5 %Tim Jürgens, January 2011
6
7 %plot 50ms right from the middle of the signal
8 time_axis = [0:1/sfreq:(size(data_matrix,2)-1)/sfreq];
9 %start_time = size(data_matrix,2)/2/sfreq-0.025; %start time to plot in s
10 %temporal_length = min([0.05 size(data_matrix,2)/sfreq]); %length to plot in s, at least 50ms or the length of the stimulus
11 [tmp, start_time_index] = min(abs(start_time-time_axis));
12 %end_time = start_time+temporal_length;
13 [tmp, end_time_index] = min(abs(end_time-time_axis));
14
15
16 %smoothing using a 4-point hamming window
17 hamm_window = hamming(4);
18 for iCounter = 1:size(data_matrix,1)
19 for jCounter = 2:length(time_axis)-2 %start with 2 and end with 2 samples
20 %less the length of time_axis in order not to get in conflict with the length of
21 %the hamm_window
22 smoothed_data_matrix(iCounter,jCounter-1) = ...
23 data_matrix(iCounter,(jCounter-1):(jCounter+2))*hamm_window./sum(hamm_window);
24 end
25 end
26
27 smoothed_time_axis = time_axis(2:end-2);
28
29 if ~exist('plothandle'), plothandle=figure; end
30
31 verticalshift = 1000; %vertical shift of single time series in z-coordinate units
32 Tickvector = [];
33 TickLabels = [];
34 for iCounter = 1:size(data_matrix,1)
35 set(gcf,'Currentaxes',plothandle);
36
37 %multiply by 1000 to set abscissa to ms units
38 verticalposition = -verticalshift*(iCounter-1);
39 plot(1000.*smoothed_time_axis(start_time_index:end_time_index), ...
40 smoothed_data_matrix(size(data_matrix,1)-iCounter+1,start_time_index:end_time_index)+verticalposition, ...
41 'k','LineWidth',0.5);
42 xlim([1000*start_time 1000*end_time]);
43 if mod(iCounter,5) == 1 %set best frequency as a label every 5 channels
44 Tickvector = [Tickvector verticalposition];
45 TickLabels = [TickLabels; BFlist(size(data_matrix,1)-iCounter+1)];
46 end
47 hold on;
48 end
49 set(gca,'yTick',Tickvector(end:-1:1),'yTickLabel',num2str(TickLabels(end:-1:1),'%4.0f'));
50 ylabel('Best Frequency of Filter (Hz)');
51 xlabel('Stimulus Time (ms)');
52 set(gca,'YLim',[-(size(data_matrix,1))*verticalshift verticalshift*1.5]);
53 box on;
54 hold off;