<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="">
<div class="">Hi Masoud,</div>
<div class=""><br class="">
</div>
I don’t know why the whole story about neighbours would be relevant to the problem you are facing. Clearly, the error you report:
<div class=""><br class="">
</div>
<div class="">
<blockquote type="cite" class="">
<div dir="ltr" class="">
<div class="">
<div class="">
<div class="gmail_quote">
<div dir="ltr" class="">
<div class="">Error in ft_channelrepair (line 204)<br class="">
cfg.missingchannel = setdiff(cfg.missingchannel, data.label, 'stable');<br class="">
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<div class=""><br class="">
</div>
is caused by an issue with the call to the matlab builtin setdiff function. In other words, there is something unexpected going on with the cfg.missingchannel/data.label combo. Have you tried to debug this by setting a breakpoint on line 204 in ft_channelrepair
 and investigate cfg.missingchannel, and data.label at that point during code execution?</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>
<div class=""><br class="">
</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On 4 Mar 2022, at 12:20, masoud via fieldtrip <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" style="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;" class="">
Hello again. Sorry for bothering you again, I know you are probably very busy but I Would appreciate it if you take your time and answer my question, I have been stuck in it for a while and just a little insight from you might help me overcome this problem.
<div class="">sincerely Masoud<br class="">
<div class=""><br class="">
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">---------- Forwarded message ---------<br class="">
From:<span class="Apple-converted-space"> </span><strong class="gmail_sendername" dir="auto">masoud</strong><span class="Apple-converted-space"> </span><span dir="auto" class=""><<a href="mailto:masoudheshmatibnd@gmail.com" class="">masoudheshmatibnd@gmail.com</a>></span><br class="">
Date: Mon, Feb 28, 2022 at 12:05 PM<br class="">
Subject: a question in neighbours and channelrepair<br class="">
To: <<a href="mailto:fieldtrip@science.ru.nl" class="">fieldtrip@science.ru.nl</a>><br class="">
</div>
<br class="">
<br class="">
<div dir="ltr" class="">Hello, I am currently using the fieldtrip matlab toolbox for preprocessing an EEG dataset. I want to interpolate the CZ channel with its neighbours, all three methods of  ft_prepare_neighbours  function have been used.
<div class="">1- I used the distance method in  ft_prepare_neighbours function but the output is:<br class="">
<div class="">Warning: no neighbours found for CZ<span class="Apple-converted-space"> </span><br class="">
 In ft_prepare_neighbours at line 384<br class="">
<br class="">
Warning: No neighbouring channels were specified or found<span class="Apple-converted-space"> </span><br class="">
 In ft_prepare_neighbours at line 390           (I changed the value of cfg.neighbourdist multiple times but no changes has occurred)<br class="">
</div>
</div>
<div class=""><br class="">
</div>
<div class="">2- The output of the triangulation method is:</div>
<div class="">Error using delaunay<br class="">
At least three input points must be provided to define a triangular mesh.            (how can i provide these inputs?)<br class="">
<br class="">
Error in ft_prepare_neighbours (line 275)<br class="">
    tri = delaunay(prj(:,1), prj(:,2));<br class="">
</div>
<div class=""><br class="">
</div>
<div class="">3- for the template method I made a custom neighbourhood templated with the file that you have shared on github, it works fine and I even tested it through ft_neighbourplot and the answer was still correct, the output of ft_neighbourplot was:</div>
<div class="">Selected channel CZ, which has 8 neighbours: FC1, FCZ, FC2, C1, C2, CP1, CPZ, CP2<br class="">
</div>
<div class="">But when I tried ft_channelrepair function the output was:</div>
<div class="">Error using cell/unique>celluniqueR2012a (line 249)<br class="">
Elements of cell array input A must be character vectors (row vectors of class char).<br class="">
<br class="">
Error in cell/unique (line 142)<br class="">
        [varargout{1:nlhs}] = celluniqueR2012a(varargin{1},logical(flaginds(1:5)));<br class="">
<br class="">
Error in cell/setdiff>cellsetdiffR2012a (line 303)<br class="">
    uA = unique(a,order);<br class="">
<br class="">
Error in cell/setdiff (line 129)<br class="">
        [varargout{1:nlhs}] = cellsetdiffR2012a(varargin{1:2},logical(flaginds(1:3)));<br class="">
<br class="">
Error in ft_channelrepair (line 204)<br class="">
cfg.missingchannel = setdiff(cfg.missingchannel, data.label, 'stable');<br class="">
 <br class="">
the summary of the code is:</div>
<div class="">cfg.channel = {'CZ'};<br class="">
cfg.method = 'template';<br class="">
cfg.layout = 'layout.mat';<br class="">
cfg.template = 'neighbours.mat';<br class="">
</div>
<div class="">neighbours = ft_prepare_neighbours(cfg, data);<br class="">
</div>
<div class="">cfg.badchannel     = 'CZ';    </div>
cfg.method         = 'average';<br class="">
cfg.neighbours     = neighbours;<br class="">
<div class="">data_fixed = ft_channelrepair(cfg,data);</div>
<div class=""><br class="">
</div>
<div class="">Would you mind please helping me with this problem?                                                       <br class="">
</div>
</div>
</div>
</div>
</div>
</div>
<span style="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; float: none; display: inline !important;" class="">_______________________________________________</span><br style="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;" class="">
<span style="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; float: none; display: inline !important;" class="">fieldtrip
 mailing list</span><br style="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;" class="">
<span style="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; float: none; display: inline !important;" class=""><a href="https://mailman.science.ru.nl/mailman/listinfo/fieldtrip" class="">https://mailman.science.ru.nl/mailman/listinfo/fieldtrip</a></span><br style="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;" class="">
<a href="https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!7J-GWl1FRMyylcZ8EyMmtqcsY-npPVZs5F--2d_meEi2wnFb-s_WwEzKCv5mN4elJChFq79C3UeJbYf60OZouaJGALqd-AM_EdayYQ$" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!7J-GWl1FRMyylcZ8EyMmtqcsY-npPVZs5F--2d_meEi2wnFb-s_WwEzKCv5mN4elJChFq79C3UeJbYf60OZouaJGALqd-AM_EdayYQ$</a><span style="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; float: none; display: inline !important;" class=""></span></div>
</blockquote>
</div>
<br class="">
</div>
</body>
</html>