Some questions about BCPy2000

Forum for software developers to discuss BCI2000 software development
Post Reply
lmbaldezzari
Posts: 8
Joined: 31 May 2015, 09:16

Some questions about BCPy2000

Post by lmbaldezzari » 04 Jun 2015, 20:16

Hi all, how are you?

I am using BCPy2000 and I've a lot a doubts, really.

Someone know how I can implement a stimulus application where a computer screen shows a group of letters grouped in regions, so the users must focus on one of this regions and when de ICC determines where the user is watching one particular region, the computer screen must display only the letters of that region. You can see this in this image

http://prntscr.com/7d8sa8

The greatest doubt is how I can determine where is watching the user?, I mean how I can separate the regions in diferent variables and then how can separate the individual letters in different variables? and finally how can I show the letter on the screen? I know python, but I don't know how do this using the classes, fundations and APIs of BCPy2000.

I hope you can understand, please, any kind of idea I'm sure will help me.

Many thanks, and good luck for all of you!

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

Re: Some questions about BCPy2000

Post by pbrunner » 05 Jun 2015, 10:42

lmbaldezzari,

I assume that you already went through the BCI2000 wiki documentation on BCPy2000 [1]. To get started I would suggest that you try to run and modify the existing Application demos in the \src\contrib\BCPy2000\demo\python folder. After this I would suggest that you define the state machine for your new application. This will also define the states that you need to define in BCI2000. The process function of your application will be executed in regular intervals, where the data acquisition hardware serves as the clock. Or in other words, every SampleBlockSize samples your process function fill be called. In each call you can modify the visual output or progress through your state machine. For example, you can change the intensity of each character group in each call. You annotate this state in the BCI2000 states that you have defined, so that you can analyze the data after the fact.

Regards, Peter

[1] http://www.bci2000.org/wiki/index.php/C ... s:BCPy2000

lmbaldezzari
Posts: 8
Joined: 31 May 2015, 09:16

Re: Some questions about BCPy2000

Post by lmbaldezzari » 11 Jul 2015, 13:02

Hi everyone!

I'm working on my BciAplicattion.py and I need to know if I'm doing fine.

The problem is I can not detect P300 potentials. I don't know if it's because my algorithm is bad, because I'm using SignalGenereator from BCI2000 to prove or both.

