New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
load discontinuous Neuralynx data as epochs #1155
base: master
Are you sure you want to change the base?
Conversation
trl(i,1) = (i-1)*hdr.nSamples + 1; | ||
trl(i,2) = (i )*hdr.nSamples ; | ||
trl(i,3) = -hdr.nSamplesPre; | ||
if isfield(hdr, 'trl') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot suddenly add a field to the output of ft_read_header and start using that here. That breaks the API, which is shared with EEGLAB, SPM and other software. See http://www.fieldtriptoolbox.org/development/module/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok good to know. Thanks to your suggestion I created ft_trialfun_neuralynx.m, and besides the fact that I now have to add a few lines before my call to ft_preprocessing, this is indeed way cleaner!
% construct the header that applies to all channels combined | ||
hdr.nChans = length(label); | ||
hdr.label = label; | ||
hdr.filename = fname; | ||
hdr.nTrials = 1; % it is continuous | ||
hdr.nTrials = nTrials; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is fine if all trials have the same length.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please note that hdr.nSamples*hdr.nTrials should correspond to the total number of samples in the file.
hdr.nSamplesPre = 0; % it is continuous | ||
|
||
hdr.nSamplesPre = 0; | ||
hdr.trl = trl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot add fields to the hdr structure.
One solution would be an implementation similar to https://github.com/fieldtrip/fieldtrip/blob/master/trialfun/ft_trialfun_brainvision_segmented.m But I believe best would be to use the existing ft_read_event output and add the segments as "events" (with the appropriate event.duration). That should allow you to do something similar to
This is also how "trial" events are being read from some files, such as the CTF format. E.g. look at Subject01.ds, which has 3-second (900 sample) segments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey Robert,
Thanks for your comments!
I first explored your second (best) suggestion, but it bugged at line 1732 of ft_read_event while trying to load an event (.nev) file that in my case doesn't exist (my cfg.dataset is a directory which only contains .ncs files).
So I switched to your first suggestion and created ft_trialfun_neuralynx.m, basically with the code I previously inserted in fileio/private/read_neuralynx_ds.m, and it works great. However, we should remove the two previously modified files (ft_preprocessing.m and fileio/private/read_neuralynx_ds.m) from this pull request; could you please take care of this, as I am not sure how to do it without messing around with the master branch?
Please let me know if you think we should make any other changes.
Best,
Ludovic
trl(i,1) = (i-1)*hdr.nSamples + 1; | ||
trl(i,2) = (i )*hdr.nSamples ; | ||
trl(i,3) = -hdr.nSamplesPre; | ||
if isfield(hdr, 'trl') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok good to know. Thanks to your suggestion I created ft_trialfun_neuralynx.m, and besides the fact that I now have to add a few lines before my call to ft_preprocessing, this is indeed way cleaner!
Hi there,
As discussed on issue #1128, here's a way to automatically load discontinuous Neuralynx data as epochs (and to avoid getting repeated, artifactual samples in our data due to the pause/stop built-in feature).
Best,
Ludovic