Sending signals to biosemi

212 views
Skip to first unread message

Cassandra Bunschoten

unread,
May 9, 2018, 11:18:48 AM5/9/18
to E-Prime
Hi everyone,

For a recent project I've started using E-Prime (version 2.0) for the first time. The goal is to research facial mimicry, using EMG. 
So I need to be able to see in BioSemi at which point a stimulus was presented, but I'm having trouble with this. 
I've used a script provided by my supervisor as a starting point for sending codes to BioSemi. However, it's not working the way it's supposed to yet.
Right now there are codes showing up in BioSemi when I run the experiment, but these don't appear at the start of stimulus presentation, instead it appears to be random. Apart from that the codes don't seem to be coupled correctly to the faces (for example, I meant to have code 1 show up for happy faces, but this doesn't happen everytime). 

This is all the code I used (which seems meager):

If c.GetAttrib("code")= "1" Then writeport 888,1
If c.GetAttrib("code")= "2" Then writeport 888,2
If c.GetAttrib("code")= "3" Then writeport 888,3

'1 is angry, 2 is scared, 3 is happy


'display fixation
black.duration=Random(7500,10000)

' (for EMG) writeport 888, 0

black.run

'writeport 888,0
writeport 888,1
writeport 888,2
writeport 888,3


Does one of you have a suggestion for what we should change or add? I found some articles and manuals on it, but haven't really been able to figure out what I need to do. 

Kind regards and thank you in advance!

Michiel Spape

unread,
May 9, 2018, 11:27:55 AM5/9/18
to e-p...@googlegroups.com

Hi Cassandra,

We have a biosemi. There are two things people seem to trouble with:

·         Send a 0 after writing a byte to the parallel port – otherwise bits 01 followed by 10 is read as 11 (see The E-Primer). This can be done nicely with delays in the task events, or, by writing

 

Writeport 888, 0

Sleep 10

Writeport 888, 1

---- followed by the stimulus presentation. This means, by the way, that the sending of the byte is always before the stimulus, not at stimulus onset. But for EMG mimicry, this hardly matters (the onset is quite variable, see https://www.sciencedirect.com/science/article/pii/S0301051117300029 )

 

·         Note that due to pre-release, the code of any inline following a stimulus with pre-release is already executed, possibly long before you expect this. This can be avoided using task-events, or setting the onset of stimuli to trigger sending a byte at the start of the trial. A quick introduction can be found here: http://cognitology.eu/?p=102

 

Best,

Michiel

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/91c54127-06ea-4929-9a69-cbd716ee8491%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Cassandra Bunschoten

unread,
May 9, 2018, 11:57:59 AM5/9/18
to E-Prime
Hi Michiel,

Thank you so much for your swift response!
However, I'm still not quite getting it (I'm really really new to this, sorry). 

We are looking at your blog, but when we reach 3, we bump into another problem. We are using the object Slide, but when we look at the properties of this, there is no tab for task events, so we are a bit lost. 

Is there any other way to do this? 

Also, we set the prerelease to 0, does this help with prerelease problem? Or should we do more?

Thank you so much for your kind answer!

Op woensdag 9 mei 2018 17:18:48 UTC+2 schreef Cassandra Bunschoten:

Michiel Spape

unread,
May 9, 2018, 12:20:36 PM5/9/18
to e-p...@googlegroups.com

Hi Cassandra,

You’re welcome!

 

Are you looking at the slide properties or some of the sub-object properties? Make sure, when you click on the properties, you have the correct ones (the ones that also have duration, logging, and so on), and not the sub-object property pages. In EP2, that’s the white, top-left, not the green, top middle, icon.

If you still use E-Prime 1: wow! You won’t have Task events, but you can still use the classic way:

1)      Define a variable in the global script, such as

Dim outport as integer

outport = &H378 ‘I think that’s the same as your 888

 

beginning of trial procedure, add inline:

 

Stim.OnsetSignalEnabled = True

Stim.OnsetSignalPort = outport

Stim.OnsetSignalData = c.GetAttrib("TriNo")

 

Where Stim is the name of the object, and TriNo references an attribute in the triallist having 1/2/3 for you, depending on the condition.

After the Stim, make sure you add another inline:

 

Writeport Outport, 0

 

Which sets the parallel port to 0 again.

 

If you have E-Prime 2 but have a really ancient version: update it! The latest one, OTOH, is 2.0.10.356. The IT here also does not want to install it, but it’s free and it fixes many bugs.

