The hardware Module

Olfactometer Provides an interface to the ValveLink devices used to control olfactometers.
Gustometer Provide an interface to the Burghart GU002 gustometer.
AnalogInput Analog data acquisition using a National Instruments board.
Trigger Send triggers, e.t.

Olfactometer

class pphelper.hardware.Olfactometer(ni_lines=u'Dev1/port0/line0:7', ni_trigger_line=None, ni_task_name=u'Olfactometer', use_threads=True, test_mode=False)

Bases: pphelper.hardware._StimulationApparatus

Provides an interface to the ValveLink devices used to control olfactometers.

Parameters:
  • ni_lines (string, optional) – The lines of the NI board to use as output channel. Defaults to Dev1/line0:7.
  • ni_trigger_line (string, optional) – A line on which to generate an additional trigger pulse as the olfactometer stimulation is initiated. This can be used to start the acquisition of PID data, for example.
  • ni_task_name (string, optional) – The name of the NI DAQ task to create. Defaults to Olfactometer.
  • use_threads (bool, optional) – Whether a Python thread should be created when select_stimulus is called. This thread would then allow non-blocking stimulation. Defaults to True.
  • test_mode (bool, optional) – If True, the NI board will not actually be initialized or used in any manner. This allows for testing the program logic on a computer without a DAQ card. Defaults to False.
add_stimulus(name, bitmask, duration=1, bitmask_offset=None, trigger_time=None, replace=False, **kwargs)

Add a stimulus to the stimulus set of this apparatus.

Parameters:
  • name (string) – A unique identifier of the stimulus to add.
  • bitmask (array_like) – The bitmask specifying the valve positions required to present this stimulus.
  • duration (float, optional) – The duration of the stimulation, specified in seconds. Defaults to 1 second.
  • bitmask_offset (array_like, optional) – The bitmask specifying the valve positions after the stimulation has finished. If not specified, all valves will be closed at the end of the stimulation.
  • trigger_time (float, optional) – The time (in terms of the psychopy.core.getTime timebase) at which the stimulation should be triggered. If None, trigger immediately. Defaults to None.
  • replace (bool, optional) – Whether an already existing stimulus of the same name should be replaced or not. Defaults to False.

Notes

Any additional keyword arguments will be added as additional stimulus properties.

remove_stimulus(name)

Remove the specified stimulus, identified by its unique name, from the stimulus list.

Parameters:name (string) – The unique name of the stimulus to remove.
select_stimulus(name)

Select the specified stimulus for the next stimulation.

Parameters:name (string) – The unique name of the stimulus to select.
stimulate(blocking_wait=False)

Start the stimulation with the currently selected stimulus.

The trigger pulse will open the valves. They are then left open for the intended duration of the stimulus. After that, they will be switched to the offset state specified by the stimulus.

Parameters:blocking_wait (bool, optional) – Specifies whether the stimulation thread should be joined or not, i.e. whether we should wait for it to finish (blocking other operations), or return immediately. This parameter will be ignored if threads are not used for stimulation. Defaults to False, i.e. non-blocking behavior.

Notes

stimulate invokes _stimulate, which itself unsets the currently selected stimulus at the end of the stimulation. You have to invoke select_stimulus again before you can call stimulate again.

stimuli

A list of all stimuli added to this stimulation apparatus.

stimulus

The currently selected stimulus.

This stimulus will be presented when invoking stimulate. It can be set using select_stimulus.

test_mode

Gustometer

class pphelper.hardware.Gustometer(pulse_duration=0.1, pause_duration=0.2, gusto_ip=u'192.168.0.1', gusto_port=40175, local_ip=u'192.168.0.10', local_port=40176, ni_trigger_in_line=u'Dev1/ctr0', ni_trigger_in_task_name=u'GustometerIn', use_threads=True, test_mode=False)

Bases: pphelper.hardware._StimulationApparatus

Provide an interface to the Burghart GU002 gustometer.

