[FieldTrip] fieldtrip Digest, Vol 148, Issue 24

Schoffelen, J.M. (Jan Mathijs) janmathijs.schoffelen at donders.ru.nl
Wed Apr 12 08:30:21 CEST 2023


Hi Peter,

Apologies, I was a bit sloppy in my earlier code snippet. I think it should have read something like this


channellist = {‘channel1’;’channel2’;…’channelN’};

cfg = [];
cfg.<someoptionsfor filtering etc>
for k = 1:numel(channellist)
   %% NOT THIS: cfg.channel = channellist{k}; % or something equivalent, at least instructing the reading function to grab a channel specific file
   cfg.dataset = sprintf(‘%s.ncs’,channellist{k});
   data{k} = ft_preprocessing(cfg);
end

If each channel is represented as a single file, ft_preprocessing needs to be instructed in each iteration of the loop with a fresh cfg.dataset
Once you have ‘appended’ the channels through ft_appenddata (note that this requires each of the channels' data structures to have the same number of samples) , you should be able to re-reference.

I hope that this helps to get you on your way.

Good luck,
Jan-Mathijs


On 11 Apr 2023, at 22:30, Peter Kaskan via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>> wrote:

Hello Jan-Mathijs,

Thanks for the reply; I was traveling and just got back to this...

In my initial, very rudimentary preprocessing script, cfg.dataset will take a single neuralynx file:

      cfg.dataset = 'CSC4.ncs';
            cfg.continuous = 'yes';
            highpass, lowlass, demean, detrend etc..
            filtContData = ft_preprocessing(cfg);

But the question was how to reference one channel with another.

I 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.

However, my initial attempt left some errors related to
Error using ft_checkconfig (line 163)
The field cfg.datafile is required
The field cfg.headerfile is required

Error in ft_preprocessing (line 385)
      cfg = ft_checkconfig(cfg, 'required',   {'headerfile', 'datafile'});
After digging a little further in ft_preprocessing lines 446-447
% translate the channel groups (like 'all' and 'MEG') into real labels
  cfg.channel = ft_channelselection(cfg.channel, hdr);
  assert(~isempty(cfg.channel), 'the selection of channels is empty');
... we rescued the error by resetting
cfg.channel = CSC1.ncs;
Do you know what is happening? If we use: channellist = {'CSC1.ncs'; 'CSC2.ncs'; 'CSC3.ncs'}

does the cfg.datafile and cfg.headerfile need to be defined some other way?


Thanks, Peter



________________________________
From: fieldtrip <fieldtrip-bounces at science.ru.nl<mailto:fieldtrip-bounces at science.ru.nl>> on behalf of fieldtrip-request at science.ru.nl<mailto:fieldtrip-request at science.ru.nl> <fieldtrip-request at science.ru.nl<mailto:fieldtrip-request at science.ru.nl>>
Sent: Monday, March 27, 2023 6:00 AM
To: fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl> <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl>>
Subject: fieldtrip Digest, Vol 148, Issue 24

Today's Topics:

1. Re: re-referencing using neuralynx.csc channels
      (Schoffelen, J.M. (Jan Mathijs))

Date: Mon, 27 Mar 2023 08:20:40 +0000
From: "Schoffelen, J.M. (Jan Mathijs)"
        <janmathijs.schoffelen at donders.ru.nl<mailto:janmathijs.schoffelen at donders.ru.nl>>

Hi Peter,

ft_read_data is a so-called ‘intermediate’ level fieldtrip function and not typically called directly by the casual user.

I think your use case calls for the following strategy:

channellist = {‘channel1’;’channel2’;…’channelN’};
for k = 1:numel(channellist)
   cfg.channel = channellist{k}; % or something equivalent, at least instructing the reading function to grab a channel specific file
   data{k} = ft_preprocessing(cfg);
end

alldata = ft_appenddata([], data{:});

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.

Best wishes,

Jan-Mathijs



On 23 Mar 2023, at 22:12, Peter Kaskan via fieldtrip <fieldtrip at science.ru.nl<mailto:fieldtrip at science.ru.nl><mailto:fieldtrip at science.ru.nl>> wrote:

Hello,

I am writing a ft_preprocessing script; I can give it channel1.csc and proceed with filtering, defining trials etc.

...but, how do I re-reference to another channel?

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?

Or do I need to create a montage, and how do I do that with n #s of separate neuralynx.csc channels?



Thanks - Peter


Peter M. Kaskan, Ph.D.
Assistant Professor
Albert Einstein College of Medicine
Leo M. Davidoff Department of Neurological Surgery
1410 Pelham Parkway South
Kennedy Center Room 429B
Bronx, NY 10461

phone: 718-430-2763
_______________________________________________
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip
https://urldefense.com/v3/__https://doi.org/10.1371/journal.pcbi.1002202__;!!HJOPV4FYYWzcc1jazlU!8H-lRU5w5rb--EVlbOiAf99N0XMGrhyk-fsQJ4BQw56I7POkez-dEqFrtQ9SJ4BnZTgBsuTZW_xvbhw4oCE_CdjMrPU0P11VRlXGfw$

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20230412/f73df2b6/attachment.htm>


More information about the fieldtrip mailing list