Interfacing with MRI scanner

marcus.haag's Avatar

marcus.haag

10 Mar, 2021 01:25 PM

Hi Chris,

we have presumably a rather simple issue atm.

We would like to perform an mWorks experiment in an MRI scanner. Once the scanner is ready to record, we would like to start our procedure.

So far we have achieved this using an NI card. The scanner sent a TTL pulse, the NI card received it and mWorks only continued to run the experiment once iut received the pulse.

The scanner we are intending to use, sends the number "5" once it is ready. We can connect the that input to our minimac and the number 5 is being produced (e.g. on notepad). Would it be possible to use this keyboard input number "5" as input to continue running the mWorks procedure?

Thanks for your help with this,

Marcus

  1. 1 Posted by marcus.haag on 10 Mar, 2021 01:30 PM

    marcus.haag's Avatar

    Hi again,

    please find attached the xml file we have been using so far. It would be great if you could adjust it, such that the dummy variable is able to react to the number 5 keyboard input.

    Thanks for your help with this,

    Marcus

  2. Support Staff 2 Posted by Christopher Sta... on 10 Mar, 2021 01:59 PM

    Christopher Stawarz's Avatar

    Hi Marcus,

    So far we have achieved this using an NI card. The scanner sent a TTL pulse, the NI card received it and mWorks only continued to run the experiment once iut received the pulse.

    This is still probably the best way to receive the trigger from the scanner. If you just need a replacement for the NI device, I can make some suggestions.

    The scanner we are intending to use, sends the number "5" once it is ready. We can connect the that input to our minimac and the number 5 is being produced (e.g. on notepad). Would it be possible to use this keyboard input number "5" as input to continue running the mWorks procedure?

    That's interesting. Does the scanner connect to the computer via USB and appear as a keyboard input? If so, then MWorks should be able to receive the "5" via a USB HID device.

    please find attached the xml file we have been using so far.

    I think the file may have been corrupted in transit, as it doesn't appear to contain XML. Can you try sending it again?

    Thanks,
    Chris

  3. 3 Posted by marcus.haag on 15 Mar, 2021 12:17 PM

    marcus.haag's Avatar

    Hi Chris,

    thanks for the feedback.

    The scanner is connected to some sort of interface box. This box can be connected to a PC via USB and sends the number "5" whenever a scan starts. Best case scenario, I just need to bring my macbook and run the experiment with that, rather than with the NI card attached.

    Please find attached an xml that hopefully works. I already put in the USB HID Device and USB HID Input device, but I am not entirely sure about how to use it. Maybe you can make the necessary adaptations, such that I can use it and remove the NI card?

    Thanks for your help with this,

    Marcus

  4. Support Staff 4 Posted by Christopher Sta... on 15 Mar, 2021 03:50 PM

    Christopher Stawarz's Avatar

    Hi Marcus,

    The scanner is connected to some sort of interface box. This box can be connected to a PC via USB and sends the number "5" whenever a scan starts.

    OK. It seems likely that the scanner does indeed appear as a USB keyboard device to macOS, so hopefully MWorks' USB HID interface will work.

    Please find attached an xml that hopefully works.

    Thanks, I got it this time.

    I've attached a modified version that will watch for events on the "5" key and set the variable "five_pressed" to one when the key is pressed, zero when it's released (with "press" and "release" being simulated by the MRI hardware). The usage value for the key (34) corresponds to the standard "5" key on a US/English Mac keyboard. It's possible that the MRI sends a different type of "5" (e.g. the "5" in the numeric keypad of an extended keyboard). If MWorks doesn't register the "5" when you expect it, try setting log_all_input_values to YES. This will cause all inputs received from the device to be logged to the MWServer console, and you should be able to read the correct usage value from there.

    Also, since both the real keyboard and the simulated MRI keyboard will appear as USB keyboards to the OS, you'll almost certainly need to set preferred_location_id to tell MWorks which one to use. To do this, load the experiment once as is. MWorks will print an error message saying there are multiple matching devices and listing the location ID's for each. You can then set the appropriate ID in your XML file and reload.

    If you need more help with this, please let me know!

    Cheers,
    Chris

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac