<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
Hi Cihan,
<div class=""><br class="">
</div>
<div class="">Thanks for your reply.</div>
<div class=""><br class="">
</div>
<div class="">I am still somewhat confused by your reply, because I don’t see why (at least if indeed you agree to saying that you want to achieve my suggested scenario 1) you would need to have the neighbourhood matrix to be time variant? If you want the spatial
 data points to be included for the clustering algorithm to vary over time, it would suffice to mask out the non-relevant data points. If it’s done in a way that these get a value such that the clusterthreshold is not exceeded, they will never contribute to
 the clustering. I don’t think that this is to be addressed in clusterstat/findcluster, but needs can be addressed at the level at which the input data to the function is to be defined. One way in which this can be done would be to replace the irrelevant space-time-frequency
 points in the input data by a NaN.</div>
<div class=""><br class="">
</div>
<div class="">Best wishes,</div>
<div class=""><br class="">
</div>
<div class="">Jan-Mathijs</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
</div>
<div class=""><br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 4 Jun 2021, at 13:30, Cihan Dogan <<a href="mailto:cd549@kent.ac.uk" class="">cd549@kent.ac.uk</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div class="WordSection1" style="page: WordSection1; caret-color: rgb(0, 0, 0); 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; -webkit-text-stroke-width: 0px; text-decoration: none;">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class="">Hi Jan,<br class="">
<br class="">
Many thanks for picking this up.<br class="">
<br class="">
From my understanding, currently what enters the clustering is a neighbourhood of electrodes, these are then used throughout the entire time period for clustering. Rather than have a ‘static’ number of channels for the entire time duration, I would like to
 change the channels used in clustering at each time point. I believe this would fall under 1.<br class="">
<br class="">
Currently to make these changes I am working under the following assumptions:<br class="">
<br class="">
<o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class="">--<br class="">
</span><br class="">
From what I gather, to make the changes there are three main MATLAB files,<span class="Apple-converted-space"> </span><b class="">ft_statistics_montecarlo.m</b>,<span class="Apple-converted-space"> </span><b class="">clusterstat.m</b>, and<span class="Apple-converted-space"> </span><b class="">findcluster.m</b>. <span class="Apple-converted-space"> </span><b class="">ft_statistics_montecarlo.m</b><span class=""><br class="">
<br class="">
</span>So the first action is define my connectivity matrix which is of size electrode*electrode where a 1 in matrix indicates if two electrodes are connected. Currently this is done for the static neighbourhood which is defined in cfg.neighbourhood. So I essentially
 I need to create a connectivity matrix for each point in time based on my dynamic ROI.<br class="">
<br class="">
From here there are two statistics that are computed, one for the observed data and randomised data over n permutations, in our case we are using the<span class="Apple-converted-space"> </span><b class="">ft_statfun_indepesampleregrT</b><span class="Apple-converted-space"> </span>function
 to regress against our behavioural variables.<span class=""><o:p class=""></o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class=""><br class="">
</b>The next step is now the clustering where<span class="Apple-converted-space"> </span><b class="">clusterstat.m</b><span class="Apple-converted-space"> </span>is called - we pass in both our observed and random statistics to<b class="">clusterstat.m</b>.
 Using<span class="Apple-converted-space"> </span><b class="">findcluster.m</b><span class="Apple-converted-space"> </span>located in<span class="Apple-converted-space"> </span><b class="">clusterstat.m<span class="Apple-converted-space"> </span></b>we first
 take in the observed data along with the connectivity matrix.<span class="Apple-converted-space"> </span><b class=""><o:p class=""></o:p></b></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<br class="">
Essentially<span class="Apple-converted-space"> </span><b class="">findcluster.m</b><span class="Apple-converted-space"> </span>takes each channel combination to find connected time-frequency clusters from the statistics, from here, we then combine clusters
 that are connected in neighbouring channels to form a large cluster.<span class="Apple-converted-space"> </span><b class="">I believe here is where I should make the changes.<span class="Apple-converted-space"> </span></b><br class="">
