<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Hello Jan-Mathijs, <br>
</div>
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
Thanks for the reply; I was traveling and just got back to this...</div>
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
In my initial, very rudimentary preprocessing script, cfg.dataset will take a single neuralynx file:</div>
<div class="elementToProof ContentPasted0" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div class="ContentPasted0 ContentPasted1" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<i><span>      </span>cfg.dataset = 'CSC4.ncs';</i></div>
<div class="ContentPasted0 ContentPasted1" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<i>            cfg.continuous = 'yes';</i></div>
<div class="ContentPasted0 ContentPasted1" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<div class="ContentPasted1"><i>            highpass, lowlass, demean, detrend etc..</i></div>
</div>
<div class="ContentPasted0 ContentPasted1" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<i>            filtContData = ft_preprocessing(cfg);</i></div>
</blockquote>
<div class="elementToProof" style=""></div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="ContentPasted0 ContentPasted2" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br>
</span></div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="ContentPasted0 ContentPasted2" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">But the question was how to reference one channel with another.
<br>
</span></div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="ContentPasted0 ContentPasted2" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"><br>
</span></div>
<div class="elementToProof ContentPasted6" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<span class="ContentPasted0 ContentPasted2" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">I
</span>have been trying to implement your channellist and appenddata suggestion as you describe (below) using channellist = {'CSC1.ncs'; 'CSC2.ncs'; 'CSC3.ncs'} and the subsequent data loop.<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
However, my initial attempt left some errors related to <br>
</div>
<div class="elementToProof ContentPasted3" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<blockquote style="margin-top:0; margin-bottom:0"><i>Error using ft_checkconfig (line 163)</i>
<blockquote style="margin-top:0; margin-bottom:0">
<div class="ContentPasted3"><i>The field cfg.datafile is required</i></div>
<div class="ContentPasted3"><i>The field cfg.headerfile is required</i></div>
</blockquote>
<div><i><br class="ContentPasted3">
</i></div>
<div class="ContentPasted3"><i>Error in ft_preprocessing (line 385)</i></div>
<div class="ContentPasted3"><i><span>      </span>cfg = ft_checkconfig(cfg, 'required',   {'headerfile', 'datafile'});</i></div>
</blockquote>
</blockquote>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
After digging a little further in ft_preprocessing lines 446-447<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<blockquote style="margin-top:0; margin-bottom:0">
<p style="margin-top: 0px; margin-bottom: 0px;font-size:11pt; font-family:Calibri,sans-serif; margin:0">
<i><span class="ContentPasted4" style="font-size: 10pt; font-family: Consolas; color: rgb(0, 128, 19);">% translate the channel groups (like 'all' and 'MEG') into real labels</span><span style="font-size:10pt; font-family:Consolas"></span></i></p>
<p style="margin-top: 0px; margin-bottom: 0px;font-size:11pt; font-family:Calibri,sans-serif; margin:0">
<i><span class="ContentPasted4" style="font-size:10pt; font-family:Consolas">  cfg.channel = ft_channelselection(cfg.channel, hdr);</span></i></p>
<p style="margin-top: 0px; margin-bottom: 0px;font-size:11pt; font-family:Calibri,sans-serif; margin:0">
<i><span class="ContentPasted4" style="font-size:10pt; font-family:Consolas">  assert(~isempty(cfg.channel),
<span class="ContentPasted4" style="color: rgb(167, 9, 245);">'the selection of channels is empty'</span>);</span></i></p>
</blockquote>
</blockquote>
</div>
<div class="elementToProof" style=""><span style="font-family:Calibri,Helvetica,sans-serif">... we rescued the error by resetting
<br>
</span></div>
<div class="elementToProof" style=""><span style="font-family:Calibri,Helvetica,sans-serif">
<blockquote itemscope="" itemtype="https://schemas.microsoft.com/QuotedText" style="border-color: rgb(200, 200, 200); border-left: 3px solid rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<blockquote style="margin-top:0; margin-bottom:0">
<p style="margin-top: 0px; margin-bottom: 0px;font-size:11pt; font-family:Calibri,sans-serif; margin:0">
<span class="ContentPasted4 ContentPasted5" style="font-size:10pt; font-family:Consolas"><i>cfg.channel = CSC1.ncs;</i></span></p>
</blockquote>
</blockquote>
</span></div>
<div class="elementToProof ContentPasted7" style=""><span style="font-family:Calibri,Helvetica,sans-serif">Do you know what is happening? If we use: channellist = {'CSC1.ncs'; 'CSC2.ncs'; 'CSC3.ncs'}</span></div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
<br>
</div>
<div class="elementToProof ContentPasted8" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);">
does the cfg.datafile and cfg.headerfile need to be defined some other way?<br>
</div>
<div id="appendonsend"></div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks, Peter</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size: 11pt; color: rgb(0, 0, 0);" face="Calibri, sans-serif"><b>From:</b> fieldtrip <fieldtrip-bounces@science.ru.nl> on behalf of fieldtrip-request@science.ru.nl <fieldtrip-request@science.ru.nl><br>
<b>Sent:</b> Monday, March 27, 2023 6:00 AM<br>
<b>To:</b> fieldtrip@science.ru.nl <fieldtrip@science.ru.nl><br>
<b>Subject:</b> fieldtrip Digest, Vol 148, Issue 24</font>
<div class="PlainText elementToProof"> <br>
Today's Topics:<br>
</div>
<div class="PlainText elementToProof"><br>
</div>
<div class="PlainText elementToProof">1. Re: re-referencing using neuralynx.csc channels<br>
</div>
<div class="PlainText elementToProof">      (Schoffelen, J.M. (Jan Mathijs))<br>
<br>
Date: Mon, 27 Mar 2023 08:20:40 +0000<br>
From: "Schoffelen, J.M. (Jan Mathijs)"<br>
        <janmathijs.schoffelen@donders.ru.nl><br>