If you have E-Prime 2, but standard rather than pro – I think that version might not have Task Events? In that case, see the explanation above.

 

If you have E-Prime 3: it should be fine.

 

“Also, we set the prerelease to 0, does this help with prerelease problem? Or should we do more?”

è It should help but it won’t necessarily fix everything. Make sure you read the documentation on prerelease to understand how it works!

 

By the way, in your code:

If c.GetAttrib("code")= "3" Then writeport 888,3

(for EMG) writeport 888, 0

writeport 888,1

writeport 888,2

writeport 888,3

 

May mean that just “3” is recorded by the amplifier. That is, if you send 1/2/3 in quick succession (ca 1 ms), it’s unlikely to capture them all. So if you do need to send 1, then 2, then 3, use something like:

writeport 888,1

sleep 5

writeport 888,0

sleep 5

writeport 888,2

sleep 5

writeport 888,0

sleep 5

writeport 888,3

sleep 5

writeport 888,0

sleep 5

 

Perhaps that’s a bit more than strictly necessary, but it’s better to be sure at this stage than having to wonder later on.

 

Hope that helps!

 

Best,

Michiel

--

You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


David McFarlane

unread,
May 9, 2018, 12:38:54 PM5/9/18
to e-p...@googlegroups.com
Note that Task Events is available only in E-Prime 3, and E-Prime 2 *Professional*, not "Standard".  If you have EP2 Standard instead of Professional, you have no access to Task Events.  And if you have EP2 Pro, you still have to save the file in Professional format to get Task Events; if you save the file in Standard format, you will not have access to Task Events.  If the file is in EP2 Standard format, just resave it as Professional; note however that once saved in Professional format, you cannot revert to Standard.

That said, Task Events is definitely the way to go!

-- David McFarlane


To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe@googlegroups.com.


To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/1fd90b84-244f-47b3-96e9-383126b6ff5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+unsubscribe@googlegroups.com.

To post to this group, send email to e-p...@googlegroups.com.

Cassandra Bunschoten

unread,
May 9, 2018, 1:56:17 PM5/9/18
to E-Prime
Dear Michiel and David, 

Thank you for your quick reaction. The script from Michiel worked, so the first part of our experiment works. Again thank you very much. We indeed dit not have the correct version for task manager, but the script worked.
However we ran into the same problem in our second part of the experiment. In this part we combined faces with a background. Two problems arose when we tried to implement this script in the second part.
First the triggers were not correct..
Our script looks like this at the moment:

Dim outport As Integer
outport = &H378

Slide1.OnsetSignalEnabled = True
Slide1.OnsetSignalPort = outport
Slide1.OnsetSignalData = c.GetAttrib("codeg") And c.GetAttrib("codea")
'codeg 1 is happy, 2 is fearful and codea 1 is neutral, 2 is fearful en 3 happy
If c.GetAttrib("codeg")= "1"  And c.GetAttrib("codea")="1" Then writeport 888,11
If c.GetAttrib("codeg")= "1"  And c.GetAttrib("codea")="2" Then writeport 888,12
If c.GetAttrib("codeg")= "1"  And c.GetAttrib("codea")="3" Then writeport 888,13
If c.GetAttrib("codeg")= "2"  And c.GetAttrib("codea")="1" Then writeport 888,21
If c.GetAttrib("codeg")= "2"  And c.GetAttrib("codea")="2" Then writeport 888,22
If c.GetAttrib("codeg")= "2"  And c.GetAttrib("codea")="3" Then writeport 888,23

Writeport Outport, 0

'display fixation
black.duration=Random(4500,6500)


black.run

writeport 888, 0


Do you know by any chance where we went wrong?

Second, the background of our picture from the face will not become transparent. We tried to give it different background colors and with the source color key tried to make it transparent. Our problem is that our picture is black and white, so if we change the background to black or white, part of our picture disappears as well. Giving it another color does not work, do you maybe know why? And how we can fix this?

Sorry for all the questions, we are just very lost.


Op woensdag 9 mei 2018 18:38:54 UTC+2 schreef McFarlane, David:

To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.


To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/1fd90b84-244f-47b3-96e9-383126b6ff5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.

Michiel S-Spape

unread,
May 9, 2018, 2:18:52 PM5/9/18
to e-p...@googlegroups.com

Dear Cassandra,

I think you will really have to be more explicit with what you are trying to achieve – and not from your point of view, but from someone who’s absolutely not knowing what you are doing. So, you have what exactly in your procedure?

 

[inline1]

[black]

[Slide1]

 

