{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "\n",
    "colorDic = {\"blue\" : \"#6599FF\", \"yellow\" : \"#FFAD33\",  \"purple\": \"#683b96\", \"green\" : \"#198D6D\", \"red\" : \"#FF523F\"}\n",
    "colors = list(colorDic.values())\n",
    "\n",
    "lables = [\"Finger\", \"Knuckle\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 50,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfTLX = pd.read_csv(\"./DataStudyEvaluation/Knuckle Study - TLX.csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfTLX['Score'] = dfTLX['Mental Demand'] + dfTLX['Physical Demand'] + dfTLX['Temporal Demand'] + dfTLX['Performance'] + dfTLX['Effort'] + dfTLX['Frustration']\n",
    "dfTLX['Score'] = (dfTLX['Score']-6) / 6.0 "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 58,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.axes._subplots.AxesSubplot at 0x7f526f0b9e48>"
      ]
     },
     "execution_count": 58,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 14848 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "dfTLX.groupby(\"Task\").mean().plot(kind=\"bar\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0, 20)"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 6072 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "M = dfTLX.groupby(\"Task\").mean().Score.values\n",
    "STD = dfTLX.groupby(\"Task\").std().Score.values\n",
    "plt.bar([0], M[0], yerr=STD[0], color=colors[1])\n",
    "plt.bar([1], M[1], yerr=STD[1], color=colors[3])\n",
    "plt.xticks([0,1], lables)\n",
    "plt.ylim(0,20)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 147,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\\ac{RTLX}   & 2.0 & 1.6 & 6.6 & 2.5 \\\\\n"
     ]
    }
   ],
   "source": [
    "s = \"\\\\ac{RTLX}  \"\n",
    "c = \"Score\"\n",
    "for con in [\"Finger\", \"Knuckle\"]:\n",
    "    s = \"%s & %.1f\" % (s, dfTLX[dfTLX.Task == con].mean()[c])\n",
    "    s = \"%s & %.1f\" % (s, dfTLX[dfTLX.Task == con].std()[c])\n",
    "print(s + \" \\\\\\\\\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 141,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfTLX[[\"ID\", \"Task\", \"Score\"]].to_csv(\"./DataStudyEvaluation/R_TLX.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 137,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfSUS = pd.read_csv(\"./DataStudyEvaluation/Knuckle Study - SUS.csv\")\n",
    "dfSUS.Q1 = dfSUS.Q1 - 1\n",
    "dfSUS.Q3 = dfSUS.Q3 - 1\n",
    "dfSUS.Q5 = dfSUS.Q5 - 1\n",
    "dfSUS.Q7 = dfSUS.Q7 - 1\n",
    "dfSUS.Q9 = dfSUS.Q9 - 1\n",
    "\n",
    "dfSUS.Q2 = 5 - dfSUS.Q2\n",
    "dfSUS.Q4 = 5 - dfSUS.Q4\n",
    "dfSUS.Q6 = 5 - dfSUS.Q6\n",
    "dfSUS.Q8 = 5 - dfSUS.Q8\n",
    "dfSUS.Q10 = 5 - dfSUS.Q10\n",
    "dfSUS[\"Score\"] = dfSUS.Q1 + dfSUS.Q2 + dfSUS.Q3 + dfSUS.Q4 + dfSUS.Q5 + dfSUS.Q6 + dfSUS.Q7 + dfSUS.Q8 + dfSUS.Q9 + dfSUS.Q10\n",
    "dfSUS.Score = dfSUS.Score * 2.5"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 138,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(0, 100)"
      ]
     },
     "execution_count": 138,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 4736 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "M = dfSUS.groupby(\"Task\").mean().Score.values\n",
    "STD = dfSUS.groupby(\"Task\").std().Score.values\n",
    "plt.bar([0], M[0], yerr=STD[0], color=colors[1])\n",
    "plt.bar([1], M[1], yerr=STD[1], color=colors[3])\n",
    "plt.xticks([0,1], lables)\n",
    "plt.ylim(0,100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 146,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "SUS   & 89.6 & 8.8 & 57.9 & 16.1 \\\\\n"
     ]
    }
   ],
   "source": [
    "s = \"SUS  \"\n",
    "c = \"Score\"\n",
    "for con in [\"Finger\", \"Knuckle\"]:\n",
    "    s = \"%s & %.1f\" % (s, dfSUS[dfSUS.Task == con].mean()[c])\n",
    "    s = \"%s & %.1f\" % (s, dfSUS[dfSUS.Task == con].std()[c])\n",
    "print(s + \" \\\\\\\\\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 140,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfSUS[[\"ID\", \"Task\", \"Score\"]].to_csv(\"./DataStudyEvaluation/R_SUS.csv\", index=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfQ = pd.read_csv(\"./DataStudyEvaluation/Knuckle Study - Quest..csv\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "metadata": {},
   "outputs": [],
   "source": [
    "cols = ['Difficult-Easy', 'Slow-Fast', 'Frustrated-Successful', 'Inaccurate-Accurate', 'Straining-Comfortable']\n",
    "lablesQ = ['Easiness', 'Speed', 'Success', 'Accuracy', 'Comfort']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Easiness  & 6.7 & 0.8 & 4.8 & 1.6 \\\\\n",
      "Speed  & 6.7 & 0.5 & 2.9 & 1.2 \\\\\n",
      "Success  & 6.1 & 1.6 & 3.6 & 1.7 \\\\\n",
      "Accuracy  & 6.2 & 1.3 & 3.4 & 1.4 \\\\\n",
      "Comfort  & 6.7 & 0.7 & 3.1 & 1.4 \\\\\n"
     ]
    }
   ],
   "source": [
    "for i, c in enumerate(cols):\n",
    "    s = lablesQ[i] + \" \"\n",
    "    for con in [\"Finger\", \"Knuckle\"]:\n",
    "        s = \"%s & %.1f\" % (s, dfQ[dfQ.Task == con].mean()[c])\n",
    "        s = \"%s & %.1f\" % (s, dfQ[dfQ.Task == con].std()[c])\n",
    "    print(s + \" \\\\\\\\\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1, 7)"
      ]
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 6168 characters]\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "M = dfQ[dfQ.Task == \"Knuckle\"].mean()[cols]\n",
    "STD = dfQ[dfQ.Task == \"Knuckle\"].std()[cols]\n",
    "plt.bar(np.array(np.arange(len(M))) -0.2, M, yerr=STD, width=.4,  color=colors[1])\n",
    "\n",
    "M = dfQ[dfQ.Task == \"Finger\"].mean()[cols]\n",
    "STD = dfQ[dfQ.Task == \"Finger\"].std()[cols]\n",
    "plt.bar(np.array(np.arange(len(M))) +0.2, M, yerr=STD, width=.4, color=colors[3])\n",
    "plt.xticks(list(range(len(M))), lablesQ)\n",
    "plt.ylim(1,7)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 136,
   "metadata": {},
   "outputs": [],
   "source": [
    "dfX = dfQ.copy(deep=True)\n",
    "lst = dfX.columns[:2].to_list()\n",
    "lst.extend(lablesQ)\n",
    "dfX.columns = lst\n",
    "dfX.to_csv(\"./DataStudyEvaluation/R_Quest.csv\", index=False)"
   ]
  }
 ],
 "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.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
