<div dir="auto">Hi Tom, hi all,<div dir="auto"><br></div><div dir="auto">Did you look at CircStat toolbox? </div><div dir="auto"><a href="https://www.jstatsoft.org/article/view/v031i10" target="_blank" rel="noreferrer">https://www.jstatsoft.org/article/view/v031i10</a></div><div dir="auto">As I understood correctly, in your case two sample Kuiper test would be more simplier to perform and perhaps more suitable for the job.</div><div dir="auto"> Alternatively you can calculate the phase locking value(or whatever parameter you are looking at) for each neuron then perform statistic on a group level with adequate parametric test. </div><div dir="auto"><br></div><div dir="auto">Bests</div><div dir="auto"><br></div><div dir="auto">Andras</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl" rel="noreferrer noreferrer" target="_blank">jan.schoffelen@donders.ru.nl</a>> ezt írta (időpont: 2020. dec. 1., K 11:30):<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">



<div style="word-wrap:break-word;line-break:after-white-space">
Dear Tom, dear all,
<div><br>
</div>
<div>Let met reply to this e-mail on the discussion list, ’ter lering ende vermaak’ of - hopefully - many.</div>
<div><br>
</div>
<div><br>
<div><br>
<blockquote type="cite">
<div>Begin forwarded message:</div>
<br>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>From:
</b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">Tom Marshall <<a href="mailto:tom.marshall@psy.ox.ac.uk" rel="noreferrer noreferrer noreferrer" target="_blank">tom.marshall@psy.ox.ac.uk</a>><br>
</span></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>Subject:
</b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif"><b>fieldtrip cluster stats on circular data?</b><br>
</span></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>Date:
</b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">30 November 2020 at 17:50:13 CET<br>
</span></div>
<div style="margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif;color:rgba(0,0,0,1.0)"><b>To:
</b></span><span style="font-family:-webkit-system-font,Helvetica Neue,Helvetica,sans-serif">"Schoffelen, J.M. (Jan Mathijs)" <<a href="mailto:jan.schoffelen@donders.ru.nl" rel="noreferrer noreferrer noreferrer" target="_blank">jan.schoffelen@donders.ru.nl</a>><br>
</span></div>
<br>
<div>
<div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none">
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
Hi JM,<u></u><u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
Is there support for using the fieldtrip cluster-stat functions if the axis I want to cluster over is<span> </span><i>circular</i>?<u></u><u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
<u></u> <u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif">
E.g., say I have spike counts at evenly-spaced phase bins of an oscillation, in two conditions, and I want to test the hypothesis of a difference between the way the spikes phase-cluster in condition A vs condition B. So instead of a time-axis, my data have
 a<span> </span><i>phase</i>-axis that spans 0-2pi.<span> </span><span style="font-size:11pt"><font color="#a811d1">It seems like you could use cluster-based permutation
 to test that hypothesis. In fact you could just hack those data into a fieldtrip structure and plug them into ft_timelockstatistics right away. But ft_timelockstatistics would then not identify clusters if they cross the arbitrary 0/2pi point (because 0 is
 at the beginning of the vector and 2pi at the end); you would be biased towards finding clusters in certain parts of the phase-space and not others by ignoring its circularity.</font></span></div>
</div>
</div>
</blockquote>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<u></u><u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<br>
</div>
<div><br>
</div>
<div>Well, the first thing that comes to mind, is that you could - rather than framing this in terms of a ’statfun’ - look into computing spike-field coherence <a href="https://www.fieldtriptoolbox.org/tutorial/spikefield/" rel="noreferrer noreferrer noreferrer" target="_blank">https://www.fieldtriptoolbox.org/tutorial/spikefield/</a>.
 That is, spike-field coherence (or a similar measure that quantifies the extent to which the timing of point-process are aligned to a preferred phase of an oscillatory process. Then, what you’re after is to statistically compare the spike-field coherence across
 conditions (provided you control for difference in overall spike rate, and the SNR of the oscillation signal.</div>
<div><br>
</div>
<div>Alternatively, and that’s what you asked about, one can think of designing a ’statfun’ that takes the circularity of the independent variable into account. So, in such a context, one would have a bunch of observed (dependent variables) values (e.g. spike
 rate), which are paired with an independent variable (i.e. the phase of an oscillation at which the spike rate was estimated). What I have done in the past was to operationalize your question into a test-statistic that quantified (least-squares) the amplitude
 of a cosine function to the data points, as a function of phase. As a  matter of fact, following up on a related discussion I recently had in house, I just created a FAQ about this: <a href="https://www.fieldtriptoolbox.org/faq/how_can_i_test_whether_a_behavioral_measure_is_phasic/" rel="noreferrer noreferrer noreferrer" target="_blank">https://www.fieldtriptoolbox.org/faq/how_can_i_test_whether_a_behavioral_measure_is_phasic/</a></div>
<div><br>
</div>
<div>In this FAQ I pasted the code for a statufn (ft_statfun_cosinefit), which basically estimates the amplitude of the best-fitting cosine wave, determined by the phase values in the design. By default, it does not care about the optimal phase (although the
 function allows for the constraint to fit a cosine wave with a fixed (specified) phase). One could of course think of other - perhaps more appropriate - test statistics, e.g. the concentration parameter of a von Mises distribution (or the goodness-of-fit of
 a (mixture of) von Mises distributions, which also would address the question as to whether there’s a single preferred phase to begin with).</div>
<div><br>
</div>
<div>The tricky bit would be to think of an appropriate randomization scheme, in order to test a null hypothesis at the first level.</div>
<div><br>
</div>
<div>Yet, in your case, it seems you want to do a second level test (i.e. is the amplitude of the cosinefit in condition A systematically larger than in condition B), so the permutation only comes into play when you start permuting across conditions (in which
 case you can just use a depsamplesT based test statistic.</div>
<div><br>
</div>
<div>Best wishes,</div>
<div><br>
</div>
<div>JM</div>
<div><br>
</div>
<div><br>
</div>
<div>
<blockquote type="cite">
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
So question part A: Has anyone implemented this before and if so is there code for it?</div>
</blockquote>
<div><br>
</div>
Yes, and yes. See above.</div>
<div><br>
<blockquote type="cite">
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
<u></u><u></u></div>
<div style="margin:0cm;font-size:11pt;font-family:Calibri,sans-serif;color:rgb(0,0,0)">
Part B: <wild guesses welcome> Do you think adapting the cluster-stats code would be a big/difficult job for a moderately-experienced coder who knows the fieldtrip source a bit (i.e., me)? Which low-level functions are the right place to start looking? And
 would this be useful for the fieldtrip user base? If so I’d happily try to implement it and submit a PR.</div>
</blockquote>
<br>
</div>
<div>Thanks. Let’s follow this up if you were thinking of another solution as the one outlined above.</div>
<div><br>
</div>
<div><br>
</div>
</div>
</div>
</div>

_______________________________________________<br>
fieldtrip mailing list<br>
<a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a><br>
<a href="https://doi.org/10.1371/journal.pcbi.1002202" rel="noreferrer noreferrer noreferrer noreferrer" target="_blank">https://doi.org/10.1371/journal.pcbi.1002202</a><br>
</blockquote></div>