Browse Source

fixed PR-SIT bugs

Andrey Sobolev 1 year ago
parent
commit
c32f5ac8fc
3 changed files with 38 additions and 21 deletions
  1. 26 9
      SIT-PR.ipynb
  2. 10 11
      controllers/sound.ipynb
  3. 2 1
      controllers/sound.py

+ 26 - 9
SIT-PR.ipynb

@@ -205,14 +205,17 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "Webcam stream 1024.0:768.0 at 30.00 FPS started\n"
+      "Webcam stream 1024.0:768.0 at 30.00 FPS started\n",
+      "Position tracker stopped\n",
+      "Video writer stopped\n",
+      "Camera released\n"
      ]
     }
    ],
@@ -362,9 +365,9 @@
     "                            islands = isl_factory.generate_target(pt.hds)  # island near the speaker\n",
     "                            log_islands(islands)  # log island(s) positions\n",
     "                            tgt = [i for i in islands if not i.is_distractor][0]\n",
-    "                            log_event(c_time, round(tgt.x, 4), round(tgt.y, 4), round(tgt.r, 4), trial, 0)\n",
     "                            phase = 1  # trial phase\n",
     "                            trial += 1\n",
+    "                            log_event(c_time, round(tgt.x, 4), round(tgt.y, 4), round(tgt.r, 4), trial, 0)\n",
     "                            iti_distance = 0\n",
     "                            phase_start = c_time\n",
     "                            target_since = None\n",
@@ -479,7 +482,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -490,9 +493,23 @@
   },
   {
    "cell_type": "code",
-   "execution_count": null,
+   "execution_count": 12,
    "metadata": {},
-   "outputs": [],
+   "outputs": [
+    {
+     "ename": "ValueError",
+     "evalue": "Wrong number of columns at line 3",
+     "output_type": "error",
+     "traceback": [
+      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
+      "\u001b[1;31mValueError\u001b[0m                                Traceback (most recent call last)",
+      "Cell \u001b[1;32mIn [12], line 5\u001b[0m\n\u001b[0;32m      2\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mSystemExit\u001b[39;00m(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mNothing recorded. No sense to continue.\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[0;32m      4\u001b[0m \u001b[38;5;66;03m# do pack data to HDF5\u001b[39;00m\n\u001b[1;32m----> 5\u001b[0m h5name \u001b[38;5;241m=\u001b[39m \u001b[43mpack\u001b[49m\u001b[43m(\u001b[49m\u001b[43msession_path\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m      6\u001b[0m trial \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m0\u001b[39m\n",
+      "File \u001b[1;32mD:\\code\\runSIT\\..\\pipeline\\postprocessing\\pack.py:59\u001b[0m, in \u001b[0;36mpack\u001b[1;34m(session_path)\u001b[0m\n\u001b[0;32m     57\u001b[0m \u001b[38;5;28;01mwith\u001b[39;00m \u001b[38;5;28mopen\u001b[39m(filename) \u001b[38;5;28;01mas\u001b[39;00m ff:\n\u001b[0;32m     58\u001b[0m     headers \u001b[38;5;241m=\u001b[39m ff\u001b[38;5;241m.\u001b[39mreadline()\n\u001b[1;32m---> 59\u001b[0m data \u001b[38;5;241m=\u001b[39m \u001b[43mnp\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mloadtxt\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfilename\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mdelimiter\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[38;5;124;43m,\u001b[39;49m\u001b[38;5;124;43m'\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mskiprows\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[0;32m     61\u001b[0m ds \u001b[38;5;241m=\u001b[39m raw\u001b[38;5;241m.\u001b[39mcreate_dataset(ds_name, data\u001b[38;5;241m=\u001b[39mdata)\n\u001b[0;32m     62\u001b[0m ds\u001b[38;5;241m.\u001b[39mattrs[\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mheaders\u001b[39m\u001b[38;5;124m'\u001b[39m] \u001b[38;5;241m=\u001b[39m headers\n",
+      "File \u001b[1;32mC:\\ProgramData\\Miniconda3\\envs\\P-SIT2\\lib\\site-packages\\numpy\\lib\\npyio.py:1159\u001b[0m, in \u001b[0;36mloadtxt\u001b[1;34m(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows, like)\u001b[0m\n\u001b[0;32m   1157\u001b[0m     words \u001b[38;5;241m=\u001b[39m usecols_getter(words)\n\u001b[0;32m   1158\u001b[0m \u001b[38;5;28;01melif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(words) \u001b[38;5;241m!=\u001b[39m ncols:\n\u001b[1;32m-> 1159\u001b[0m     \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mValueError\u001b[39;00m(\n\u001b[0;32m   1160\u001b[0m         \u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mWrong number of columns at line \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mlineno\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m   1161\u001b[0m \u001b[38;5;66;03m# Convert each value according to its column, then pack it\u001b[39;00m\n\u001b[0;32m   1162\u001b[0m \u001b[38;5;66;03m# according to the dtype's nesting, and store it.\u001b[39;00m\n\u001b[0;32m   1163\u001b[0m chunk\u001b[38;5;241m.\u001b[39mappend(packer(convert_row(words)))\n",
+      "\u001b[1;31mValueError\u001b[0m: Wrong number of columns at line 3"
+     ]
+    }
+   ],
    "source": [
     "if not trial > 0:\n",
     "    raise SystemExit('Nothing recorded. No sense to continue.')\n",
@@ -557,7 +574,7 @@
     "\n",
     "# occupancy\n",
     "sigma = 0.1\n",
-    "lin_profile = np.linspace(-15, 15, 20)\n",
+    "lin_profile = np.linspace(-15, 15, 20) \n",
     "bump = np.exp(-sigma * lin_profile**2)\n",
     "bump /= np.trapz(bump)  # normalize to 1\n",
     "kernel = bump[:, np.newaxis] * bump[np.newaxis, :]\n",
@@ -681,7 +698,7 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 3",
+   "display_name": "Python 3 (ipykernel)",
    "language": "python",
    "name": "python3"
   },
@@ -695,7 +712,7 @@
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.8.8"
+   "version": "3.8.13"
   }
  },
  "nbformat": 4,

File diff suppressed because it is too large
+ 10 - 11
controllers/sound.ipynb


+ 2 - 1
controllers/sound.py

@@ -270,9 +270,10 @@ class SoundControllerPR:
         for ch in self.cfg['sounds']['noise']['channels']:
             to_play[:, ch-1] = self.sounds['noise']
         
+        ch1 = self.cfg['sounds']['noise']['channels'][0]
         t0 = time.time()
         with open(self.cfg['file_path'], 'a') as f:
-            f.write(",".join([str(x) for x in (t0, -1)]) + "\n")
+            f.write(",".join([str(x) for x in (t0, -1, ch1)]) + "\n")
         
         self.stream.write(to_play)