# length of freq vector in freqanalysis

Sameer Walawalkar sameer at ANDREW.CMU.EDU
Tue Apr 10 18:40:55 CEST 2007

```Hello,

I find that freqanalysis  (cfg.method = mtmfft) generates two different
.freq vectors (different lengths, but spanning the correct [min max] as
indicated by cfg.foilim) for two different datasets passed with same cfg
(but one dataset has more time points than the other).

Plotting the power spectra of the two datasets simultaneously using
singleplotER works just fine, but multiplotER  shows one spectrum spanning
smaller range than the other. Funnily, it is the frequency distribution
with the larger .freq vector which is graphed smaller.

Is there some way I can specify not only the frequency range but also the
number of frequency points to be generated?

The details are given below.

1> re: freqanalysis
I use the same cfg structure (given below) to pass two datasets to
freqanalysis. Yet the frequency vectors for each dataset has very
different lengths.  I wonder if the different time lengths of each set
make a difference.

cfg = [];
cfg.ouput='powandcsd';
cfg.method='mtmfft';
cfg.keeptrials='no';
cfg.tapsmofrq=4;
cfg.foilim =[30 90];
cfg.channel = 'MEG'  ;
cfg.channelcmb = {'MEG' 'MEG'};

pre1 = -.300  ;
pre2 = -.100 ;
post1 = .000 ;
post2 = .500 ;
(this line tells my defined function Breakdata to pass on only data
between times 300msec  to 100 msec before event and from event to 500 msec
after.

[data_pre, data_post]  = Breakdata(data, pre1, pre2, post1, post2)
freq_pre = freqanalysis(cfg,data_pre);
freq_post = freqanalysis(cfg,data_post);

fd_pre = freqdescriptives([], freq_pre)
fd_post = freqdescriptives([], freq_post)

In the above line Breakdata is a function I have written (I know I could
use TFRs to do the same, but I had already written the function and have
not yet had time to consider the other option).

Now, my question is,
>> size(freq_pre.freq)

ans =

1    13

>> size(freq_post.freq)

ans =

1	31

Why the difference? (they do however span the interval [30 90].).
Needless to mention, fd_pre and fd_post are also effected.

2>re: multiplot.
I use
cfg = [];
cfg.xparam = 'freq';
cfg.zparam = 'cohspctrm';
cfg.zlim = [0 1e-27];
cfg.channel = 'all';
cfg.cohrefchannel = 'MEG1833';
cfg.layout = 'NM306mag.lay';
multiplotER(cfg, fd_pre,fd_post)

I would expect the plotting would not be affected as both datasets have
their frequency vector noted for the x-axis. Yet, the graph of the first
dataset is 1/3rd as long on the plot.

How can I fix this? (Incidently, singleplotER works fine for the power
spectrum ).