I decided to use the phase machine and transitions between phases to control my stimuli.
When I light-up stimulus 1 (let's say stimulus 1 is the group of letters at the top of the screen, see the image in my last post), I do:
self.states['StimulusCode'] = 1 (in order to inform to P3SignalProcessing the current StimulusCode)

When I light up the group of letters to the right (let's say they are stimulus 2), then I do:
self.states['StimulusCode'] = 2

When I turn off the light, I do
self.states['StimulusCode'] = 0

But, never change, always I have the same StimulusCodeRes = 0. So, what would be the problem?

In other hand, when I Suspend the run I obtain this fatal error:
2015-07-11T13:57:18 - PythonAppFilter::StopRun: Parameter "estSinArbol" was accessed during initialization or processing, but not checked for consistency during preflight phase
.

Reading the BCPy2000 Wiki I found this function, but I can't use it in the correct way and I don't know why.
write_access(self, p)
Call this during Preflight in order to ensure that changes
you make to the named parameter(s) will be propagated
to other modules between StopRun() and StartRun().

Changing a parameter value that has not been made writeable
during Preflight will cause a fatal error during StopRun.
Thank you so much, really!

boulay
Posts: 382
Joined: 25 Dec 2011, 21:14

Re: Some questions about BCPy2000

Post by boulay » 12 Jul 2015, 10:35

About estSinArbol, all you have to do is touch the parameter once during preflight, even if you aren't using it at that time.

For the P300-specific problems, can you examine the data file to see that the states are indeed changing in the data file?

jhill
Posts: 34
Joined: 17 Nov 2009, 15:15

Re: Some questions about BCPy2000

Post by jhill » 14 Jul 2015, 10:33

`StimulusCodeRes` state values are output by the `P3SignalProcessing` module, specifically the `P3TemporalFilter` component of that module. Therefore, to get a non-zero value in `StimulusCodeRes`, everything will have to be configured the way that filter likes to have things—for guidance see http://www.bci2000.org/wiki/index.php/U ... oralFilter and the user tutorials/book.

The best thing to do to get it up and running would be to use it with `P3Speller` application, as in the the tutorials, and only move the application module to BCPy2000 when that works.

When you do move, you'll find that BCPy2000 handles stimulus timing somewhat differently from the off-the-shelf BCI2000 modules like `P3SignalProcessing`. For example, the `P3SignalProcessing` module will know nothing of the `EventOffset` state described in http://bci2000.org/downloads/BCPy2000/Timing.html , and will instead always expect stimuli to be delivered at a fixed time relative to a "packet" or "SampleBlock" (those are two terms for the same thing). There is a call you can make,

Code: Select all

self.lock_transitions(to='packet')
which will force BCPy2000 to behave the same way.

Stimulus timing is not the reason you're getting `StimulusCodeRes=0`, though: that's a more fundamental problem (see above).

lmbaldezzari
Posts: 8
Joined: 31 May 2015, 09:16

Re: Some questions about BCPy2000

Post by lmbaldezzari » 25 Aug 2015, 19:11

Hi guys! Thank so much boulay and jhill. First of all, I need to say, 'sorry about the delay in my answert'. I was workinf in other part of my thesis.

Boulay:
About estSinArbol, all you have to do is touch the parameter once during preflight, even if you aren't using it at that time.
I think I had tried this, but I'm not sure. Don't worry, I will try to do it, I hope it works!
For the P300-specific problems, can you examine the data file to see that the states are indeed changing in the data file?
Let me work a little more on my code and then I'm gonna tell you something about the data file!

jhill:
The best thing to do to get it up and running would be to use it with `P3Speller` application, as in the the tutorials, and only move the application module to BCPy2000 when that works.
Sincerely,I don't know what do you mean when you say: "only move the application module to BCPy2000 when that works". Are you talking about the parameters or state variables?
When you do move, you'll find that BCPy2000 handles stimulus timing somewhat differently from the off-the-shelf BCI2000 modules like `P3SignalProcessing`. For example, the `P3SignalProcessing` module will know nothing of the `EventOffset` state described in http://bci2000.org/downloads/BCPy2000/Timing.html , and will instead always expect stimuli to be delivered at a fixed time relative to a "packet" or "SampleBlock" (those are two terms for the same thing).
This is really important! Thank you...

I will try to do:

Code: Select all

self.lock_transitions(to='packet')
But I don't know which part of my code I need implement it.

In the nex days I will share with all of you the results and doubts...

One more time! Thanks a lot...

Greetings from Argentina!

jhill
Posts: 34
Joined: 17 Nov 2009, 15:15

Re: Some questions about BCPy2000

Post by jhill » 28 Aug 2015, 17:20

Sincerely,I don't know what do you mean when you say: "only move the application module to BCPy2000 when that works". Are you talking about the parameters or state variables?
I just mean, start with a P300 speller system that you know actually runs, using the existing BCI2000 modules. Then, if you want to replace the application module, start by not changing the parameters and weights, but rather attempt to recreate the P3Speller application's working behavior exactly in Python: develop it to the point where you can swap back and forth between the builtin P3Speller application and your Python-based clone without the performance changing. Then start customizing, moving step-by-step away from the clone in the direction that you want.

The `lock_transitions` call can be done during `Initialize`.

lmbaldezzari
Posts: 8
Joined: 31 May 2015, 09:16

Re: Some questions about BCPy2000

Post by lmbaldezzari » 17 Oct 2015, 18:44

Hi everyone!
It has been a long time since I write. But I'm here again.

I was with a lot of work and other personal issues, so I could not workBut, days ago I return it to my code in Python in order to make my BCPyAplicattion module in BCPy2000.

Like jhill said, I made my aplicattion following the same theory of P3Speller. At the moment the P3Filter is send me the correct (I think) StimulusCodeRes, so I need to take this information and implement some algorithm that can help me to determine what is the most likelihood target.

But, there are some problems. For example, if I look the data file using the BCI2000 Viewer, I can see that the system give me all the StimulusCode, but not all the StimulusCodeRes, I mean, I use at the moment 9 different StimulusCode, but the P3Filter only gimme 7 StimulusCodeRes, associated with those StimulusCode

In other hand, I have this when I click on "Start" of the "Operator Module".
Colission in state PresentationPhase : Oldvalue: 0 New Python value: 4 New BCI value :3
WARNING:: multiple phase transitions per packet
May be there is the problem, what do you think?

Please, any kind of help is welcome!

Thank you so much, guys! Best regards.
Lucas

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests