patient#

entrypoint for patient interface

class perceptivo.runtimes.patient.Patient(audio_config: perceptivo.types.sound.Audio_Config = Audio_Config(fs=44100), audiogram_model: Optional[perceptivo.types.psychophys.Psychoacoustic_Model] = None, picamera_params: Optional[perceptivo.types.video.Picamera_Params] = None, oracle: Optional[callable] = None, pupil_extractor: Optional[perceptivo.video.pupil.Pupil_Extractors] = None, pupil_extractor_params: Optional[perceptivo.video.pupil.EllipseExtractor_Params] = None, networking: Optional[perceptivo.types.networking.Patient_Networking] = None, prefs_file: pathlib.Path = PosixPath('/home/docs/.perceptivo/prefs.json'), **kwargs)#

Bases: perceptivo.runtimes.runtime.Runtime

Runtime agent for the patient-facing Pi (see SoftwareOverview).

Runs the

  • Sound Server

  • PiCamera

  • Processing stages including pupil extraction, psychoacoustic model, and stimulus manager

On intialization, boot the sound server and rehydrate the psychoacoustic model from the parameterization passed in audiogram_model. The patient runtime is parameterized by the perceptivo.prefs.Patient_Prefs object, which creates and reads from a prefs.json file (located at perceptivo.prefs.Directories.prefs_file ).

The basic operation of the Patient runtime is encapsulated in the trial() method, see that for further documentation.

Parameters
  • audio_config (Jackd_Config) – Configuration used to boot the jackd server

  • audiogram_model (Psychoacoustic_Model) – Model parameterization used to model the audiogram as well as generate optimal stimuli to sample

  • oracle (callable) – Optional, if present use an oracle to generate responses to stimuli rather than getting them from the pupil extraction method. Mostly for testing, takes a function that accepts a Sound object and returns a boolean response, typically generated by functions in oracle like reference_audiogram()

prefs_class#

alias of perceptivo.prefs.Patient_Prefs

trial() perceptivo.types.psychophys.Sample#

One complete loop through a probe cycle. In order:

Stores the Samples in samples, which also include the parameterizations and timestamps of the presented sounds

next_sound() perceptivo.types.sound.Sound#

Generate the next sound using the psychoacoustic model

Returns

Sound to play

probe(sound: perceptivo.types.sound.Sound) Optional[perceptivo.types.psychophys.Sample]#

One loop of

  • Presenting a sound stimulus

  • Signaling to the other Pi to present a visual stimulus

  • Estimating the Pupil Response

Returns

perceptivo.types.psychophys.Sample

play_sound(sound: perceptivo.types.sound.Sound) perceptivo.types.sound.Sound#

Play a parameterized sound

Parameters

sound ()

Returns

Sound

await_response(sound: perceptivo.types.sound.Sound) Optional[perceptivo.types.pupil.Dilation]#

Wait until we are given a pupil from the picamera process

Returns

bool

_collect_frames(start_time: datetime.datetime)#

Collect frames from the picamera for one sample

handle_message(message)#

Handle a message by calling some method according to its key attribute

Parameters

message (bytes) – a serialized networking.messages.Message object

cb_control(control: Union[perceptivo.types.gui.GUI_Control, Dict[str, perceptivo.types.gui.GUI_Control]])#

Handle GUI Control messages.

Parameters

control ()

Returns:

cb_start(params: Union[perceptivo.types.exam.Exam_Params, Dict[str, perceptivo.types.exam.Exam_Params]])#

Start the exam!

Parameters

params (types.exam.Exam_Params) – Parameters to run the exam!

cb_stop(value=None)#

Stop the exam :Parameters: value ()

Returns:

_update_pupil_params(pupils: List[perceptivo.types.pupil.Pupil]) perceptivo.types.pupil.Pupil_Params#
Parameters

pupils ()

Returns:

_init_audio() Union[autopilot.stim.sound.jackclient.JackClient, soundcard.pulseaudio._Speaker]#

Start the jackd process, connect a client to it!

Returns

autopilot.stim.sound.jackclient.JackClient - A booted jack client!

perceptivo.runtimes.patient.patient_parser(manual_args: Optional[List[str]] = None) argparse.Namespace#
perceptivo.runtimes.patient.main()#