<br class="">
--<br class="">
<br class="">
Many thanks,<br class="">
Cihan<o:p class=""></o:p></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class=""><o:p class=""> </o:p></span></div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span class=""><o:p class=""> </o:p></span></div>
<div class="">
<div style="border-style: solid none none; border-top-width: 1pt; border-top-color: rgb(225, 225, 225); padding: 3pt 0cm 0cm;" class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<b class=""><span lang="EN-US" class="">From:</span></b><span lang="EN-US" class=""><span class="Apple-converted-space"> </span>Schoffelen, J.M. (Jan Mathijs) <<a href="mailto:jan.schoffelen@donders.ru.nl" style="color: blue; text-decoration: underline;" class="">jan.schoffelen@donders.ru.nl</a>><span class="Apple-converted-space"> </span><br class="">
<b class="">Sent:</b><span class="Apple-converted-space"> </span>04 June 2021 09:38<br class="">
<b class="">To:</b><span class="Apple-converted-space"> </span>FieldTrip discussion list <<a href="mailto:fieldtrip@science.ru.nl" style="color: blue; text-decoration: underline;" class="">fieldtrip@science.ru.nl</a>><br class="">
<b class="">Cc:</b><span class="Apple-converted-space"> </span>Howard Bowman <<a href="mailto:H.Bowman@kent.ac.uk" style="color: blue; text-decoration: underline;" class="">H.Bowman@kent.ac.uk</a>>; Palaniappan Ramaswamy <<a href="mailto:R.Palani@kent.ac.uk" style="color: blue; text-decoration: underline;" class="">R.Palani@kent.ac.uk</a>>;
 Cihan Dogan <<a href="mailto:cd549@kent.ac.uk" style="color: blue; text-decoration: underline;" class="">cd549@kent.ac.uk</a>><br class="">
<b class="">Subject:</b><span class="Apple-converted-space"> </span>Re: [FieldTrip] Dynamic ROI for cluster-based permutation statistics<o:p class=""></o:p></span></div>
</div>
</div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div style="border: 1pt solid rgb(156, 101, 0); padding: 2pt;" class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif; line-height: 12pt; background-color: rgb(255, 235, 156);" class="">
<span style="font-size: 10pt; color: rgb(156, 101, 0);" class="">CAUTION:</span><span style="font-size: 10pt;" class=""><span class="Apple-converted-space"> </span>This email originated from outside of the organisation. Do not click links or open attachments
 unless you recognise the sender and know the content is safe.<o:p class=""></o:p></span></div>
</div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Hi Cihan,<span class="Apple-converted-space"> </span><o:p class=""></o:p></div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
I don’t understand the question. Also, I don’t understand what you mean with ‘defining a ROI in cfg.neighbours’.<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Do you want to<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
1. constrain for each time point the set of channels that enter into the clustering algorithm?<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
or <o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
2. use a different spatial neighbourhood matrix for each time point?<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
These are two different things I think.<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Best wishes,<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Jan-Mathijs<o:p class=""></o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
</div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
 <o:p class=""></o:p></div>
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<br class="">
<br class="">
<o:p class=""></o:p></div>
<blockquote style="margin-top: 5pt; margin-bottom: 5pt;" class="">
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
On 19 May 2021, at 13:04, Cihan Dogan <<a href="mailto:CDogan1994@hotmail.co.uk" style="color: blue; text-decoration: underline;" class="">CDogan1994@hotmail.co.uk</a>> wrote:<o:p class=""></o:p></div>
</div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<o:p class=""> </o:p></div>
<div class="">
<div class="">
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
Dear FT,<br class="">
<br class="">
Currently I have an experiment setup to run a cluster-based permutation tests on time-frequency data regressing against some behavioural variables using the<span class="apple-converted-space"> </span><b class="">ft_statfun_indepsampleregrT</b><span class="apple-converted-space"> </span>function.<br class="">
<br class="">
I have a prior precedent for using a particular ROI which I have defined in cfg.neighbours, however, I wish to change this ROI dynamically through time. So essentially for each timestep get the set of neighbours and use this to cluster at that point in time
 rather than apply a static ROI for the entire duration.<br class="">
<br class="">
I was wondering if in FieldTrip it is possible to apply a dynamic region of interest through time? And if not, how much of a job it would be to make this addition myself.<br class="">
<br class="">
I’ve started to look at some of the underlying code such as clusterstat.m and findcluster.m to make this addition /amendment and was wondering if anyone in the community has made such a change.<br class="">
<br class="">
Many thanks,<br class="">
Cihan<o:p class=""></o:p></div>
</div>
<div style="margin: 0cm; font-size: 11pt; font-family: Calibri, sans-serif;" class="">
<span style="font-size: 10.5pt; font-family: Helvetica, sans-serif;" class="">_______________________________________________<br class="">
fieldtrip mailing list<br class="">
</span><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" style="color: blue; text-decoration: underline;" class=""><span style="font-size: 10.5pt; font-family: Helvetica, sans-serif;" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</span></a><span style="font-size: 10.5pt; font-family: Helvetica, sans-serif;" class=""><br class="">
</span><a href="https://urldefense.com/v3/__https:/doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!r6QEjALJvF3ICw4grX-kFnt5Oxhwfbzf7K48sclvFI815gxNw3oIE4PTHQKZw0F1Ppk0d2mC$" style="color: blue; text-decoration: underline;" class=""><span style="font-size: 10.5pt; font-family: Helvetica, sans-serif;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!r6QEjALJvF3ICw4grX-kFnt5Oxhwfbzf7K48sclvFI815gxNw3oIE4PTHQKZw0F1Ppk0d2mC$</span></a></div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>