Parameters:
  • pulse_duration (float, optional) – The duration of one stimulation pulse, in seconds. Defaults to 0.1.
  • pause_duration (float, optional) – The duration of the spray pause between two pulses in seconds. Defaults to 0.2
  • gusto_ip (string, optional) – The IP address of the gustometer control computer. Defaults to 192.168.0.1.
  • gusto_port (int, optional) – The port on which the control software on the gustometer control computer is listening for a connection. This should usually not need to be changed. Defaults to 40175.
  • local_ip (string, optional) – The IP address of the computer running the experimental scripts. This should be the address of the interface which is connected to the gustometer control computer. Defaults to 192.168.0.10.
  • local_port (string, optional) – The port on which to listen for responses from the gustometer control computer. Defaults to 40176.
  • ni_trigger_in_line (string, optional) – The counter input line on the NI board which shall be used to receive the trigger pulse emitted by the gustometer as soon presentation of the requested stimulus has actually started. Defaults to Dev1/ctr0.
  • ni_trigger_in_task_name (string, optional) – The name to assign to the trigger input task. Defaults to GustometerIn.
  • use_threads (bool, optional) – Whether a Python thread should be created when select_stimulus is called. This thread would then allow non-blocking stimulation. Defaults to True.
  • test_mode (bool, optional) – If True, the NI board will not actually be initialized or used in any manner. This allows for testing the program logic on a computer without a DAQ card. Defaults to False.
add_stimulus(name, classnum, trigger_time=None, replace=False, **kwargs)

Add a stimulus to the stimulus set of this apparatus.

Parameters:
  • name (string) – A unique identifier of the stimulus to add.
  • classnum (int) – The stimulus class number, as defined in the Gusto Control software.
  • trigger_time (float, optional) – The time (in terms of the psychopy.core.getTime timebase) at which the stimulation should be triggered. If None, trigger immediately. Defaults to None.
  • replace (bool, optional) – Whether an already existing stimulus of the same name should be replaced or not. Defaults to False.

Notes

Any additional keyword arguments will be added as additional stimulus properties.

load_classfile(filename)

Load a classes file in the Gusto Control software.

Parameters:filename (string) – The filename of the classes file to be loaded, including the file extension (typically .cla).
remove_stimulus(name)

Remove the specified stimulus, identified by its unique name, from the stimulus list.

Parameters:name (string) – The unique name of the stimulus to remove.
select_stimulus(name)

Select the specified stimulus for the next stimulation.

Parameters:name (string) – The unique name of the stimulus to select.
stimulate(blocking_wait=False)

Start the stimulation with the currently selected stimulus.

Parameters:blocking_wait (bool, optional) – Specifies whether the stimulation thread should be joined or not, i.e. whether we should wait for it to finish (blocking other operations), or return immediately. This parameter will be ignored if threads are not used for stimulation. Defaults to False, i.e. non-blocking behavior.

Notes

stimulate invokes _stimulate, which itself unsets the currently selected stimulus at the end of the stimulation. You have to invoke select_stimulus again before you can call stimulate again.

stimuli

A list of all stimuli added to this stimulation apparatus.

stimulus

The currently selected stimulus.

This stimulus will be presented when invoking stimulate. It can be set using select_stimulus.

test_mode
trigger_conf(duration=0.9, int_taste=100, int_bg=100)

Configure the trigger on the gusto.

Parameters:
  • duration (int, optional) – Trigger duration (stimulation duration) in seconds. Defaults to 0.9s.
  • int_taste (int, optional) – Taste intensity in percent. Defaults to 100%.
  • int_bg (int, optional) – Background intensity in percent. Defaults to 100%.

AnalogInput

class pphelper.hardware.AnalogInput(ni_input_line=u'Dev1/ai0', ni_trigger_line=None, sampling_duration=3, sampling_rate=2000, ni_task_name=u'AnalogInput')

Bases: object

Analog data acquisition using a National Instruments board.

