@@ -4,10 +4,176 @@ This chapter contains functions you can use to establish and control interaction
## bIO
function: out = bIO(pinNr, status, parEv)
**Description**
Use this function to control single outputs/pins of supported hardware. In many cases the use of other functions like feeder, punishment or startExperiment is more useful and fine-grained. The bIO function can be used to turn on or turn off specific pins, which is helpful for programming or debugging an experiment in the office and for simulation of an experiment on your keyboard. To feature different hardware interactions change the option 2 in the function myHardwareSetup.m. Most frequently used hardware devices are implemented in the bIO function but it is not universal.
The general functionality of bIO.m is as follows: bIO can be used with one argument, the number of an input-pin defined in myHardwareSetup. In this case it will read from this pin.
It can be used with two arguments, an output-pin defined in myHardwareSetup and a status (0/1). In this case it will switch this pin on/off.
A third argument can be used to send an event-code, for example for electrophysiology. Event-codes are especially useful for precisely timed extra information such as trial descriptions. This will work only with the parallel port interface. For further information see how-to section 2.4. Event-codes. Please contact us if you have any more questions: biopsytoolbox@ruhr-uni-bochum.de.
**Inputs**
~~~
pinNr number of a pin or vector of pins to read from or write to, see myHardwareSetup
~~~
**Inputs-optional**
~~~
status binary: on/off (1/0), needs to be the same length as the vector of pin numbers
parEv number of the parallel port event to send out
~~~
**Outputs**
~~~
out returns pin number of pins that were active, 0 if none were active
~~~
**Examples**
~~~
1. bIO(1)
% displays status of pin 1
2. bIO(1,1)
% turns on pin 1
3. bIO(2,0)
% turns off pin 2
4. bIO(0,1)
% turns on all pin
5. bIO(0,0)
% turns off all pin
6. bIO([1 2 3],[1 1 0])
% turns on pin 1 and 2 and turns off pin 3
7. bIO([1 2])
% waits for a behavioral response at pin 1 or 2 (during simulation press keys on
This is a helper function that is useful as a reward after a task was successfully finished. This function uses the feeder specified in myHardwareSetup to feed the animal and clears the screen automatically. More than one feeder is supported, but they have to be specified. During feeding the behavioral responses of the animal are recorded and available in the output variable.
In addition feeding turns on the feeding light if defined in myHardwareSetup.m. The optional argument 'noLight' avoids the feeding light.
**Inputs**
~~~
time duration of feeding
~~~
**Inputs-optional**
~~~
varargin ‘feeder’ Defines a specific feeder to use for feeding (followed by feeder number).
Useful if more than one feeder is available.
The number that is used as argument is the index that
points to the pin number, given in section 3 of myHardwareSetup.
‘dontClear’ keeps the content on the screen.
‘noLight’ ignores the feeding light if available.
‘lightdur’ duration of the feeding light (useful if feeding is set to amount in myHardwareSetup)
~~~
**Outputs**
~~~
result struct containing responses recorded during feeding, similar to the output from keyBuffer
~~~
**Examples**
~~~
1. result = feeding(time,varargin)
2. result = feeding(5);
% feeds the animal for 5 seconds or with 5 portions of food
3. result = feeding(1.2,'dontclear');
% feeds the animal for 1.2 seconds and keeps the screen content
4. result = feeding(3, 'noLight');
% feeds the animal for 3 seconds or 3 portions and prevents the feeding light, if defined
5. result = feeding(4, 'lightdur', 6);
% Feeder will operate for 4 seconds or 4 portions and keeps the feeder light on for 6
% seconds in total -> 2 seconds after feeding
6. result = feeding(6,'feeder',2);
% Feeds for 6 seconds on feeder 2, where feeder 2 is the second listed feeder in
% myHardwareSetup.m
~~~
**See also**
punishment, bIO
## punishment (animal)
function: result = punishment(time, varargin)
**Description**
Use this function for punishment if a task wasn't successfully finished. During punishment the answers of the animal are recorded and available in the output variable. This function uses three options for punishment implicitly (all are defined in myHardwareSetup/ myParadigmSetup):
1. if specified in section (3) in myHardwareSetup a device is used
2. if specified in section (6) in myParadigmSetup a stimulus is presented
3. if nothing of the above is specified the houselight will be turned off as punishment
The screen is cleared, but can be kept by using an optional input argument (not if a punishment stimulus is shown!).
**Inputs**
~~~
time duration of punishment
~~~
**Inputs-optional**
~~~
varargin ‘dontclear’ keeps the content on the screen.
~~~
**Outputs**
~~~
result struct containing responses recorded during punishment
~~~
**Examples**
~~~
1. result = punishment(2);
% punishment for two seconds
2. result = punishment(1.5, 'dontclear');
% punishment for 1.5 seconds and keeps the screen content
~~~
## openNetworkIO
function: openNetworkIO
**Description**
Initializes network communication to Network-IO device. Call this function before using functions that need network interfaces. Usually this function is called internally by the bIO function and does not need to be called manually!
**See also**
bIO, closeNetworkIO
## closeNetworkIO
function: closeNetworkIO
**Description**
Use this function to close the network connection to the network IO device. Usually this function is called internally by the stopExperiment function and does not need to be called manually.