stims time information & sampleTime in ov2mat

Obtaining data from various hardware devices
Post Reply
vpeterson
Posts: 3
Joined: Thu Feb 16, 2017 2:15 pm

stims time information & sampleTime in ov2mat

Post by vpeterson »

Hi everyone,

I am new here, so it is my first post. I will describe the scenario of my problem.
I have bought an OpenBCI acquisition system and I am using the OpenVIBE P300 scenario in order to collect some data. Since I am interested in some Matlab off-line analysis with my acquired data, I have used the ov2mat.m function that is provide here http://openvibe.inria.fr/converting-ov-files-to-matlab/
This function save on a file the following variables:

channelsNames: a cell array of size 1x C, where C is the number of electrodes used in the acquisition, containing the name of the channels (the ones that have been load in the SAS)
samples: a N x C matrix containing the recorded EEG data
sampleTime: a N x 1 vector containing the time information
sampleFreq: a number indicating the sample frequency used during acquisition.
stims: a M x 3 matrix containing some time information, code stimulation and, in the last column, all zeros (don't know why)

In order to do some processing with the EEG data, I should have to know the beginning of a target/non-target stimulation, the raw or column that was being highlighted and so on. The second column of the stims matrix contain that information given by the stimulation codes as described here: http://openvibe.inria.fr/stimulation-codes/. Those codes, as well as I understood, are associated to a specific time point given in the first column of stims matrix, with which can then be used to extract EEG epochs. Unfortunately, when I tried to extract a segment of EEG given in the samples matrix, I almost all cases, the time point in which theoretically a stimulus was applied do not "exist" in the sampleTime vector, i.e. I am not able to know the beginning of an epoch/trial. So, my questions are:
Why time information given in stims matrix do not concord with the one given in the sampleTime vector?
How, can I then extract trial for off-line analysis in Matlab?
Please, any advice will be happily received. ! :D

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: stims time information & sampleTime in ov2mat

Post by jtlindgren »

Hi,

the last column in stimulations is the duration. This is usually 0 as the timeline generators bundled with openvibe do not ever set it to anything else (afaik).

The sampleTime vector is pretty much redundant, as openvibe only supports dense, equally spaced signals. Taking 'diff' of sampleTime in normal conditions should give you a vector of constants. In particular, 1/(sampleTime(2)-sampleTime(1)) should equal the sampling frequency.

To get an epoch of the samples matrix, you should be able to do something like this,

Code: Select all

startIdx = floor(stims(indexOfStimOfInterest,1) * samplingFreq) + 1;
stopIdx = startIdx + floor(yourGuessedDurationInSeconds * samplingFreq) - 1;
epoch = samples(startIdx:stopIdx,:);
About the stims and sampleTime not being 'in concord', what do you mean by that?

Cheers,
Jussi

vpeterson
Posts: 3
Joined: Thu Feb 16, 2017 2:15 pm

Re: stims time information & sampleTime in ov2mat

Post by vpeterson »

Hi,

Thanks you very much! You have save me a lot of time in looking for a solution. I will try your advise.

I apologize for my English, I am not a native speaker. What I meant about my first quote (first column of sample are not "in concord with" sampleTime) is that when I selected any time point belonging to the first column of sample, I could not find this value on the sampleTime vector (I was trying to find the index of a trial beginning). Now, that I know that there is NO relationship between those values, I understand everything!

Again, Thank you!

Victoria.

knightv8
Posts: 14
Joined: Thu Jun 29, 2017 9:32 pm

Re: stims time information & sampleTime in ov2mat

Post by knightv8 »

Hey Jussi,
trying to do some offline epoch outside of eeglab and found this. I got everything apart from what you mean by "yourGuessedDurationInSeconds" ?

Lets say I indexed 33285, 33286 (target & nontarget) and my flash duration is 0.1 and non flash 0.08 with 12 repetitions per trial, hence the value for "yourGuessedDuartionInSeconds" would be 0.18 * 24 = 4.32 (epoch of one repetition) ? Am I understanding it correctly ?

Cheers

jtlindgren
Posts: 775
Joined: Tue Dec 04, 2012 3:53 pm
Location: INRIA Rennes, FRANCE

Re: stims time information & sampleTime in ov2mat

Post by jtlindgren »

Hi,

as far as I understand, usually in P300 you collect sample blocks related to stimulus (flash) onset. So if this onset is x seconds, you want data matrix segments like [x-0.1s , x+0.5s], for example. The exact time boundaries are somewhat matter of choice. Then these segments themselves are either aggregated per class to get e.g. a P300 target/nontarget templates, or analyzed/used individually. The latter is the case for example if you give them to some classifier training algorithm and then later make a 'prediction by voting' using the classifier output on a set of flashes.

That your blocks are of different sizes may make comparison difficult unless you use some feature extraction that compresses both classes to the same data dimension.

In the sense of what you write, the duration of your 'block of interest' is 0.1s to keep things comparable (larger of the two). A P300 'trial' then consists of many such blocks from two classes, these blocks overlapping in time. EEGLAB would call block related to each target/nontarget flash an 'epoch'. I'm not sure what kind of use case you'd intend if you want to pick a segment of data that has, for example, all flashes in the trial. If you still want that, then the duration is simply 'number_of_events*time_per_event' assuming there's no delays between.

Hope this helps,
Jussi

knightv8
Posts: 14
Joined: Thu Jun 29, 2017 9:32 pm

Re: stims time information & sampleTime in ov2mat

Post by knightv8 »

Thanks for the detailed explanation Jussi... made my life easier :) Working fine now.

Thanks
Patrick

Post Reply