Parameters:
  • ni_input_line (str, optional) – The analog input line to acquire the data from. Defaults to Dev1/ai0.
  • ni_trigger_line (str, optional) – If specified, start the acquisition only after a start trigger (high voltage) on this line has been received. If None, no external trigger is required.
  • sampling_duration (float, optional) – How long to sample, specified in seconds. Defaults to 3 seconds.
  • sampling_rate (int, optional) – At which rate (in Hz) to sample the analog input signal. Defaults to 2000 Hz.
  • ni_task_name (str, optional) – The name of the NIDAQmx task to create. Defaults to AnalogInput.
get_data()

Return the acquired data.

If the acquisition is not finished by the time this method is called, it will first wait until finished (blocking other processing) and then return the data.

samples_to_acquire

The number of samples to acquire in the acquisition. This is the product of the sampling rate and the sampling duration.

sampling_duration

The duration (in seconds) of data acquisition.

sampling_rate

The sampling rate (in Hz) of the analog data acquisition.

trigger()

Return the acquired data.

If the acquisition is not finished by the time this method is called, it will first wait until finished (blocking other processing) and then return the data.

Trigger

class pphelper.hardware.Trigger(ni_lines=u'Dev1/PFI2:9', ni_start_trigger_line=None, ni_task_name=u'Triggers', use_threads=True, test_mode=False)

Bases: pphelper.hardware._StimulationApparatus

Send triggers, e.t. to the EEG system.

Parameters:
  • ni_lines (string, optional) – The lines of the NI board to use as output channel. Defaults to Dev1/PFI2:9.
  • ni_start_trigger_line (str or None, optional) – If specified, start the generation only after a start trigger (high voltage) on this digital line has been received. If None, no external trigger is required.
  • ni_task_name (string, optional) – The name of the NI DAQ task to create. Defaults to Triggers.
  • use_threads (bool, optional) – Whether a Python thread should be created when select_stimulus is called. This thread would then allow non-blocking stimulation. Defaults to True.
  • test_mode (bool, optional) – If True, the NI board will not actually be initialized or used in any manner. This allows for testing the program logic on a computer without a DAQ card. Defaults to False.
add_stimulus(name, bitmask, duration=1, trigger_time=None, replace=False, **kwargs)

Add a stimulus to the stimulus set of this apparatus.

Parameters:
  • name (string) – A unique identifier of the stimulus to add.
  • bitmask (array_like) – The bitmask specifying the valve positions required to present this stimulus.
  • duration (float, optional) – The duration of the stimulation, specified in seconds. Defaults to 1 second.
  • trigger_time (float, optional) – The time (in terms of the psychopy.core.getTime timebase) at which the stimulation should be triggered. If None, trigger immediately. Defaults to None.
  • replace (bool, optional) – Whether an already existing stimulus of the same name should be replaced or not. Defaults to False.

Notes

Any additional keyword arguments will be added as additional stimulus properties.

add_trigger(*args, **kwargs)
remove_stimulus(name)

Remove the specified stimulus, identified by its unique name, from the stimulus list.

Parameters:name (string) – The unique name of the stimulus to remove.
remove_trigger(name)
select_stimulus(name)

Select the specified trigger for the next generation.

Parameters:name (string) – The unique name of the trigger to select.
select_trigger(name)
stimulate(blocking_wait=False)

Start the generation of the currently selected trigger.

Parameters:blocking_wait (bool, optional) – Specifies whether the trigger thread should be joined or not, i.e. whether we should wait for it to finish (blocking other operations), or return immediately. This parameter will be ignored if threads are not used for stimulation. Defaults to False, i.e. non-blocking behavior.

Notes

trigger invokes _trigger, which itself unsets the currently selected trigger at the end of the generation. You have to invoke select_trigger again before you can call trigger again.

stimuli

A list of all stimuli added to this stimulation apparatus.

stimulus

The currently selected stimulus.

This stimulus will be presented when invoking stimulate. It can be set using select_stimulus.

test_mode
trigger(blocking_wait=False)