The black.run indicates that an object, with the rather uninformative name black, will be run from within the script. I don’t think that is a good idea in terms of timing accuracy and transparency of code. Just insert it onto the timeline. I get that you’re working by hacking another’s script, so to speak, but it’s probably best to just break it and start from there.

 

The problem is that you will probably want to use Slide1 to have as onset data a signal based on Codeg and codea, yes? So the whole IF statement part is redundant.

Instead:

Slide1.OnsetSignalEnabled = True

Slide1.OnsetSignalPort = outport

Is okay…

 

Slide1.OnsetSignalData = c.GetAttrib("codeg") And c.GetAttrib("codea")

Is not. The AND is a logical indicator, not a way of concatenating variables.

I would use

Slide1.OnsetSignalData = c.GetAttrib("codeg") & c.GetAttrib("codea")

But just to be sure, it may benefit to cast the numbers explicitly to strings and then combine them

Slide1.OnsetSignalData = cstr(c.GetAttrib("codeg")) & cstr(c.GetAttrib("codea"))

But of course you want to send a number, not a string, so:

Slide1.OnsetSignalData = cint(cstr(c.GetAttrib("codeg")) & cstr(c.GetAttrib("codea")))

 

Now, Slide1 will send, at onset, the value. FOLLOWING Slide1 (I mean after the object on the timeline, add a new inline), just do the single writebyte:

 

Writeport Outport, 0

 

…and get rid of the Black.run.

 

Second: I would open the file you have with the background in MSPAINT (start, run, mspaint). Make it a BMP instead of JPG (jpg compresses images and what looks like black becomes a different colour). Select (magic wand) the background you want to have, and use to fill tool to change it entirely to, say, blue. Then use blue as a source key instead.

 

Best,

Michiel

(procrastinating instead of marking)

--
You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/e-prime/078801d3e7b1%24a63bf050%24f2b3d0f0%24%40hope.ac.uk.
For more options, visit https://groups.google.com/d/optout.

 

--

You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


Cassandra Bunschoten

unread,
May 9, 2018, 2:48:17 PM5/9/18
to E-Prime
Hi Michiel,

Thank you! With your advice we managed to figure most of it out, so the whole experiment runs correctly now, thank you so much!

Since you're procastinating, maybe we can bother you with one final question? We still can't manage to make the background disappear. We tried it with black and white in bmp (but that still results in removing parts of the image), but when we make the background another colour in paint, it doesn't disappear. We looked at the colours (so compared for example our blue to the blue in e-prime) and they don't match 100%, can this be the reason the background remains visible? If so, is there a way to match it exactly? If not, do you have a suggestion for how we can fix this? We also tried removing the background entirely in photoshop, but E-Prime then adds a background to it on its own. 

Thank you again so much for your help!!


Op woensdag 9 mei 2018 17:18:48 UTC+2 schreef Cassandra Bunschoten:
Hi everyone,

Michiel S-Spape

unread,
May 9, 2018, 3:49:35 PM5/9/18
to e-p...@googlegroups.com

Hi Cassandra,

No problem!

You’re correct, the colours in E-Prime are not necessarily the same as those in Windows. This is because a “pure red” that looks as red as red can be has a dash of yellow (see https://www.youtube.com/watch?v=8c-qbGgEAEI ).

 

That said, you can find out the exact RGB values by going in MSPAINT and clicking Edit Colours. See the red/green/blue values there and use the same in E-Prime for the source colour. I attach an example here, should that be helpful.

Best,

Michiel

 

 

 

From: e-p...@googlegroups.com [mailto:e-p...@googlegroups.com] On Behalf Of Cassandra Bunschoten
Sent: 09 May 2018 19:48
To: E-Prime <e-p...@googlegroups.com>
Subject: Re: Sending signals to biosemi

 

Hi Michiel,

--

You received this message because you are subscribed to the Google Groups "E-Prime" group.
To unsubscribe from this group and stop receiving emails from it, send an email to e-prime+u...@googlegroups.com.
To post to this group, send email to e-p...@googlegroups.com.


For more options, visit https://groups.google.com/d/optout.


red.zip

Cassandra Bunschoten

unread,
May 14, 2018, 3:23:46 AM5/14/18
to E-Prime
Hi Michiel!

I only now had the chance to look at your solution. Works like a charm!

Thank you again so much for all your help, the entire experiment is running correctly now! 

Kind regards, 
Cassandra

Op woensdag 9 mei 2018 21:49:35 UTC+2 schreef Michiel S-Spape:
Reply all
Reply to author
Forward
0 new messages