<br>
Hi Peter,<br>
<br>
ft_read_data is a so-called ‘intermediate’ level fieldtrip function and not typically called directly by the casual user.<br>
<br>
I think your use case calls for the following strategy:<br>
<br>
channellist = {‘channel1’;’channel2’;…’channelN’};<br>
for k = 1:numel(channellist)<br>
   cfg.channel = channellist{k}; % or something equivalent, at least instructing the reading function to grab a channel specific file<br>
   data{k} = ft_preprocessing(cfg);<br>
end<br>
<br>
alldata = ft_appenddata([], data{:});<br>
<br>
Once you have the alldata object, you can apply re-referencing. Perhaps indeed this is best done by creating a ‘montage’, and apply it to the data.<br>
<br>
Best wishes,<br>
<br>
Jan-Mathijs<br>
<br>
<br>
<br>
On 23 Mar 2023, at 22:12, Peter Kaskan via fieldtrip <fieldtrip@science.ru.nl<mailto:fieldtrip@science.ru.nl>> wrote:<br>
<br>
Hello,<br>
<br>
I am writing a ft_preprocessing script; I can give it channel1.csc and proceed with filtering, defining trials etc.<br>
<br>
...but, how do I re-reference to another channel?<br>
<br>
Is there a way to use ft_read_data to create a structure with all channels, and then tell it what channel I want to use as a reference?<br>
<br>
Or do I need to create a montage, and how do I do that with n #s of separate neuralynx.csc channels?<br>
<br>
<br>
<br>
Thanks - Peter<br>
<br>
<br>
Peter M. Kaskan, Ph.D.<br>
Assistant Professor<br>
Albert Einstein College of Medicine<br>
Leo M. Davidoff Department of Neurological Surgery<br>
1410 Pelham Parkway South<br>
Kennedy Center Room 429B<br>
Bronx, NY 10461<br>
<br>
phone: 718-430-2763<br>
_______________________________________________<br>
</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt"></span></font></div>
</body>
</html>