Home > brain, matlab, nirs, programming > Some tips to use wavelet toolbox

## Some tips to use wavelet toolbox

June 13th, 2016

Wavelet toolbox is a useful tool to study hyperscanning data. Many recent publications on NIRS hyperscanning use wavelet coherence to quantify the relationship between two interacting brains (e.g. Baker et al 2016, Nozawa et al 2016). You can see more information about wavelet coherence at http://www.alivelearn.net/?p=1169

wavelet

Here are some tips to use the toolbox:

1. It often takes a long time to run Monte Carlo simulation. You may use ‘mcc’=0 to disable it.

`figure;wtc(signal(:,jj),signal(:,jj+22),'mcc',0);`

2. If you need to get the values of the result (instead of the graphic), you may specify the return value

`[Rsq,period,scale,coi,sig95] = wtc(signal1,signal2,'mcc',0); %Rsq is a complex matrix`

3. If you are only interested in a certain band, you can specify the MaxScale (i.e. ms) parameter. More information at http://www.alivelearn.net/?p=1518

`[Rsq,period,scale,coi,sig95] = wtc(signal1,signal2,'mcc',0, 'ms', 128);`

4. If you are interested in finding the “phase” information (visualized by the arrows), you may use xwt function. The returned value is a complex matrix and you can calculate the phase.

```[Rsq,period,scale,coi,sig95] = xwt(signal(:,jj),signal(:,jj+22));
figure;imagesc(angle(Rsq));```

5. To visualize the power of a single signal, you may use wt, which I personally feel much better than FFT.

`figure;wt(signal(:,jj));`

6. To change the density of the arrows, you may specify the ArrowDensity parameter

`figure;wtc(signal(:,jj),signal(:,jj+22),'mcc',0,'ArrowDensity',[30 30]);`

Do you have any tips? Please let me know.

Xu Cui Categories: Tags:
 Try Stork, a research tool we developed Stork is a publication alert app developed by us at Stanford. As a researcher we often forget to follow up important publications - and it's practically impossible to search many keywords or researchers' names everyday. Stork can help us to search everyday and notifies us when there are new publications/grants. How Stork helped me?

 About the author: Xu Cui is a human brain research scientist in Stanford University. He lives in the Bay Area in the United States. He is also the founder of Stork (smart publication alert app), PaperBox and BizGenius.   He was born in He'nan province, China. He received education in Beijing University(BS), University of Tennessee (Knoxville) (MS), Baylor College of Medicine (PhD) and Stanford University (PostDoc). Read more ...
1. November 18th, 2016 at 07:09 | #1

Dear Cui,

Thanks a lot for your post.
Nevertheless it is not clear to me why we must extract the phases on the cross-correlation and not on the coherence whereas this one is present in the figure. Could you explain ? And then, il web want to extract not only the mean but the dynamic (fluctuation) over time, Is there a solution other than compute a loop?
Thanks a lot !

2. November 24th, 2016 at 21:08 | #2

Hi Dr. Xu,

Thanks so much for sharing all this info on your site! I was hoping to get your insight on an analysis decision with WTC: in your 2012 paper, you analyzed the coherence band at period=64 because there was good reason to think that the activity pattern would be at that frequency (task timing = 7s). What would you suggest for hyperscanning studies that aren’t event related, and are instead one long scanning period over the entirety of the subjects’ interaction? Is there any theory about which frequency band is most important in that case, or is the best option just to average the coherence value over a large frequency band?

Thanks so much!

3. November 28th, 2016 at 11:04 | #3

@Shannon
It’s a good question, and a difficult question! Let me share briefly with you the thought behind the band choice:

When I was doing data analysis and saw the coherence figures, there was an obvious red band in the plot. So this is something interesting, I thought. Then I examined its frequency, and found it is at ~7s, which turned out to be our task frequency. So in our paper we wrote we use the coherence value around the task frequency band.

As you see, we discovered the pattern (red band) first, then try to rationalize this pattern (find a reason choose this band). In the paper it sounds we already have a good reason to choose the band in the first place, but the reality is reverse.

So while I can’t answer your question directly, I do encourage you to see if there are any patterns emerging in your figure.

4. March 16th, 2018 at 07:39 | #4

Dear Dr.Cui:
Thanks so much for sharing these ideas,It’s very useful.
Btw. I want to ask you whether there wiil be some differences between the reult figures that one I did Monte Carlo simulation and one did not(‘mcc’=0).

sincerely ,it really cost so much time to do Monte Carlo! =_=

5. March 16th, 2018 at 08:40 | #5

@Jiaxin Yang
mcc is to calculate the significance value. I never used it because our statistics test were on group level.

6. March 16th, 2018 at 17:57 | #6

@Xu Cui
So kind of you, Thanks a lot！