[FieldTrip] Logarithmic plot of power spectrum

Daniel Hähnke daniel.haehnke at lrz.tu-muenchen.de
Mon Jul 6 18:02:17 CEST 2015


Dear Philip,

you’re right, my question is about the equal spacing of the y-axis.

Thanks for the suggestion! I was just using the same line of thought to change the code of ft_singleplotTFR, but your approach is much safer than messing around with fieldtrip code ;)

All the best,

Daniel
> On 06 Jul 2015, at 17:54, Philipp Ruhnau <mail at philipp-ruhnau.de> wrote:
> 
> 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
> philipp
> 
>  
>  
> %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));
> end
>  
> % 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 <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 <http://sites.google.com/site/obobcimec>
> 
> 
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip

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


More information about the fieldtrip mailing list