[FieldTrip] Logarithmic plot of power spectrum

Philipp Ruhnau mail at philipp-ruhnau.de
Mon Jul 6 17:54:07 CEST 2015

Dear Daniel,
you can plot TFRs with logarithmic axes yes, by just using ft_multiplotTFR or ft_singleplotTFR with your logspace TF data
but I think you’re question is about equally spacing the image? 

if so you can ’trick’ fieldtrip, or better matlabs imagesc which fieldtrip uses to plot, by changing the values in the data.freq field to a linearly increasing vector (1:1:numel(data.freq)) and then 
either change the numeric values back in a graphic design software, 
or you change the yticklabels in matlab. see snippets below (just tested this quickly so no guarantee)
hope this helps

%assume you have a dataset 'data' which has a powspectrum field 
% keep the original frequency axis
orig_freq_axis = data.freq;
% now create fake linear axis
data.freq = 1:numel(data.freq);
% plot data with defaults (needs powspectrum)
cfg = [];
cfg.channel = 1:10; % average across first 10 channels
figure; ft_singleplotTFR(cfg, data)
% get the y tick labels, which we can use as index for the original data
yLabels = get(gca, 'YTickLabel');
% find index and create new labels in a cell of strings
newYLabels = [];
for i=1:numel(yLabels)
  ind = str2num(yLabels{i});
  newYLabels{i} = num2str(orig_freq_axis(ind));
% now change the current labels to correct labels
set(gca, 'YTickLabel', newYLabels')

> On 06 Jul 2015, at 16:09, Daniel Hähnke <daniel.haehnke at lrz.tu-muenchen.de <mailto:daniel.haehnke at lrz.tu-muenchen.de>> wrote:
> Dear community,
> I feel like this is a very basic question, but I have not found any solution here.
> I’d like to plot my TFRs with a logarithmic frequency axis, as seen e.g. in http://www.pnas.org/content/106/50/21341.figures-only <http://www.pnas.org/content/106/50/21341.figures-only>
> Is there any way I can do this with fieldtrip? I know that I can logarithmically space the frequencies of interest, so this question is merely about plotting.
> All the best,
> Daniel
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl <mailto:fieldtrip at donders.ru.nl>
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

Philipp Ruhnau, PhD
CIMeC - Center for Mind/Brain Sciences
Università degli Studi di Trento
via delle Regole, 101
38123 Mattarello (TN) - ITALY

phone: +39 0461 28 3083
fax: +39 0461 28 3066
homepage: http://sites.google.com/site/obobcimec

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150706/c5fa2a7f/attachment-0002.html>

More information about the fieldtrip mailing list