[FieldTrip] Difficulty detecting TTL pulses with ft_read_event

Paul Sowman paul.sowman at mq.edu.au
Tue Oct 29 02:29:41 CET 2019


Hi Jonathon, you could try something like this:


trigger_nums = 161:225; %TTL channels

triggers     = ft_read_data(cfg.dataset,'dataformat','yokogawa_con','chanindx',trigger_nums); %read in data from MEG



hdr = ft_read_header(cfg.dataset,'dataformat','yokogawa_con');



for j=1:size(triggers,1)

    trig_height(j) = max(triggers(j,:)); %find the peak voltage in trigger channel

end



trig_thresh = 0.25*max(trig_height); % threshold 1/4 of trigger max

triggers    = triggers>trig_thresh; %Binarise trigger channels



event = [];

list  = trigger_nums;



for k=1:size(triggers,1)

    channel   = list(k);

    trig      = triggers(k,:);

    pad       = trig(1);

    trigshift = 0;

    begsample = 1;





    for l=find(diff([pad trig(:)'])>0)

        event(end+1).type   = num2str(channel);

        event(end  ).sample = l + begsample - 1;      % assign the sample at which the trigger has gone down

        event(end  ).value  = trig(l+trigshift);      % assign the trigger value just _after_ going up

    end



end



--
Paul F Sowman
Associate Professor
Director HDR
Deputy Head
Department of Cognitive Science
Level 3, Room 3.824
Australian Hearing Hub
16 University Drive
Macquarie University, NSW 2109, Australia
T: +61 2 9850 6732
W: Profile Page<https://researchers.mq.edu.au/en/persons/paul-sowman>
W: Scholar<https://scholar.google.com.au/citations?hl=en&user=3qso4G4AAAAJ&view_op=list_works&sortby=pubdate>
<https://www.cogsci.mq.edu.au/members/profile.php?memberID=291>



From: fieldtrip <fieldtrip-bounces at science.ru.nl> on behalf of "fieldtrip-request at science.ru.nl" <fieldtrip-request at science.ru.nl>
Reply to: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Date: Saturday, 26 October 2019 at 4:58 am
To: "fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: fieldtrip Digest, Vol 107, Issue 14

Send fieldtrip mailing list submissions to
fieldtrip at science.ru.nl

To subscribe or unsubscribe via the World Wide Web, visit
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://protect-au.mimecast.com/s/YfJaCmO5wZsA3qNqhDqbaK?domain=mailman.science.ru.nl>
or, via email, send a message with subject or body 'help' to
fieldtrip-request at science.ru.nl

You can reach the person managing the list at
fieldtrip-owner at science.ru.nl

When replying, please edit your Subject line so it is more specific
than "Re: Contents of fieldtrip digest..."


Today's Topics:

1. Difficulty detecting TTL pulses with ft_read_event
(Jonathon James Parker)


----------------------------------------------------------------------

Message: 1
Date: Fri, 25 Oct 2019 17:56:22 +0000
From: Jonathon James Parker <parkerjo at stanford.edu>
To: " fieldtrip at science.ru.nl" <fieldtrip at science.ru.nl>
Subject: [FieldTrip] Difficulty detecting TTL pulses with
ft_read_event
Message-ID:
<BYAPR02MB5750759FB50F1B32AD4033ABAD650 at BYAPR02MB5750.namprd02.prod.outlook.com>

Content-Type: text/plain; charset="windows-1252"

Hi FieldTrippers:

I am a LFP/Brain stimulation researcher new to FieldTrip @Stanford.

I have run across some difficulty using the ft_read_event to detect TTL pulses and triggering my data into discrete epochs

I have 14 channels of LFP data and 1 channel of trigger data recording using a gTec USBAmp-Research. I have successfully read in the data, filtered-it, re-referenced channels of interest, and appended the un-filitered trigger channel (‘TRAIN’).

The TTL pulses are on (value ~1) while stimulation is on. I would like to trigger based on the upgoing flank.

Each time I run ft_read_event, I have passed it the isolated trigger channel data, but I receive this error:
[cid:image002.png at 01D58B22.76EEAD40]

Does anyone have sample scripts they could share with use of ft_read_event to detect TTL pulses?

See my full code below:

[cid:image004.png at 01D58B22.D7510DE0]

Thank you!

Jonathon

Jonathon J. Parker MD PhD
Stanford University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20191025/818bef13/attachment.html<https://protect-au.mimecast.com/s/nf5HCnx1Z5UK2VNVTpvw21?domain=mailman.science.ru.nl>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: A3DC4FD486F44903AB758DAE15EE481D.png
Type: image/png
Size: 34364 bytes
Desc: A3DC4FD486F44903AB758DAE15EE481D.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20191025/818bef13/attachment.png<https://protect-au.mimecast.com/s/ZejsCoV1Y2SBRm3mS7o3D-?domain=mailman.science.ru.nl>>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ADBC8F3541B147E684A61A3B335C4EFC.png
Type: image/png
Size: 569163 bytes
Desc: ADBC8F3541B147E684A61A3B335C4EFC.png
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20191025/818bef13/attachment-0001.png<https://protect-au.mimecast.com/s/B7ZpCp81gYCvWZ3ZHx3W1y?domain=mailman.science.ru.nl>>

------------------------------

Subject: Digest Footer

_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://protect-au.mimecast.com/s/YfJaCmO5wZsA3qNqhDqbaK?domain=mailman.science.ru.nl>
_______________________________________________
fieldtrip mailing list
https://mailman.science.ru.nl/mailman/listinfo/fieldtrip<https://protect-au.mimecast.com/s/YfJaCmO5wZsA3qNqhDqbaK?domain=mailman.science.ru.nl>
https://doi.org/10.1371/journal.pcbi.1002202<https://protect-au.mimecast.com/s/7IINCq71jxfz3vjvIpAnIS?domain=doi.org>


------------------------------

End of fieldtrip Digest, Vol 107, Issue 14
******************************************

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20191029/c10a5396/attachment.html>


More information about the fieldtrip mailing list