rtCommon.subjectInterface

SubjectInterface is a client interface (i.e. for the experiment script running in the cloud) that facilitates interaction with the subject in the MRI scanner, such as sending classification results to drive the subject display, or receiving their responses (e.g. button-box).

To support RPC calls from the client, there will be two instances of SubjectInterface, one at the cloud projectServer which is a stub to forward requests (started with subjectRemote=True), and another at the presentation computer, run as a service and with subjectRemote=False.

The subjectInterface instance can also be instantiated within the projectServer if the projectServer and presentation computer run on the same system.

Module Contents

Classes

SubjectInterface

Provides functions for sending feedback and receiving reponses from the subject in the scanner.

class rtCommon.subjectInterface.SubjectInterface(subjectRemote=False)

Bases: rtCommon.remoteable.RemoteableExtensible

Provides functions for sending feedback and receiving reponses from the subject in the scanner.

If subjectRemote=True, then the RemoteExtensible parent class takes over and forwards all requests to a remote server via a callback function registered with the RemoteExtensible object. In that case none of the methods below will be locally invoked.

If subjectRemote=False, then the methods below will be invoked locally and the RemoteExtensible parent class is inoperable (i.e. does nothing).

When classification results are received from the experiment script they are placed in a queue which the presentation script can then access. The presentation script can wait on the queue for new results to arrive.

setResult(runId: int, trId: int, value: float, onsetTimeDelayMs: int = 0) None

When setResult is called by the experiment script it queues the result for the presentation script to later read and use to provide subject feedback. :param runId: experiment specific identifier of the run :param trId: volume number of the dicom within a run :param value: the classification result from processing the dicom image for this TR :param onsetTimeDelayMs: time in milliseconds to wait before presenting the feedback stimulus

setResultDict(values: dict, onsetTimeDelayMs: int = 0, name='defaultname') None

Same as setResult except the caller can provide a dictionary with whatever entries are desired to be used at the subjectService. :param values: a dictionary with the desired values to send for this TR :param onsetTimeDelayMs: time in milliseconds to wait before presenting the feedback stimulus

setMessage(message: str) None

Updates the message displayed to the subject

getResponse(runId: int, trId: int)

Retrieve the subject response, used by the classification script. See note above - these local versions of the function are just for testing or as a place holder when no external subjectInterface is used.

getAllResponses()

Retrieve all subject responses since the last time this call was made

dequeueResult(block: bool = False, timeout: int = None) float

Return the next result value sent by the experiment script. Used by the presentation script. See note above - these local versions of the function are just for testing or as a place holder when no external version is used.