problem with sending different trigger to BrainVision Recorder with V-Amp, serial port
Dear community
Hi, I'm Lee, and it's my first time asking a question. Please understand If I'm not good at English.
I'm making simple oddball task for my ERP Experiment.
So I want to send different trigger at different stimuli.
but, BrainVision Recorder was received same trigger. just "S11".
at first, before start the experiment, I wrote the code like below at inline script(run).
import serial import time try: exp.port= serial.Serial('COM3') print 'serial port read', exp.port.name, exp.port.baudrate, exp.port.bytesize, exp.port.parity except: print 'serial port not read'
and the printed result of first inline script is here.
serial port read COM3 9600 8 N
and after each stimuli, I wrote the code like below.
value = var.triggervalue t = time.time() count = 0 try: while (time.time()-t) < 0.005 : #500Hz: >4ms / 250Hz: >8ms exp.port.write(str(value)) # or whatever is appropriate count += 1 print('trigger has been sent') print('value:',value,' time:',time.time()-t,' count:',count) except: print 'trigger not sent' self.sleep(200)
and the printed result is here. (value 1: prominent / value 2: odd)
trigger has been sent ('value:', 1, ' time:', 0.005000114440917969, ' count:', 58) trigger has been sent ('value:', 1, ' time:', 0.00599980354309082, ' count:', 32) trigger has been sent ('value:', 2, ' time:', 0.006000041961669922, ' count:', 36) trigger has been sent ('value:', 1, ' time:', 0.006000041961669922, ' count:', 34) trigger has been sent ('value:', 1, ' time:', 0.006000041961669922, ' count:', 67)
last, I end the experiment with this code
exp.port.close()
I expected this inline scripts would sent right trigger, but BrainVision Recorder received only "S11".
Why Recorder read the trigger only "S11", not "S1" nor "S2"? Where is "S11" from?
I read other forums(https://forumcogsci.nl/index.php?p=/discussion/491/solved-sending-different-triggers-via-serial-port etc), but I can't understand why and where I make mistake.
Could you explain what is wrong?
and I have one more question.
I send the trigger with "for" phrase, so I send lots of trigger at one time to handle nyquist problem.
How can I send the only one and long trigger?
If you could correct my mistake, I would be much appreciated.
Thanks a lot.
Comments
Hi Lee,
I don't know whether this makes sense (I've never worked with Serial ports), but maybe you have unset a trigger before sending a new trigger. So in between exp.port.write(str(1)) amd exp.port.write(str(2)), send exp.port.write(str(0)).
I send the trigger with "for" phrase, so I send lots of trigger at one time to handle nyquist problem. How can I send the only one and long trigger?
One way is to send a counter, for example this:
Eduard
Thanks for your reply, Eduard.
Actually, I found what I wrong just before.
I want to handle nyquist problem, so I send triggers with "while" phrase, (sorry, I have mistake. I wrote wrong word.)
but, It send wrong trigger.
with while phrase, I intended to send trigger [1,1,1,1,1,1,1...] -> [S1,S1,S1,S1,S1....]
but, serial port sent trigger [111111....] -> the max signal -> [S11]
photo at below is the result of serial port communication(that I sent to BrainVision Recorder).
Do you know How can I send only one and long trigger?
To solve Nyquist problem, when sampling rate is 500Hz,
One Trigger must longer than 4ms.
How can I make long trigger?
thanks alot.
Hi Lee,
If your experiment allows for it, you can sleep for a little while (e.g. 10 ms ) on every iteration.
Does that do the trick?
Eduard