[FieldTrip] Help Manually Defining Trials

Peter Lyons plyons at udel.edu
Wed Jul 22 21:18:25 CEST 2015


Hi All,

Thank you all for your help.  Please excuse the tardiness of my response.
For anyone in the future who wishes to define trials via sample numbers I
thought I would post this code my colleague came up with.  It is surely not
the most elegant way to go about defining trials, but it works so I hope it
helps someone out there.

% % Segmenting based on sample numbers
% % currently shown to create two trials for example

data.cfg                  = rmfield(data.cfg,'trl');
beginTrial               = [2000,7000];                      %beginning
sample numbers
endTrial                  = [5000,10000];                    %end sample
numbers

for numOfTrials = 1:2
    data_artclean.cfg.trl{numOfTrials,1} = beginTrial(numOfTrials);
    data_artclean.cfg.trl{numOfTrials,2} = endTrial(numOfTrials);
    data_artclean.cfg.trl{numOfTrials,3} = 0;
end

cfg.trl                    = cell2mat(data.cfg.trl);
data_seg              = ft_redefinetrial(cfg, data);

Thanks,
Peter

On Mon, Jun 29, 2015 at 10:16 AM, Pelt, S. van (Stan) <
stan.vanpelt at donders.ru.nl> wrote:

>  Hi Peter,
>
>
>
> In addition to Steve’s perfect suggestion, you might want to take a look
> at this example script, which basically is a data-driven way to define
> trials:
>
>
>
>
> http://www.fieldtriptoolbox.org/example/detect_the_muscle_activity_in_an_emg_channel_and_use_that_as_trial_definition
>
>
>
> Here, co-recorded EMG-data is used to define trials, but in your case you
> can use (some parameter in) your MEG data (e.g., some ‘cleaniness’ measure).
>
>
>
> Best,
>
> Stan
>
>
>
> --
>
> Stan van Pelt, PhD
>
> Donders Institute for Brain, Cognition and Behaviour
>
> Radboud University
>
> Montessorilaan 3, B.01.34
>
> 6525 HR Nijmegen, the Netherlands
>
> tel: +31 24 3616288
>
>
>
>
>
> *From:* fieldtrip-bounces at science.ru.nl [mailto:
> fieldtrip-bounces at science.ru.nl] *On Behalf Of *Stephen Politzer-Ahles
> *Sent:* maandag 29 juni 2015 15:32
> *To:* fieldtrip at science.ru.nl
> *Subject:* Re: [FieldTrip] Help Manually Defining Trials
>
>
>
>
>
> Hi Peter,
>
> http://www.fieldtriptoolbox.org/reference/ft_definetrial describes the
> format of the trial definition matrix; you can simply create a matrix like
> this using the times that you would like to choose for your epochs, and
> then run ft_preprocessing() with this matrix as the input for cfg.trl.
> (This is basically a combination of methods (1) and (2) that you suggested
> below.)
>
> Best,
>
> Steve
>
>
>
> Stephen Politzer-Ahles
> New York University, Abu Dhabi
> Neuroscience of Language Lab
> http://www.nyu.edu/projects/politzer-ahles/
>
>
>
> On Mon, Jun 29, 2015 at 2:00 PM, <fieldtrip-request at science.ru.nl> wrote:
>
>
>
> Message: 1
> Date: Sun, 28 Jun 2015 23:51:19 -0400
> From: Peter Lyons <plyons at udel.edu>
> To: FieldTrip discussion list <fieldtrip at science.ru.nl>
> Subject: [FieldTrip] Help Manually Defining Trials
> Message-ID:
>         <CALq-V2qi104MwTnq26qr4EwKPkZkBMEBzstS5JPRxZKVMrr=
> sw at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear All,
>
> My name is Peter Lyons, and I am a researcher at the University of
> Delaware.  Currently, I am conducting resting state EEG research with the
> intention of using Fieldtrip to calculate the power of different frequency
> bands as well as phase lag index between various sensors.  My dataset is a
> continuous recording sampled at 1000 hz for 30 minutes.  I do not have any
> events or triggers in my data.
>
> I would like to manually select the cleanest segments of my data following
> artifact rejection, and define them as trials.
>
> Theoretically, I see three ways to segment my data manually:
>
> 1.  Insert individual triggers throughout my data (at locations determined
> via ft_databrowser), and then define trials based on these triggers.
>
> 2.  Define trials based on a beginning and ending sample number.
>
> 3.  Use ft_databrowser to select segments of data as if they were
> artifacts, and then define these "artifacts" as trials instead of rejecting
> them from the dataset.
>
> Could anyone advise on how to code one of the above methods?
>
> Any help is welcome and appreciated!
>
> Thanks,
> Peter
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150628/d926ab81/attachment-0001.html
> >
>
> ------------------------------
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
> End of fieldtrip Digest, Vol 55, Issue 26
> *****************************************
>
>
>
> _______________________________________________
> fieldtrip mailing list
> fieldtrip at donders.ru.nl
> http://mailman.science.ru.nl/mailman/listinfo/fieldtrip
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.science.ru.nl/pipermail/fieldtrip/attachments/20150722/956fcd9f/attachment-0001.html>


More information about the fieldtrip mailing list