Skip to content

Commit 01cff70

Browse files
authored
Merge pull request #8 from neuralabc/enh-trigger
Enh trigger tested and working as expected, moving to main
2 parents 759162e + fa4b2d3 commit 01cff70

23 files changed

Lines changed: 2477 additions & 117 deletions

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,5 +68,7 @@ stage/
6868

6969
*.jar
7070
spft/output/xxx_Test_Right_Only_out-file.yml
71-
spft/__pycache__/spft.cpython-39.pyc
72-
spft/__pycache__/spft.cpython-39.pyc
71+
spft/__pycache__/*
72+
spft/__pycache__
73+
spft/testing/output/*.yml
74+
.ipynb_checkpoints*

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"java.configuration.updateBuildConfiguration": "interactive"
3+
}

README.md

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ This task is modeled on previous work, including the following (most relevant) r
88
- https://pubmed.ncbi.nlm.nih.gov/34704176/
99
- https://pubmed.ncbi.nlm.nih.gov/33885965/
1010

11+
### Integration (triggering)
12+
- The session can be triggered to start by keypress values defined in the [configuration file](#configuration-file)
13+
- Each trial start/stop can also be synchronized with external devices through serial port triggering (or emulated serial port)
14+
- a single trigger message is sent to the external device (e.g, arduino) for both start and stop: `byte[] TRIGGER_MESSAGE = {'1','\n'}`
15+
- the generated [output file](#output) will contain a triggersOut field with times and values indicating start (`'0'`) and stop (`'1'`)
16+
1117
## Build
1218
The application is built with Maven 3
1319

@@ -22,7 +28,9 @@ This will generate a runnable jar in the `target` folder
2228
## Run
2329
This application uses Java 17. Make sure it is installed before running the application.
2430

25-
- if you are running this on a linux system, you will require explicit access to the incoming data from ports {`/dev/ttyACM0`; `/dev/ttyACM1`}. This can be granted by the _system administrator_ providing the user with access to the `dialout` group with `sudo usermod -a -G dialout theUserNameHere`
31+
- if you are running this on a linux system, you will require explicit access to the incoming data from ports {`/dev/ttyACM0`; `/dev/ttyACM1`} and to send triggers out from the program via the serial port if desired {`/dev/ttyACM2`}. This can be granted by the _system administrator_ providing the user with access to the `dialout` group with `sudo usermod -a -G dialout theUserNameHere`
32+
- to ensure that you are recording from the correct devices __always__ plug the devices in to the USB ports in the same order `(left, right)` and you **must** attach the trigger output device last
33+
- this allows you to ensure that you are always aware of which device is which
2634

2735
### Installing Java17 (linux)
2836
Java 11 may still be the default for Ubuntu-based OSs, so you must install it explicitly
@@ -39,7 +47,7 @@ Once a JDK or JRE is installed, run
3947

4048
For example, if running a locally built version
4149

42-
`java -jar target/spft-1.0-SNAPSHOT-jar-with-dependencies.jar`
50+
`java -jar target/spft-1.3-SNAPSHOT-jar-with-dependencies.jar`
4351

4452
This will start a window where you can load a [configuration file](#configuration-file) for a session.
4553
There is a list of [runtime flags](#runtime-flags) that let you customize some aspects of the application
@@ -72,12 +80,13 @@ If the parameter is missing, the session will start as soon as the experimenter
7280
`blocks.trials`: A list of references to the sequences that define each trial. The referenced sequence has to exist in
7381
the top-level pool of sequences
7482
`sequences`: A pool of sequences that can be referenced in blocks' trials. Each sequence has the values for the reference
75-
bar and a frequency in Hz that defines the speed of the sequence
83+
bar and a frequency in milliseconds that defines the speed of the sequence. Each value of the sequence is displayed for this length of time.
84+
- a sequence must be made up of at least two timepoints (i.e., two height values) to ensure correct timing of feedback at the end of the block
7685

7786
### Runtime flags
7887
Runtime flags are JVM System Properties that control some behaviour of the application
7988
To pass a system property, use the `-Dproperty=value` syntax before the jar name that's standard in java applications. For
80-
example, to enable debug mode: `java -jar -Ddebug=true target/spft-1.0-SNAPSHOT-jar-with-dependencies.jar`
89+
example, to enable debug mode: `java -jar -Ddebug=true target/spft-1.3-SNAPSHOT-jar-with-dependencies.jar`
8190

8291
`debug`: Enables extra verbose logging and panel coloured backgrounds to see where each panel ends
8392
`spft.forceData.smoothWindowSize`: The number of samples in the averaging window to calculate the height of the force bar. Default: 1
@@ -117,7 +126,8 @@ relative to the other times in the session
117126
`blocks.trials`: A list of the presentation values and their actual timestamps using a CPU clock
118127
`blocks.endTimestamp`: The end of the block using a CPU clock
119128
`devices`: A list of hardware force devices with each element containing the full stream of data starting when one of the triggers is received
120-
`triggers`: A lif of triggers received throughout the session
129+
`triggers`: A list of triggers received throughout the session
130+
`triggersOut`: If present, indicates serial out hardware device and port name for triggers sent to arduino. Contains the times and values for each trigger
121131

122132
## Implementation notes
123133
### Force bar height

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
<groupId>com.github.neuralabc.spft</groupId>
88
<artifactId>spft</artifactId>
9-
<version>1.1-SNAPSHOT</version>
9+
<version>1.4-SNAPSHOT</version>
1010
<name>Sequence Pinch Force Task</name>
11-
<description>A Java implementation of a Sequence Pinch Force task</description>
11+
<description>A Java implementation of a Sequence Pinch Force task, with ability to trigger to external serial device</description>
1212

1313
<properties>
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

spft/2022_06_Trial_by_trial_Bx.ipynb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 2,
5+
"execution_count": 3,
66
"metadata": {},
77
"outputs": [
88
{
@@ -11,6 +11,14 @@
1111
"text": [
1212
"Populating the interactive namespace from numpy and matplotlib\n"
1313
]
14+
},
15+
{
16+
"name": "stderr",
17+
"output_type": "stream",
18+
"text": [
19+
"/opt/quarantine/miniforge/envs/py3p9/lib/python3.9/site-packages/scipy/__init__.py:146: UserWarning: A NumPy version >=1.16.5 and <1.23.0 is required for this version of SciPy (detected version 1.23.3\n",
20+
" warnings.warn(f\"A NumPy version >={np_minversion} and <{np_maxversion}\"\n"
21+
]
1422
}
1523
],
1624
"source": [
@@ -25,7 +33,7 @@
2533
},
2634
{
2735
"cell_type": "code",
28-
"execution_count": 2,
36+
"execution_count": 4,
2937
"metadata": {},
3038
"outputs": [
3139
{

spft/2022_09_DTW_known_data_test.ipynb

Lines changed: 235 additions & 0 deletions
Large diffs are not rendered by default.

spft/2022_09_DTW_test.ipynb

Lines changed: 967 additions & 0 deletions
Large diffs are not rendered by default.

spft/ComputingBxMetrics_testing.ipynb

Lines changed: 695 additions & 27 deletions
Large diffs are not rendered by default.
2.08 KB
Binary file not shown.
Lines changed: 22 additions & 43 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)