{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "669ce28c",
   "metadata": {
    "jupyter": {
     "source_hidden": true
    },
    "nbsphinx": "hidden",
    "tags": []
   },
   "outputs": [],
   "source": [
    "import sys\n",
    "import os\n",
    "\n",
    "sys.path.append('../../../')\n",
    "\n",
    "from bci_framework.utils import Paradigm\n",
    "from matplotlib import pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "9b0358cd",
   "metadata": {
    "collapsed": true,
    "jupyter": {
     "outputs_hidden": true,
     "source_hidden": true
    },
    "nbsphinx": "hidden",
    "tags": []
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'plt' is not defined",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-2-daf86705fd30>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mfig\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mplt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfigure\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfigsize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m10\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m4\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdpi\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m90\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m paradigm = (\n\u001b[1;32m      4\u001b[0m     {\n\u001b[1;32m      5\u001b[0m         \u001b[0;34m'time'\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;34m-\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m0\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'plt' is not defined"
     ]
    }
   ],
   "source": [
    "fig = plt.figure(figsize=(10, 4), dpi=90)\n",
    "\n",
    "paradigm = (\n",
    "    {\n",
    "        'time': (-3, 0),\n",
    "        'level': (0.5, 1),        \n",
    "        'label': 'Fixation cross',\n",
    "        'color': 'C0',\n",
    "    },\n",
    "    {\n",
    "        'time': (0, -1, -3),\n",
    "        'level': (0, 0.5),    \n",
    "        'label': 'Stimulus onset\\nasynchronously',\n",
    "        'color': 'C3',\n",
    "    },       \n",
    "    {\n",
    "        'time': (0, 2, 6),\n",
    "        'label': 'Cue',\n",
    "        'color': 'C2',\n",
    "        'rotation': 90,\n",
    "        'marker': {\n",
    "            'label': 'Marker streamed',\n",
    "            'width': 2,\n",
    "            'level': 1,\n",
    "        }\n",
    "    },   \n",
    ")\n",
    "\n",
    "Paradigm.build_paradigm(paradigm)\n",
    "plt.savefig('paradigm.png')"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7ddb0edc",
   "metadata": {},
   "source": [
    "# 4-Class motor imagery (Arrows)\n",
    "\n",
    "Implemented through extensions systems in the [FourClassMotorImagery](../../../../_modules/bci_framework.default_extensions.Class_motor_imagery.main.rst) module.\n",
    "\n",
    "<img src='paradigm.png'></img>\n",
    "\n",
    "This cue-based BCI paradigm consisted of up to four different motor imagery tasks, represented by a succession of cues (arrow-shaped) and separated with an asynchronous break. This paradigm used an arrow pointing to the left right, up or bottom, which has been widely used <cite data-footcite=\"choi2013electroencephalography, llanos2013mu\">choi2013electroencephalography, llanos2013mu</cite>."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "08eccc9b",
   "metadata": {},
   "source": [
    "## Configuration options\n",
    "\n",
    "<img src='../../../images/extensions/4class_mi.gif'></img>\n",
    "\n",
    "**Cues:**  \n",
    "Is possible to select up to 4 classes, represented by one arrow. All 4 classes are active by default.\n",
    "\n",
    "**Trials per class:**  \n",
    "How many trials per class will contain the run. Between 1 and 100, 10 by default.\n",
    "\n",
    "**Stimulus duration:**  \n",
    "The time in milliseconds that will display the cue on screen. Between 2000 and 6000 ms, 4000 by default\n",
    "\n",
    "**Stimulus onset asynchronously:**  \n",
    "To prevent fixed time between trials. A range between 1000 and 3000 ms, (2000-3000) by default. This means that for each trial a random number (with uniform distribution) is generated between this range and used as inter stimulus interval."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6a6c2aa3",
   "metadata": {},
   "source": [
    "### References\n",
    ".. footbibliography::"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
