Commit 47f26bec authored by Stefan Liebich Mobil's avatar Stefan Liebich Mobil

few changes to fix colormap

parent 33404ebe
function varargout = meanMagnPhase(varargin)
% mean value for magnitude and phase individually
% INPUT
% in: itaAudio to take mean from
% mode: mode for taking the mean over magnitude and phse
% 0: no unwrap
% 1: unwrap without reference
% 2: unwrap with reference at 100 Hz
% 3: align but no unwrap (more complex, but more accurate)
% Author: Stefan Liebich (IKS) -- Email: liebich@iks.rwth-aachen.de
% Created: 21-Jan-2019
......@@ -8,12 +15,16 @@ function varargout = meanMagnPhase(varargin)
% This file is part of the ITA-Toolbox. Some rights reserved.
% You can find the license for this m-file in the license.txt file in the ITA-Toolbox folder.
% </ITA-Toolbox>
unwrapRefFreq = 100;
activateUnwrap = 1; % for debug purposes
unwrapRefFreq = 100; % Hz
narginchk(1,1);
narginchk(1,2);
result = varargin{1};
if nargin < 2
mode = 1;
else
mode = varargin{2};
end
if numel(result)>1 %get max over multiple instances and not over channel of each struct
tmp = result(1);
data = zeros(size(tmp.freqData,1),prod(tmp.dimensions),numel(result));
......@@ -24,12 +35,19 @@ if numel(result)>1 %get max over multiple instances and not over channel of each
% calculate min in magn and phase separately
magnMed = squeeze(mean(abs(data),3));
if( activateUnwrap )
idxRefZero = tmp.freq2index(unwrapRefFreq); % get index for 20 Hz to use for unwrap
phaseMed = squeeze(mean(ita_unwrap(angle(data),'refZeroBin',idxRefZero),3));
% phaseMed = squeeze(mean(ita_align_phase(angle(data)),3));
else
phaseMed = squeeze(mean(angle(data),3));
% phase depending on mode
switch mode
case 0 % pure angle
phaseMed = squeeze(mean(angle(data),3));
case 1 % unwrap
phaseMed = squeeze(mean(unwrap(angle(data)),3));
case 2 % unwrap with reference 100 Hz
idxRefZero = tmp.freq2index(unwrapRefFreq); % get index for 20 Hz to use for unwrap
phaseMed = squeeze(mean(ita_unwrap(angle(data),'refZeroBin',idxRefZero),3));
case 3 % align
alignedPhase = ita_align_phase(angle(data));
phaseMed = squeeze(mean(alignedPhase,3));
otherwise
end
% combine min values in magn and phase
......@@ -39,12 +57,20 @@ else % max over channels
% calculate min in magn and phase separately
magnMed = squeeze(mean(abs(result.freqData),2));
if( activateUnwrap )
idxRefZero = result.freq2index(unwrapRefFreq); % get index for 20 Hz to use for unwrap
phaseMed = squeeze(mean(ita_unwrap(angle(result.freqData),'refZeroBin',idxRefZero),2));
% phaseMed = squeeze(mean(ita_align_phase(angle(result.freqData)),2));
else
phaseMed = squeeze(mean(angle(result.freqData),2));
% phase depending on mode
switch mode
case 0 % pure angle
phaseMed = squeeze(mean(angle(result.freqData),2));
case 1 % unwrap
phaseMed = squeeze(mean(unwrap(angle(result.freqData)),2));
case 2 % unwrap with reference 100 Hz
idxRefZero = result.freq2index(unwrapRefFreq); % get index for 20 Hz to use for unwrap
phaseMed = squeeze(mean(ita_unwrap(angle(result.freqData),'refZeroBin',idxRefZero),2));
case 3 % align
alignedPhase = ita_align_phase(angle(result.freqData));
phaseMed = squeeze(mean(alignedPhase,2));
otherwise
end
% combine min values in magn and phase
......
function rgb = ita_colormap
function rgb = ita_colormap(numentries)
% enhancement of the artemis scale, increasing lightness with increasing value -> ideal for color and b&W plots
if nargin < 1 % SL additional parameter for number of entries
numentries = 64;
end
x = linspace(0,1,64);
rgb = artemis;
x = linspace(0,1,numentries);
rgb = artemis(numentries);
for idr = 1:20
wb = sqrt(sum(rgb.^2,2))/sqrt(3);
......@@ -24,7 +26,6 @@ for idr = 1:20
end
rgb(rgb<0) = 0;
end
......
......@@ -66,7 +66,7 @@ matlabdefaults = ita_set_plot_preferences; %#ok<NASGU> %set ita toolbox preferen
sArgs = struct('pos1_data','itaSuper','nodb',true,'unwrap',false,'wrapTo360',false,'figure_handle',[],'axes_handle',[],'linfreq','off','linewidth',ita_preferences('linewidth'),...
'fontname',ita_preferences('fontname'), 'xlim',[],'ylim',[],'axis',[],'aspectratio',[],'hold','off','precise',true,'ylog',false,'plotargs',[],...
'align',0,'alignFreq', -1,'onlyAlignPhase',0,...
'unwrapRefZeroFreq', -1,'colormap',[]);
'colormap',[]);
[data, sArgs] = ita_parse_arguments(sArgs, varargin);
if numel(data) > 1
......
......@@ -106,7 +106,7 @@ else
if sArgs.unwrap == 1 && sArgs.alignFreq == -1 && sArgs.align == 0
plotData = unwrap(angle(data.freqData(bin_indices,:)),[],1) .* 180/pi;
phase_str = 'Unwrapped Phase';
elseif sArgs.unwrap == 1 && sArgs.align
elseif sArgs.unwrap == 1 && ( sArgs.align || sArgs.alignFreq > 0)
if sArgs.alignFreq > 0
idxRefZero = data.freq2index(sArgs.alignFreq); % get index to frequency for aligning
else
......@@ -169,6 +169,12 @@ if ~sArgs.linfreq
else
lnh = plot(bin_vector,plotData,'LineWidth',sArgs.linewidth);
end
if sArgs.linfreq %SL: bugfix
set(sArgs.axes_handle,'XScale','linear');
else
set(sArgs.axes_handle,'XScale','log');
end
axh = get(fgh,'CurrentAxes');
setappdata(axh,'ChannelHandles',lnh);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment