Upgrade to Pro — share decks privately, control downloads, hide ads and more …

CSC570 Lecture 06

CSC570 Lecture 06

Applied Affective Computing
BCI dataset (+ MQTT publishing)
(202504)

Javier Gonzalez-Sanchez

April 17, 2023
Tweet

More Decks by Javier Gonzalez-Sanchez

Other Decks in Research

Transcript

  1. Dr. Javier Gonzalez-Sanchez [email protected] www.javiergs.info o ffi ce: 14 -227

    CSC 570 Current Topics in Computer Science Applied Affective Computing Lecture 06. BCI Dataset
  2. Device | Sample 5 Timestamp Local time Battery Level Battery

    Percent Wireless Signal Overall Quality Quality Sensor 0 Quality Sensor 1 Quality Sensor 2 Quality Sensor 3 Quality Sensor 4 1744764427.2127 17:47:07.212 4 93 1.0 83 4 2 4 4 4 1744764427.7128 17:47:07.712 4 93 1.0 100 4 4 4 4 4 1744764428.212 17:47:08.212 4 93 1.0 100 4 4 4 4 4 1744764428.7123 17:47:08.712 4 93 1.0 83 4 2 4 4 4 1744764429.2123 17:47:09.212 4 93 1.0 83 4 2 4 4 4 1744764429.7118 17:47:09.711 4 93 1.0 83 4 2 4 4 4 1744764430.2118 17:47:10.211 4 93 1.0 83 4 2 4 4 4 1744764430.7118 17:47:10.711 4 93 1.0 83 4 2 4 4 4 1744764431.2113 17:47:11.211 4 93 1.0 83 4 2 4 4 4 1744764431.7115 17:47:11.711 4 93 1.0 83 4 2 4 4 4 1744764432.2114 17:47:12.211 4 93 1.0 100 4 4 4 4 4 1744764432.7108 17:47:12.710 4 93 1.0 100 4 4 4 4 4 1744764433.2108 17:47:13.210 4 93 1.0 100 4 4 4 4 4 1744764433.7108 17:47:13.710 4 93 1.0 100 4 4 4 4 4
  3. Timestamp and Local Time • 1744764427 . 2127 • Milliseconds:

    0.2127 • Seconds: 1744764427 • Minutes: (1744764427 / 60) = 29,079,407 minutes (1744764427 % 60) = 7 seconds (rem a ining) • Hours: (29,079,407 / 60) = 484,656 hours (29,079,407 % 60) = 47 minutes (rem a ining) • D a ys (484,656 / 24) = 20,194 d a ys (484,656 % 24) = 0 hours (rem a ining) • 1744764427.2127 is 00:47:07.2127 (UTC-0). In C a liforni a is 17:47:07.2127 (UTC-7). 6
  4. Attributes Approxim a tely 2 times per second, it is

    reported: a ) B a ttery Level (0 to 4) b) B a ttery Percent a ge (0 to 100) c) Wireless Sign a l (0 or 1) f) Over a ll Qu a lity (0 to 100) g) Qu a lity per Sensor (0 to 4) – ex a mple is showing Emotiv Insight with 5 sensors. 7
  5. Battery Percentage 8 * The headset uses Bluetooth or BLE,

    which periodically spikes power usage:
  6. Affect | Sample 11 Timestamp Local time Active Focus Focus

    Active Engagement Engagement Active Excitement Excitement Active Interest Interest Active Relaxation Relaxation Active Stress Stress 1744764427.2049 17:47:07.204 TRUE 0.442648 TRUE 0.643395 TRUE 0.335885 TRUE 0.434116 TRUE 0.329787 TRUE 0.342687 1744764427.705 17:47:07.705 TRUE 0.446789 TRUE 0.637363 TRUE 0.323186 TRUE 0.436262 TRUE 0.335162 TRUE 0.353683 1744764428.2042 17:47:08.204 TRUE 0.446741 TRUE 0.637341 TRUE 0.310262 TRUE 0.438645 TRUE 0.335169 TRUE 0.363112 1744764428.7044 17:47:08.704 TRUE 0.438516 TRUE 0.637319 TRUE 0.297989 TRUE 0.439741 TRUE 0.337592 TRUE 0.363114 1744764429.2045 17:47:09.204 TRUE 0.428505 TRUE 0.607775 TRUE 0.286152 TRUE 0.439762 TRUE 0.347594 TRUE 0.356406 1744764429.7039 17:47:09.703 TRUE 0.419546 TRUE 0.592737 TRUE 0.277071 TRUE 0.439503 TRUE 0.3476 TRUE 0.348793 1744764430.204 17:47:10.204 TRUE 0.41153 TRUE 0.580864 TRUE 0.266992 TRUE 0.438463 TRUE 0.331386 TRUE 0.319546 1744764430.704 17:47:10.704 TRUE 0.410955 TRUE 0.574201 TRUE 0.258335 TRUE 0.436267 TRUE 0.320155 TRUE 0.308104 1744764431.2035 17:47:11.203 TRUE 0.411234 TRUE 0.552865 TRUE 0.252417 TRUE 0.433624 TRUE 0.311228 TRUE 0.307482 1744764431.7037 17:47:11.703 TRUE 0.411486 TRUE 0.528224 TRUE 0.252434 TRUE 0.431828 TRUE 0.291503 TRUE 0.298646 1744764432.2036 17:47:12.203 TRUE 0.411714 TRUE 0.520951 TRUE 0.254464 TRUE 0.431789 TRUE 0.285768 TRUE 0.297925 1744764432.703 17:47:12.703 TRUE 0.416707 TRUE 0.520948 TRUE 0.254481 TRUE 0.433045 TRUE 0.285784 TRUE 0.297938 1744764433.203 17:47:13.203 TRUE 0.421216 TRUE 0.539614 TRUE 0.254498 TRUE 0.4343 TRUE 0.287166 TRUE 0.298739 1744764433.703 17:47:13.703 TRUE 0.411843 TRUE 0.548943 TRUE 0.256466 TRUE 0.434502 TRUE 0.291273 TRUE 0.2989
  7. Attributes Approxim a tely 2 times per second, it is

    reported: a ) Active <?> is true if the detection of this metrics is running properly. It is f a lse if the detection c a nnot run. This c a n h a ppen if the EEG sign a l from the he a dset is of poor qu a lity. b) Focus: sust a ined a ttention on a single t a sk. c) Eng a gement: immersion in a n a ctivity. d) Excitement: intensity of re a ctions to stimuli. e) Interest: a ttr a ction or a version to stimuli. f) Rel a x a tion: c a lm a fter a period of intense concentr a tion. g) Emotion a l Stress (Insight/EPOC): tension experienced when completing a t a sk. h) Cognitive Stress (MN8): ment a l str a in c a used by ch a llenging t a sks or environments. 12
  8. EEG | Sample 15 Timestamp Local time Counter Interpolated Contact

    Quality AF3 T7 Pz T8 AF4 1744764427.0639 17:47:07.063 104 FALSE 0.0 4187.949 4618.205 3943.333 4129.744 4270.641 1744764427.0717 17:47:07.071 105 FALSE 0.0 4186.282 4636.795 3944.487 4157.692 4273.846 1744764427.0795 17:47:07.079 106 FALSE 0.0 4201.667 4650.513 3953.718 4221.667 4289.103 1744764427.0874 17:47:07.087 107 FALSE 0.0 4203.846 4628.974 3949.872 4206.667 4295.641 1744764427.0953 17:47:07.095 108 FALSE 0.0 4206.667 4641.282 3954.872 4200.0 4296.795 1744764427.1031 17:47:07.103 109 FALSE 0.0 4223.718 4673.59 3968.333 4223.974 4307.821 1744764427.1109 17:47:07.110 110 FALSE 0.0 4218.462 4645.897 3958.846 4195.385 4306.282 1744764427.1187 17:47:07.118 111 FALSE 0.0 4190.513 4602.179 3942.051 4173.333 4283.462 1744764427.1266 17:47:07.126 112 FALSE 0.0 4185.256 4617.949 3944.359 4197.308 4276.538 1744764427.1344 17:47:07.134 113 FALSE 0.0 4197.051 4653.718 3945.641 4205.128 4290.385 1744764427.1422 17:47:07.142 114 FALSE 0.0 4191.538 4644.872 3933.205 4198.846 4288.205 1744764427.1500 17:47:07.150 115 FALSE 0.0 4194.359 4617.949 3935.385 4194.103 4283.718 1744764427.1579 17:47:07.157 116 FALSE 0.0 4230.385 4632.308 3962.692 4200.256 4310.769 1744764427.1658 17:47:07.165 117 FALSE 0.0 4248.846 4661.667 3977.692 4229.231 4330.897
  9. Attributes Approxim a tely 128 times per second, (one v

    a lue every 7 milliseconds) it is reported: a ) Counter (0 to 127): b) Interpol a ted: FALSE if this s a mple w a s received from the he a dset. TRUE if this s a mple w a s interpol a ted by Emotiv Softw a re. c) Cont a ct Qu a lity d) AF3, T7, Pz, T8, AF4: v a lues in microvolts (sc a led) 16
  10. Face | Sample 19 Timestamp Local time Action Eye Action

    Upper Face Power Upper Face Action Lower Face Power Lower Face 1744764427.2049 17:47:07.204 neutral frown 0.3378 neutral 0.0 1744764427.2362 17:47:07.236 neutral frown 0.3378 neutral 0.0 1744764427.2674 17:47:07.267 neutral frown 0.3378 neutral 0.0 1744764427.2987 17:47:07.298 neutral frown 0.3378 neutral 0.0 1744764427.3299 17:47:07.329 blink frown 0.45515 neutral 0.0 1744764427.3612 17:47:07.361 blink frown 0.45515 neutral 0.0 1744764427.3923 17:47:07.392 blink frown 0.45515 neutral 0.0 1744764427.4235 17:47:07.423 blink frown 0.45515 neutral 0.0 1744764427.4548 17:47:07.454 blink frown 1.0 neutral 0.0 1744764427.4862 17:47:07.486 neutral frown 1.0 neutral 0.0 1744764427.5175 17:47:07.517 blink frown 1.0 neutral 0.0 1744764427.5489 17:47:07.548 blink frown 1.0 neutral 0.0 1744764427.5802 17:47:07.580 blink frown 1.0 neutral 0.0 1744764427.6115 17:47:07.611 blink frown 1.0 neutral 0.0
  11. Attributes Approxim a tely 32 times per second, it is

    reported: a ) Eye (Action): neutr a l, blink, left wink (winkL), right wink (winkR) b) Upper F a ce (Action a nd Power): neutr a l, r a ised eyebrows (surprise), furrowed brows (frown) – v a lue 0 to 1 c) Lower F a ce (Action a nd Power): neutr a l, smile, l a ugh, smirkRight, smirkLeft, a nd clenched teeth (clench) – v a lue 0 to 1 20
  12. Motion | Sample 23 250415174707_MOTION Timestamp Local time Counter Interpolated

    Accelerometer X Accelerometer Y Accelerometer Z Magnetometer X Magnetometer Y Magnetometer Z Quaternion 0 Quaternion 1 Quaternion 2 Quaternion 3 1744764427.1893 17:47:07.189 30 FALSE 0.727844 0.228271 0.646606 -0.0059 0.9307 -0.3243 -0.059083 -15.773483 18.672238 -8.167456 1744764427.2206 17:47:07.220 31 FALSE 0.727772 0.228333 0.646667 -0.0058 0.9434 -0.3336 -0.058106 -15.841058 18.65929 -8.218033 1744764427.2518 17:47:07.251 0 FALSE 0.727684 0.228271 0.64679 -0.0056 0.9473 -0.3297 -0.062501 -15.96169 18.692499 -8.248599 1744764427.2831 17:47:07.283 1 FALSE 0.727661 0.228516 0.646729 -0.0057 0.9419 -0.3287 -0.053712 -15.950628 18.871925 -8.306015 1744764427.3142 17:47:07.314 2 FALSE 0.727611 0.228333 0.646851 -0.0056 0.9341 -0.3424 -0.050782 -15.806088 18.76424 -8.342737 1744764427.3456 17:47:07.345 3 FALSE 0.727596 0.228027 0.646973 -0.0059 0.9385 -0.3229 -0.05127 -15.795632 18.742092 -8.345878 1744764427.3767 17:47:07.376 4 FALSE 0.727557 0.227966 0.647034 -0.0063 0.9360 -0.3151 -0.048341 -15.606776 18.767021 -8.28889 1744764427.4079 17:47:07.407 5 FALSE 0.727426 0.227173 0.647461 -0.0062 0.9478 -0.3214 -0.050294 -15.571391 18.744595 -8.327324 1744764427.4392 17:47:07.439 6 FALSE 0.727434 0.227478 0.647339 -0.0068 0.9492 -0.3361 -0.065431 -15.584405 18.799181 -8.257237 1744764427.4705 17:47:07.470 7 FALSE 0.727224 0.227966 0.6474 -0.0070 0.9360 -0.3366 -0.066896 -15.551256 18.773539 -8.224067 1744764427.5019 17:47:07.501 8 FALSE 0.727112 0.228149 0.647461 -0.0071 0.9448 -0.3287 -0.054688 -15.656007 18.690646 -8.209168 1744764427.5332 17:47:07.533 9 FALSE 0.726828 0.228516 0.647644 -0.0077 0.9331 -0.3361 -0.052247 -15.735329 18.705766 -8.285482 1744764427.5646 17:47:07.564 10 FALSE 0.72675 0.228577 0.647705 -0.0081 0.9473 -0.3336 -0.056641 -15.702042 18.704419 -8.264441 1744764427.5959 17:47:07.595 11 FALSE 0.726777 0.227783 0.647949 -0.0085 0.9551 -0.3234 -0.057618 -15.612268 18.792931 -8.23055
  13. Attributes Approxim a tely 32 times per second, it is

    reported: a ) Counter (0 to 31) b) Interpol a ted: FALSE if this s a mple w a s received from the he a dset. TRUE if this s a mple w a s interpol a ted by Emotiv Softw a re. c) Accelerometer. X, Y, Z a xis of the a ccelerometer ( a pprox. -2.0 to +2.0 g) d) M a gnetometer. X, Y, Z a xis of the m a gnetometer ( a pprox. -150.0 to +15.0 µtesl a s) e) Qu a ternions of the gyroscope (-1.0 to 1.0) – orient a tion in a unit sphere 24
  14. Orientation • Given a qu a ternion q = [x,

    y, z, w]: • • Roll - rot a tion a round X- a xis: • Pitch - rot a tion a round Y- a xis: • Y a w - rot a tion a round Z- a xis: qnormalized = [ x norm , y norm , z norm , w norm ] ϕ = atan2(2(wx + yz),1 − 2(x2 + y2)) θ = asin(2(wy − zx)) ψ = atan2(2(wz + xy),1 − 2(y2 + z2)) 25 norm = x2 + w2 + z2 + w2
  15. MQTT Wh a t is MQTT? • MQTT (Mess a

    ge Queuing Telemetry Tr a nsport) is a lightweight, publish-subscribe network protocol. • Designed for constr a ined devices a nd low-b a ndwidth, high-l a tency, or unreli a ble networks. Key Fe a tures • Simple a nd e a sy to implement. • Low b a ndwidth consumption. • Reli a ble mess a ge delivery. • Sc a l a ble to millions of devices. 30
  16. MQTT Architecture Broker • The centr a l server th

    a t h a ndles mess a ge distribution. • Ex a mples: Mosquitto, HiveMQ, EMQX, AWS MQ. Clients • Devices or a pplic a tions th a t publish (send) a nd subscribe (receive) mess a ges. • Ex a mples: Sensors, mobile a pps, a nd IoT devices. Topics • Hier a rchic a l n a mesp a ces for org a nizing mess a ges. • Ex a mple: home/livingRoom/temper a ture. 31
  17. MQTT Work f low Connect • Clients connect to the

    broker. Subscribe • Clients subscribe to topics of interest. Publish • Clients publish mess a ges to topics. Receive • Clients receive mess a ges from topics they a re subscribed to. Disconnect • Clients disconnect from the broker. 32
  18. Eclipse Paho for Java Wh a t is Eclipse P

    a ho? • A set of MQTT client libr a ries developed by the Eclipse Found a tion. • It supports multiple l a ngu a ges, such a s J a v a , Python, J a v a Script, etc. J a v a Dependency (M a ven) <dependency> <groupId>org.eclipse.paho</groupId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId> <version>1.2.5</version> </dependency> 36
  19. Quality-of-service options • 0 – "at most once": A.K.A. "fire-and-forget."

    This option is suitable when message loss is acceptable, as it doesn't require acknowledgment or persistence. • 1 – "at least once": This option should be chosen when message loss is unacceptable, and your subscribers can handle duplicate messages. • 2 – "Exactly once": This option is ideal when message loss is unacceptable, and your subscribers cannot handle duplicate messages. 39
  20. CSC 570 Applied Affective Computing Javier Gonzalez-Sanchez, Ph.D. [email protected] Spring

    2025 Copyright. These slides can only be used as study material for the class CSC 570 at Cal Poly. They cannot be distributed or used for another purpose.