Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

Trigger to external software not working

Hi there, I asked this question within a previous post, but I thought it better to keep this question on a different thread.

I'm using a Dell (Windows 10).Then I'm using Legacy backend for OS.

I am running a task and at the same time recording fNIRS using OxySoft sofrware on the same computer.

I need to be able to use a keyboard to send a trigger to Oxysoft when a participant (babies) looks away during a block.

I have this working in my baseline block which has a sequence that looks like this:

  • A loop containing a inline scrip, then sketchpad, then keyboard response
  • through the loop I present a random sequence of jpg's in the sketchpad for ~30s
  • the inline script to send the trigger is quite simple:
oxy.WriteEvent("p", "end_pause")


My problem is that in a different block loop, the same inline script does not send the trigger to Oxysoft. The only difference is that this loop has a sequence that uses a media_player_mpy, playing a random sequence of vide files. In this sequence I have:

  • inline script with code:
oxy.WriteEvent("x", "Ignore_Block")
  • media_plahyer_mpy
  • keyboard response

I have the keyboard_response with no correct response and Timeout set to 0 (or I've tried 15000 - ie the duration of the block).

The idea is that mostly the sequence will run a few videos and no trigger is needed. But occasionally i'll need to send an x trigger.

I think maybe it's how i've set up the keyboard_response?


I've been playing around with this for a couple of weeks and just can't work it out. Any help much appreciated.

Comments

  • An abbreviated version of the task is here just in case this helps though obviously I assume it's not possible to test the trigger code without Oxysoft (but I know the inline scipt itself is fine given it works in the other block)


  • Hi rlaycock,

    Here some modifications to your script:

    I couldn't test it, because there were no videos in the file pool. Perhaps you could simplify this script more by reducing the loop table to a few videos only and attached those to the file pool.

    Aside of that, I suspect the problem was twofold:

    1. setting the run-if field of the keyboard response is set to [response] = 'x', is a bit weird, because you need that keyboard response in order to get a response that you then can evaluate. So I changed that to always
    2. In order to always be able to poll that response, you need to set the duration of the video to 0, and set the duration of it in the keyboard response that follows (essentially the same way you did it for the sketchpad in the first block).

    Do these adjustments fix it?

    Eduard

    Buy Me A Coffee

  • Thanks for your help here @eduard .

    Here is the task with a video in the File pool (video was over 10MB so couldn't attach sorry).


    Unfortunately setting video duration to 0 doesn't work - I just get a black screen (video does not play). My interpretation is that when you present a jpg for duration = 0 (as in my Baseline block) OS shows the image, and waits for the keyboard response(?). But with a video it's either playing the video or not showing it. It seems that it's not straight forward to perform actions (eg have an inline script) during a video - you'd have to do this before or after the video?

    I'm not sure why I had the keyboard response with a run-if setting. I think this was meant for the inline script, which I've now put into the same sequence as the video (ie same structure I have for the baseline).

    But we're still stuck with the fact that the inline script does not seem to execute (run if: [response] = x) despite the keyboard response looking for a key press.


    I have a work-around: I have the video set to duration = keypress. I then added a blank sketchpad which shows if I press any key (empty sketchpad duration = infinite). Then I have my inline scrip (run if [response] = x). So when I want to send an x trigger during a video a just press x twice. This is fine for current needs, but it does stop the video, and it would be good if I could send the x trigger with video still playing.

    Thanks!

    Robin

  • update: actually my workaround is no good. I do need the video to keep playing at the same time as I (on some trials) send a trigger.

  • Hi,

    yeah, it seems you need to do some inline_scripting. There are two approaches:

    1. code everything inline (OpenCV2 to present videos instead of the media player)
    2. Use the Call custom Python code option of the media player.

    I have no experience with the second one (e.g. no clue whether the video quality suffers in case the custom code is too heavy), and I can't see where the code to be executed has to be added.

    But the first one should be easy enough. I attach an example experiment that plays back the video you attached, and responds to keypresses. If you extend it to process keys the way you want it, and add sending triggers, you should be set, right?

    https://we.tl/t-Atw2lzdaFj

    Does that help?

    Buy Me A Coffee

Sign In or Register to comment.