How to use¶
Here’s some basic features that let the use send signals out of the TRGen Device. These functions are used to send a defaul trigger signal (positive square with lasting 20µs)
Sending Default Single Trigger to BNCO¶
To send a default trigger to the BNCO the sendTrigger() function can be used:
client.sendTrigger()
Send Trigger(s) to Multiple Ports¶
To send trigger to a customa single or multiple custom triggers at the same time (i.e., with nanosecond time resolution), the same sendTrigger() function can be used but with one extra argument:
client.sendTrigger([TrgenPin.NS0,TrgenPin.GPIO0])
In this example, sendTrigger has one array as argument.
The array represent the list of the desired PINs (PIN 0 of the parallel port and PIN 0 of the GPIO, TrgenPin.NS0 and TrgenPin.GPIO0, respectively) to send simultaneous triggers.
This function can also be used to test whether signals on PINs are properly functioning.
Sending Markers¶
To send a marker to bioamplifiers equipped with parallel ports used for triggering and register events, the function sendMarker() function can be used with the following arguments:
markerNS(default None)markerSA(default None)markerGPIO(default None)LSB(default False)stop(default True)
like this:
client.sendMarker(markerNS=12,markerSA=139,markerGPIO=42)
sendMarker(markerNS,markerSA,markerGPIO) will send the appropriate triggers to generate the desired marker n on the electrophysiological signal from ALL the equipped output ports (NeuroScan, SynAmps, GPIO) on the TRGen device.
Pin Binary Mapping¶
sendMarker(markerNS,markerSA,markerGPIO) use a binary mapping system where each pin corresponds to a specific bit position. This allows for efficient encoding of multiple pin states in a single value:
Pin |
Binary Position |
Decimal Value |
Binary Representation |
|---|---|---|---|
NS0 |
Bit 0 (2^0) |
1 |
00000001 |
NS1 |
Bit 1 (2^1) |
2 |
00000010 |
NS2 |
Bit 2 (2^2) |
4 |
00000100 |
NS3 |
Bit 3 (2^3) |
8 |
00001000 |
NS4 |
Bit 4 (2^4) |
16 |
00010000 |
NS5 |
Bit 5 (2^5) |
32 |
00100000 |
NS6 |
Bit 6 (2^6) |
64 |
01000000 |
NS7 |
Bit 7 (2^7) |
128 |
10000000 |
Example of mapping marker values:
sendMarker(markerNS=1)→ activates only NS0 (binary: 00000001)sendMarker(markerSA=128, markerNS=2)→ activates SA7 (binary: 10000000) and NS1 (binary: 00000010)sendMarker(markerGPIO=131)→ activates GPIO0 + GPIO1 + GPIO7 (binary: 10000011)
This same mapping applies to Synamps (SA0-SA7) and GPIO (GPIO0-GPIO7) pins when using their respective marker parameters.
LSB¶
If the marker number sent does not match with the one observed on the physiological signal, this is may due to an inverted mapping of the bioamplifier’s PINOUT. To fix the issue, also it is possible to invert the bit order, just flag the LSB argument (False by default)
client.sendMarker(markerNS=13,LSB=True)
Example of mapping marker values with LSB:
sendMarker(markerNS=1,LSB=True)→ activates only NS0 (binary: 10000000)sendMarker(markerSA=12,markerNS=2,LSB=True)→ activates SA0 (binary: 00000001) and NS6 (binary: 01000000)sendMarker(markerGPIO=131,LSB=True)→ activates GPIO0 + GPIO6 + GPIO7 (binary: 11000001)
In this way, a marker value of 8 will be generated from the parallel port, 2 on the second parallel port and 15 from the GPIO port.
Auto-Stop¶
If setted to False, the TRGen Device will continue the execution.
client.sendMarker(markerSA=100,LSB=True,stop=False)
# it's the same of calling client.stop() right after.