Scheduled service maintenance on November 22


On Friday, November 22, 2024, between 06:00 CET and 18:00 CET, GIN services will undergo planned maintenance. Extended service interruptions should be expected. We will try to keep downtimes to a minimum, but recommend that users avoid critical tasks, large data uploads, or DOI requests during this time.

We apologize for any inconvenience.

1
0
Selaa lähdekoodia

tested light switch in the main aSIT

dianamaro 3 vuotta sitten
vanhempi
commit
350cf4d386
3 muutettua tiedostoa jossa 30 lisäystä ja 52 poistoa
  1. 22 46
      aSIT.ipynb
  2. 2 2
      controllers/position.ipynb
  3. 6 4
      settings.json

+ 22 - 46
aSIT.ipynb

@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 73,
+   "execution_count": 48,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -44,7 +44,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 74,
+   "execution_count": 49,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -53,7 +53,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 75,
+   "execution_count": 50,
    "metadata": {
     "scrolled": false
    },
@@ -69,7 +69,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 76,
+   "execution_count": 51,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -91,7 +91,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 77,
+   "execution_count": 52,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -108,7 +108,8 @@
     "cfg['position']['file_path'] = os.path.join(save_to, 'positions.csv')\n",
     "cfg['experiment']['file_path'] = os.path.join(save_to, 'events.csv')\n",
     "cfg['sound']['file_path'] = os.path.join(save_to, 'sounds.csv')\n",
-    "cfg['position']['background_file'] = os.path.join('assets', cfg['position']['background_file'])\n",
+    "cfg['position']['background_light'] = os.path.join('assets', cfg['position']['background_light'])\n",
+    "cfg['position']['background_dark'] = os.path.join('assets', cfg['position']['background_dark'])\n",
     "    \n",
     "# Saves all parameters to a JSON file with the user-defined \"Experiment ID\" as filename\n",
     "with open(os.path.join(save_to, experiment_id + '.json'), 'w') as f:\n",
@@ -121,7 +122,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 78,
+   "execution_count": 53,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -136,7 +137,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 79,
+   "execution_count": 54,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -154,7 +155,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 80,
+   "execution_count": 55,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -164,7 +165,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 81,
+   "execution_count": 56,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -175,11 +176,12 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 1,
+   "execution_count": 57,
    "metadata": {},
    "outputs": [],
    "source": [
     "def switch_light(pt, board):\n",
+    "    print('Switching BG..')\n",
     "    pt.switch_background()\n",
     "    board.switch_light()"
    ]
@@ -201,7 +203,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 82,
+   "execution_count": null,
    "metadata": {
     "scrolled": false
    },
@@ -210,11 +212,7 @@
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Webcam stream 1024.0:768.0 at 20.00 FPS started\n",
-      "Fake Arduino - exiting...\n",
-      "Position tracker stopped\n",
-      "Video writer stopped\n",
-      "Camera released\n"
+      "Webcam stream 1024.0:768.0 at 20.00 FPS started\n"
      ]
     }
    ],
@@ -332,6 +330,9 @@
     "        if target_since is not None:\n",
     "            cv2.putText(frame, 'In target: %.2f' % float(c_time - target_since), (10, 670), cv2.FONT_HERSHEY_DUPLEX, .5, COLORS['white'])\n",
     "        \n",
+    "        # Light or dark period\n",
+    "        cv2.putText(frame, 'Light' if pt.is_light else 'Dark', (10, 690), cv2.FONT_HERSHEY_DUPLEX, .5, (255, 255, 255))            \n",
+    "        \n",
     "        # assign the frame back to the video stream for other controllers\n",
     "        vs.frame_with_infos = frame\n",
     "        \n",
@@ -431,7 +432,7 @@
     "                \n",
     "                # init light events\n",
     "                timers = []\n",
-    "                for event_t = cfg_exp['light_events']:\n",
+    "                for event_t in cfg_exp['light_events']:\n",
     "                    timers.append(threading.Timer(event_t, switch_light, args=(pt, board)))                \n",
     "                for t in timers:\n",
     "                    t.start()\n",
@@ -467,7 +468,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 83,
+   "execution_count": null,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -477,34 +478,9 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 84,
+   "execution_count": null,
    "metadata": {},
-   "outputs": [
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "postprocessing.ipynb:35: UserWarning: loadtxt: Empty input file: \"sessions\\47_aSIT_2021-08-11_16-03-25\\positions.csv\"\n",
-      "  \"    \\n\",\n",
-      "postprocessing.ipynb:35: UserWarning: loadtxt: Empty input file: \"sessions\\47_aSIT_2021-08-11_16-03-25\\events.csv\"\n",
-      "  \"    \\n\",\n",
-      "postprocessing.ipynb:35: UserWarning: loadtxt: Empty input file: \"sessions\\47_aSIT_2021-08-11_16-03-25\\sounds.csv\"\n",
-      "  \"    \\n\",\n"
-     ]
-    },
-    {
-     "ename": "IndexError",
-     "evalue": "too many indices for array: array is 1-dimensional, but 2 were indexed",
-     "output_type": "error",
-     "traceback": [
-      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
-      "\u001b[1;31mIndexError\u001b[0m                                Traceback (most recent call last)",
-      "\u001b[1;32m<ipython-input-84-74648d1531a4>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m      1\u001b[0m \u001b[1;31m# do pack data to HDF5\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 2\u001b[1;33m \u001b[0mh5name\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mpack\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0msession_path\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
-      "\u001b[1;32mD:\\runSIT\\postprocessing.ipynb\u001b[0m in \u001b[0;36mpack\u001b[1;34m(session_path)\u001b[0m\n\u001b[0;32m     52\u001b[0m     \u001b[1;34m\"    h5name = os.path.join(session_path, '%s.h5' % params_file.split('.')[0])\\n\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     53\u001b[0m     \u001b[1;34m\"    with h5py.File(h5name, 'w') as f:  # overwrite mode\\n\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 54\u001b[1;33m     \u001b[1;34m\"\\n\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m     55\u001b[0m     \u001b[1;34m\"\\n\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m     56\u001b[0m     \u001b[1;34m\"        # -------- save raw data ------------\\n\"\u001b[0m\u001b[1;33m,\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
-      "\u001b[1;31mIndexError\u001b[0m: too many indices for array: array is 1-dimensional, but 2 were indexed"
-     ]
-    }
-   ],
+   "outputs": [],
    "source": [
     "# do pack data to HDF5\n",
     "h5name = pack(session_path)"

+ 2 - 2
controllers/position.ipynb

@@ -141,8 +141,8 @@
     }
    ],
    "source": [
-    "import nbimporter\n",
-    "from camera import WebcamStream\n",
+    "#import nbimporter\n",
+    "#from camera import WebcamStream\n",
     "\n",
     "with open(os.path.join('..', 'settings.json')) as json_file:\n",
     "    cfg = json.load(json_file)\n",

+ 6 - 4
settings.json

@@ -12,7 +12,8 @@
         "file_path": "video.avi"
     },
     "position": {
-        "background_file": "background_dark.png",
+        "background_light": "background_light.png",
+        "background_dark": "background_dark.png",
         "arena_x": 522,
         "arena_y": 372,
         "arena_radius": 330,
@@ -24,7 +25,7 @@
         "device": [1, 26],
         "n_channels": 4,
         "sounds": [
-            {"freq": 20000, "amp": 0.13, "channels": [1, 3]},
+            {"freq": 10000, "amp": 0.13, "channels": [1, 3]},
             {"freq": 660, "amp": 0.05, "channels": [1, 3]}, 
             {"freq": 860, "amp": 0.15, "channels": [1, 3]}, 
             {"freq": 1060, "amp": 0.25, "channels": [1, 3]},
@@ -51,7 +52,8 @@
         "init_duration": 0.2,
         "distractor_island": 0,
         "capture_background": false,
-        "MCSArduinoPort": "fake",
-        "file_path": "events.csv"
+        "MCSArduinoPort": "COM10",
+        "file_path": "events.csv",
+        "light_events": []
     }
 }