diff --git a/.idea/PythonProject.iml b/.idea/PythonProject.iml index d8b3f6c..f571432 100644 --- a/.idea/PythonProject.iml +++ b/.idea/PythonProject.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/GUI/pantalla.py b/GUI/pantalla.py new file mode 100644 index 0000000..08386ad --- /dev/null +++ b/GUI/pantalla.py @@ -0,0 +1,62 @@ +import pygame + +# Inicializar pygame +pygame.init() + +# Configuración de la pantalla +ANCHO, ALTO = 600, 400 # Puedes cambiar el tamaño +TERCIO_ANCHO = ANCHO // 3 + +screen = pygame.display.set_mode((ANCHO, ALTO)) +pygame.display.set_caption("Cambio de colores con teclas") + +# Fuente para el texto +font = pygame.font.Font(None, 36) + + +# Variables para controlar la iluminación +i_presionado = False +d_presionado = False +espacio_presionado = False + +# Bucle principal +running = True +while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT: + running = False + elif event.type == pygame.KEYDOWN: + if event.key == pygame.K_i: + i_presionado = True + elif event.key == pygame.K_d: + d_presionado = True + elif event.key == pygame.K_SPACE: + espacio_presionado = True + elif event.type == pygame.KEYUP: + if event.key == pygame.K_i: + i_presionado = False + elif event.key == pygame.K_d: + d_presionado = False + elif event.key == pygame.K_SPACE: + espacio_presionado = False + + # Fondo en blanco + screen.fill((255, 255, 255)) + + # Dibujar los rectángulos si se presionan teclas + if i_presionado: + pygame.draw.rect(screen, (255, 0, 0), (0, 0, TERCIO_ANCHO, ALTO)) + text_surface = font.render("Izquierda", True, (0, 0, 0)) + screen.blit(text_surface, (TERCIO_ANCHO // 2 - text_surface.get_width() // 2, 20)) + if d_presionado: + pygame.draw.rect(screen, (0, 255, 0), (2 * TERCIO_ANCHO, 0, TERCIO_ANCHO, ALTO)) + text_surface = font.render("Derecha", True, (0, 0, 0)) + screen.blit(text_surface, (2 * TERCIO_ANCHO + TERCIO_ANCHO // 2 - text_surface.get_width() // 2, 20)) + # Mostrar texto solo cuando se presiona espacio + if espacio_presionado: + text_surface = font.render("None", True, (0, 0, 0)) + screen.blit(text_surface, (ANCHO // 2 - text_surface.get_width() // 2, ALTO // 2)) + + pygame.display.flip() + +pygame.quit() \ No newline at end of file diff --git a/TestEtiquetado.ipynb b/TestEtiquetado.ipynb index abf76c7..9786a29 100644 --- a/TestEtiquetado.ipynb +++ b/TestEtiquetado.ipynb @@ -2,88 +2,86 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, "id": "5fe31b7f-2243-4587-9740-46164846cff3", "metadata": { - "ExecuteTime": { - "end_time": "2025-02-13T20:09:41.300262Z", - "start_time": "2025-02-13T20:09:41.297886Z" - }, "collapsed": true, "jupyter": { "outputs_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-03-02T19:13:55.436438Z", + "start_time": "2025-03-02T19:13:46.916154Z" } }, - "outputs": [], "source": [ "import os\n", "import matplotlib\n", "import pandas as pd\n", "from datetime import datetime, timezone\n", "import zoneinfo\n" - ] + ], + "outputs": [], + "execution_count": 1 }, { "cell_type": "code", - "execution_count": 2, "id": "cbb445af-6351-43b0-8142-f9aa35388e6e", "metadata": { - "ExecuteTime": { - "end_time": "2025-02-13T20:09:41.308855Z", - "start_time": "2025-02-13T20:09:41.306360Z" - }, "collapsed": true, "jupyter": { "outputs_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-03-02T19:13:55.474641Z", + "start_time": "2025-03-02T19:13:55.449280Z" } }, - "outputs": [], "source": [ "logs_path = \"join/mergedLog_output.txt\"\n", "openbci_path = \"join/mergedData_output.txt\"\n", "output_csv_path = \"OpenBCI_with_labels.csv\"\n", "label_name = \"Movement\"\n", "timestamp_col=\"Timestamp\"" - ] + ], + "outputs": [], + "execution_count": 2 }, { "cell_type": "code", - "execution_count": 3, "id": "f613abe9-8d5b-444c-af3c-b0ab826ed3f4", "metadata": { - "ExecuteTime": { - "end_time": "2025-02-13T20:09:43.026443Z", - "start_time": "2025-02-13T20:09:41.323419Z" - }, "collapsed": true, "jupyter": { "outputs_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-03-02T19:13:57.903721Z", + "start_time": "2025-03-02T19:13:55.482610Z" } }, - "outputs": [], "source": [ "# Leer los logs y extraer tiempos y etiquetas\n", "with open(logs_path, \"r\") as logs_file:\n", " logs_data = [log.strip().split(\",\") for log in logs_file.readlines()]\n", "with open(openbci_path, \"r\") as openbci_file:\n", " lineas = [linea.strip().split(\",\") for linea in openbci_file.readlines() if not linea.strip().startswith('%')]" - ] + ], + "outputs": [], + "execution_count": 3 }, { "cell_type": "code", - "execution_count": 4, "id": "d8eba4ab-63ee-40f5-b30d-f8ae58d5aa79", "metadata": { - "ExecuteTime": { - "end_time": "2025-02-13T20:09:43.043659Z", - "start_time": "2025-02-13T20:09:43.039923Z" - }, "collapsed": true, "jupyter": { "outputs_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-03-02T19:13:58.869318Z", + "start_time": "2025-03-02T19:13:58.856580Z" } }, - "outputs": [], "source": [ "# Utility functions\n", "def remove_columns(df, columns):\n", @@ -104,25 +102,90 @@ " else:\n", " data.loc[mask, label_name] = label.strip()\n", " return True" - ] + ], + "outputs": [], + "execution_count": 4 }, { "cell_type": "code", - "execution_count": 5, "id": "1ecf8906-828c-4e13-a267-2b96f61e2c2e", "metadata": { - "ExecuteTime": { - "end_time": "2025-02-13T20:09:46.253744Z", - "start_time": "2025-02-13T20:09:43.057864Z" - }, "collapsed": true, "jupyter": { "outputs_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-03-02T19:14:07.618668Z", + "start_time": "2025-03-02T19:13:58.903011Z" } }, + "source": [ + "#Convertir los datos en un DataFrame\n", + "columns = \"Sample Index, EXG Channel 0, EXG Channel 1, EXG Channel 2, EXG Channel 3, EXG Channel 4, EXG Channel 5, EXG Channel 6, EXG Channel 7, EXG Channel 8, EXG Channel 9, EXG Channel 10, EXG Channel 11, EXG Channel 12, EXG Channel 13, EXG Channel 14, EXG Channel 15, Accel Channel 0, Accel Channel 1, Accel Channel 2, Not_Used1, Digital Channel 0 (D11), Digital Channel 1 (D12), Digital Channel 2 (D13), Digital Channel 3 (D17), Not_Used2, Digital Channel 4 (D18), Analog Channel 0, Analog Channel 1, Analog Channel 2, Timestamp, Marker Channel, Timestamp (Formatted)\".split(\",\")\n", + "columns = [column.strip() for column in columns]\n", + "types = {}\n", + "\n", + "data_df = pd.DataFrame(lineas, columns=columns)\n", + "exceptions = [\"Timestamp (Formatted)\"]\n", + "\n", + "for column in data_df.columns:\n", + " if column in exceptions:\n", + " continue\n", + " data_df[column] = pd.to_numeric(data_df[column], errors='coerce')\n", + "remove_columns(data_df, [\"Not_Used1\", \"Not_Used2\", \"Timestamp (Formatted)\", \"Sample Index\"])\n", + "data_df[timestamp_col] = pd.to_datetime(data_df[timestamp_col], unit=\"s\", utc=True).dt.tz_convert(\"Europe/Madrid\")\n", + "# Create the label column\n", + "data_df[label_name]= \"\"\n", + "data_df.head()" + ], "outputs": [ { "data": { + "text/plain": [ + " EXG Channel 0 EXG Channel 1 EXG Channel 2 EXG Channel 3 EXG Channel 4 \\\n", + "0 19162.754019 10400.132585 -26819.835820 -10368.437811 -17614.694549 \n", + "1 38187.821291 20561.995573 -53613.967134 -20684.863113 -36268.231126 \n", + "2 37916.314652 20446.347647 -53464.702185 -20528.311494 -36279.362295 \n", + "3 38343.098860 20722.995189 -53693.628751 -20771.207901 -35548.817879 \n", + "4 37910.905529 20389.820086 -53463.472839 -20529.742006 -36741.171687 \n", + "\n", + " EXG Channel 5 EXG Channel 6 EXG Channel 7 EXG Channel 8 EXG Channel 9 \\\n", + "0 175.684711 -23469.398733 -13855.980498 -20491.900503 -22635.343389 \n", + "1 361.517115 -46906.543899 -27692.805552 4671.916923 -32254.126043 \n", + "2 -755.690128 -46767.136069 -27537.952666 4684.500955 -32010.313214 \n", + "3 628.978089 -47001.941145 -27767.415675 4760.072203 -32191.876434 \n", + "4 -392.630743 -46768.946560 -27551.766044 4555.129058 -32183.382771 \n", + "\n", + " ... Digital Channel 1 (D12) Digital Channel 2 (D13) \\\n", + "0 ... 112.0 15.5 \n", + "1 ... 0.0 0.0 \n", + "2 ... 0.0 0.0 \n", + "3 ... 0.0 0.0 \n", + "4 ... 104.0 15.5 \n", + "\n", + " Digital Channel 3 (D17) Digital Channel 4 (D18) Analog Channel 0 \\\n", + "0 120.0 16.0 0.0 \n", + "1 0.0 0.0 0.0 \n", + "2 0.0 0.0 0.0 \n", + "3 0.0 0.0 0.0 \n", + "4 112.0 120.0 0.0 \n", + "\n", + " Analog Channel 1 Analog Channel 2 Timestamp \\\n", + "0 0.0 0.0 2025-01-27 17:31:42.443204641+01:00 \n", + "1 0.0 0.0 2025-01-27 17:31:42.443370104+01:00 \n", + "2 0.0 0.0 2025-01-27 17:31:42.443432808+01:00 \n", + "3 0.0 0.0 2025-01-27 17:31:42.443464756+01:00 \n", + "4 0.0 0.0 2025-01-27 17:31:42.443489552+01:00 \n", + "\n", + " Marker Channel Movement \n", + "0 0.0 \n", + "1 0.0 \n", + "2 0.0 \n", + "3 0.0 \n", + "4 0.0 \n", + "\n", + "[5 rows x 30 columns]" + ], "text/html": [ "
\n", "