Offline analysis: look at only hit trials

Forum for discussion on different signal processing algorithms
Post Reply
GrahamLab
Posts: 4
Joined: 07 Jan 2016, 17:51

Offline analysis: look at only hit trials

Post by GrahamLab » 22 Aug 2016, 13:29

Hello,

How can I analyze only the hit trials using the Offline Analysis tool? I don't know how to take out the trials that did not hit the target or single out the ones that did. Is there a way I can delete the non-hit trials from the .dat file and then import that into the Offline Analysis tool?

Thanks :)

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Offline analysis: look at only hit trials

Post by pbrunner » 22 Aug 2016, 18:05

Catalina,

whether a trial was a hit or a miss depends on evaluating whether the ResultCode equals the TargetCode. While TargetCode is set throughout the trial, the ResultCode is only known for a brief time after the target was hit, missed or the trial timed out [1]. Because of this you can't easily use this as an expression in the Offline Analysis tool.

As a workaround, you could use load_bcidat [2] to read the data into MATLAB and to create a new state that for the duration of the TargetCode is filled with the ultimate result of this trial. You then use save_bcidat [2] to save this again as a BCI2000 data file. After this you can evaluate your new state in OfflineAnalysis together with the TargetCode.

Let me know if this works for you.

Regards, Peter

[1] http://www.bci2000.org/wiki/index.php/U ... k#Timeline
[2] http://www.bci2000.org/wiki/index.php/U ... _MEX_Files

GrahamLab
Posts: 4
Joined: 07 Jan 2016, 17:51

Re: Offline analysis: look at only hit trials

Post by GrahamLab » 23 Aug 2016, 14:24

Thank you very much. I was wondering if you could help me with filling in the new states variable. I don't have very good matlab skills and I would really appreciate it. I was able to create a new states variable but I can't figure out how to fill it with the information I need.

Thank you

pbrunner
Posts: 344
Joined: 17 Sep 2010, 12:43

Re: Offline analysis: look at only hit trials

Post by pbrunner » 24 Aug 2016, 14:39

Catalina,

please see the code below.

Regards, Peter

Code: Select all

clear all
close all

addpath('~/mex/');

filename = 'filename.dat';

[ signal, states, parameters ] = load_bcidat(filename);

%%

figure,
plot(states.TargetCode,'b-'), hold on,
plot(states.ResultCode,'r--'), axis tight;

%%

index_trial_start = find(diff(double(states.TargetCode)) > 0)+1;
index_trial_stop  = find(diff(double(states.TargetCode)) < 0);

if length(index_trial_stop) < length(index_trial_start)
    index_trial_stop = [index_trial_stop;length(states.TargetCode)];
end

for idx_trial = 1:length(index_trial_start),
    states.ResultCode(index_trial_start(idx_trial):index_trial_stop(idx_trial)) = states.ResultCode(index_trial_stop(idx_trial));   
end

%%

figure,
plot(states.TargetCode,'b-'), hold on,
plot(states.ResultCode,'r--'), axis tight;

GrahamLab
Posts: 4
Joined: 07 Jan 2016, 17:51

Re: Offline analysis: look at only hit trials

Post by GrahamLab » 25 Aug 2016, 12:59

Great! It worked! Thank you so much for all of your help :)

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests