<commit_before>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Instructions for the subject:\n",
    "print(\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "input(\"Press enter to advance\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/jonaheisenberg/anaconda/lib/python3.5/site-packages/ipykernel/__main__.py:31: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future\n",
      "/Users/jonaheisenberg/anaconda/lib/python3.5/site-packages/ipykernel/__main__.py:34: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "\n",
    "\n",
    "## Set number of conditions and \n",
    "TargetSets      = np.array([2,4])\n",
    "DistractorSets  = np.array([0,2,4])\n",
    "nConds = TargetSets.size*DistractorSets.size\n",
    "nTrials = 720\n",
    "nTrialsPerCond = nTrials/nConds\n",
    "\n",
    "\n",
    "## set condition names and store\n",
    "conds = {};\n",
    "nTotalItemsPerCond = np.zeros(nConds)\n",
    "cnt = 1;\n",
    "for ts in range(TargetSets.size):\n",
    "    for ds in range(DistractorSets.size):\n",
    "        conds[cnt] = 'nT' + str(TargetSets[ts]) + 'nD' + str(DistractorSets[ds])\n",
    "        nTotalItemsPerCond[cnt-1] = int(TargetSets[ts]+DistractorSets[ds])\n",
    "        cnt += 1\n",
    "\n",
    "\n",
    "# Set trial conditions and counter balance\n",
    "TrialIDs = np.arange(nTrials)        # trial IDs\n",
    "AvailableTrials = np.array(TrialIDs) \n",
    "TrialCondIDs   = np.zeros(nTrials)   # individual trial condition\n",
    "ChangeTrialIDs = np.zeros(nTrials)   # test array changes at test\n",
    "nTrialItems    = np.zeros(nTrials,int)   # total number of trials per item\n",
    "\n",
    "for cond in range(nConds):\n",
    "    trials = np.random.choice(AvailableTrials,nTrialsPerCond,replace=False)\n",
    "    TrialCondIDs[trials] = cond+1\n",
    "    AvailableTrials = np.setxor1d(AvailableTrials,trials)\n",
    "    ChangeTrialIDs[np.random.choice(trials,nTrialsPerCond/2,replace=False)]=1\n",
    "    nTrialItems[trials] = nTotalItemsPerCond[cond]\n",
    "    \n",
    "assert AvailableTrials.size==0, 'Error Assigning Trials'\n",
    "hist=np.histogram(TrialCondIDs,range(1,nConds+2))[0]\n",
    "assert sum(hist==nTrialsPerCond)==nConds, 'Uneven Trials'\n",
    "\n",
    "\n",
    "# Set orientations and location for each item \n",
    "PossibleOrientations  = np.concatenate((np.arange(10,81),np.arange(100,171))); # in degrees\n",
    "OrientTrialItems = {}\n",
    "for tt in range(nTrials):\n",
    "    OrientTrialItems[tt] = np.random.choice(PossibleOrientations,nTrialItems[tt])\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'vwmArray' 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-3-04d8a7f8a34f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     33\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mblue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     34\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0mcondition\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 35\u001b[0;31m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     36\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     37\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'vwmArray' is not defined"
     ]
    }
   ],
   "source": [
    "responses = {}\n",
    "for i in range(nTrials):\n",
    "    condition = TrialCondIDs[i]\n",
    "    changeBinary = ChangeTrialIDs[i]\n",
    "    orientationArray = OrientTrialItems[i]\n",
    "    # LocateTrialItems[i]\n",
    "    rectangles = {}\n",
    "    if condition == 1:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "    if condition == 2:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(blue)\n",
    "        rectangles[4] = vwmArray.colorRect(blue)\n",
    "    if condition == 3:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(blue)\n",
    "        rectangles[4] = vwmArray.colorRect(blue)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "    if condition == 4:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "    if condition == 5:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "    if condition == 6:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "        rectangles[7] = vwmArray.colorRect(blue)\n",
    "        rectangles[8] = vwmArray.colorRect(blue)  \n",
    "    #add bi-directional cue here\n",
    "    wait(200)\n",
    "    #remove bi-directional cue\n",
    "    #add fixation cross here\n",
    "    wait(100)\n",
    "    for j in range(1, nTrialItems[i] + 1):\n",
    "        rectangles[j].rotate(orientationArray[j - 1])\n",
    "        rectangles[j].moveTo(locationsArray[j - 1])\n",
    "        add(rectangles[j])\n",
    "    wait(100)\n",
    "    for jj in range(1, nTrialItems[i] + 1):\n",
    "        remove(rectangles[jj]\n",
    "    wait(1000)\n",
    "    #add test array here, allow for response\n",
    "    wait(1000)\n",
    "    #remove test array here\n",
    "    remove(fixationCross)\n",
    "    #subject response code here\n",
    "    #wait 500-1000 ms or until response\n"
   ]
  }
 ],
 "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.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
<commit_msg>Nearing completion with trial loop<commit_after>{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "import numpy as np"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "# Instructions for the subject:\n",
    "print(\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "input(\"Press enter to advance\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/Users/jonaheisenberg/anaconda/lib/python3.5/site-packages/ipykernel/__main__.py:31: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future\n",
      "/Users/jonaheisenberg/anaconda/lib/python3.5/site-packages/ipykernel/__main__.py:34: DeprecationWarning: using a non-integer number instead of an integer will result in an error in the future\n"
     ]
    }
   ],
   "source": [
    "## Set number of conditions and \n",
    "TargetSets      = np.array([2,4])\n",
    "DistractorSets  = np.array([0,2,4])\n",
    "nConds = TargetSets.size*DistractorSets.size\n",
    "nTrials = 720\n",
    "nTrialsPerCond = nTrials/nConds\n",
    "\n",
    "\n",
    "## set condition names and store\n",
    "conds = {};\n",
    "nTotalItemsPerCond = np.zeros(nConds)\n",
    "cnt = 1;\n",
    "for ts in range(TargetSets.size):\n",
    "    for ds in range(DistractorSets.size):\n",
    "        conds[cnt] = 'nT' + str(TargetSets[ts]) + 'nD' + str(DistractorSets[ds])\n",
    "        nTotalItemsPerCond[cnt-1] = int(TargetSets[ts]+DistractorSets[ds])\n",
    "        cnt += 1\n",
    "\n",
    "\n",
    "# Set trial conditions and counter balance\n",
    "TrialIDs = np.arange(nTrials)        # trial IDs\n",
    "AvailableTrials = np.array(TrialIDs) \n",
    "TrialCondIDs   = np.zeros(nTrials)   # individual trial condition\n",
    "ChangeTrialIDs = np.zeros(nTrials)   # test array changes at test\n",
    "nTrialItems    = np.zeros(nTrials,int)   # total number of trials per item\n",
    "\n",
    "for cond in range(nConds):\n",
    "    trials = np.random.choice(AvailableTrials,nTrialsPerCond,replace=False)\n",
    "    TrialCondIDs[trials] = cond+1\n",
    "    AvailableTrials = np.setxor1d(AvailableTrials,trials)\n",
    "    ChangeTrialIDs[np.random.choice(trials,nTrialsPerCond/2,replace=False)]=1\n",
    "    nTrialItems[trials] = nTotalItemsPerCond[cond]\n",
    "    \n",
    "assert AvailableTrials.size==0, 'Error Assigning Trials'\n",
    "hist=np.histogram(TrialCondIDs,range(1,nConds+2))[0]\n",
    "assert sum(hist==nTrialsPerCond)==nConds, 'Uneven Trials'\n",
    "\n",
    "\n",
    "# Set orientations and location for each item \n",
    "PossibleOrientations  = np.concatenate((np.arange(10,81),np.arange(100,171))); # in degrees\n",
    "OrientTrialItems = {}\n",
    "for tt in range(nTrials):\n",
    "    OrientTrialItems[tt] = np.random.choice(PossibleOrientations,nTrialItems[tt])\n",
    "        "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "collapsed": true,
    "slideshow": {
     "slide_type": "-"
    }
   },
   "outputs": [
    {
     "ename": "NameError",
     "evalue": "name 'vwmArray' 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-3-04d8a7f8a34f>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m     33\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m6\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mblue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     34\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0mcondition\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;36m6\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 35\u001b[0;31m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     36\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m2\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     37\u001b[0m         \u001b[0mrectangles\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m3\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mvwmArray\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcolorRect\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mNameError\u001b[0m: name 'vwmArray' is not defined"
     ]
    }
   ],
   "source": [
    "responses = {}\n",
    "for i in range(nTrials):\n",
    "    # Set up conditions for this trial\n",
    "    condition = TrialCondIDs[i]\n",
    "    changeBinary = ChangeTrialIDs[i]\n",
    "    orientationArray = OrientTrialItems[i]\n",
    "    locationArray = LocateTrialItems[i]\n",
    "    rectangles = {}\n",
    "    if condition == 1:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "    elif condition == 2:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(blue)\n",
    "        rectangles[4] = vwmArray.colorRect(blue)\n",
    "    elif condition == 3:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(blue)\n",
    "        rectangles[4] = vwmArray.colorRect(blue)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "    elif condition == 4:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "    elif condition == 5:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "    else:\n",
    "        rectangles[1] = vwmArray.colorRect(red)\n",
    "        rectangles[2] = vwmArray.colorRect(red)\n",
    "        rectangles[3] = vwmArray.colorRect(red)\n",
    "        rectangles[4] = vwmArray.colorRect(red)\n",
    "        rectangles[5] = vwmArray.colorRect(blue)\n",
    "        rectangles[6] = vwmArray.colorRect(blue)\n",
    "        rectangles[7] = vwmArray.colorRect(blue)\n",
    "        rectangles[8] = vwmArray.colorRect(blue)  \n",
    "    # Displays bi-directional cue on the screen for 200 ms\n",
    "    bidirectionalCue = vwmArray.bidirectionalCue()\n",
    "    add(bidirectionalCue)\n",
    "    wait(200)\n",
    "    remove(bidirectionalCue)\n",
    "    # Displays fixation cross on the screen for 100 ms\n",
    "    fixationCross = vwmArray.fixationCross()\n",
    "    wait(100)\n",
    "    # Adds VWM Array rectangles to the screen\n",
    "    for j in range(1, nTrialItems[i] + 1):\n",
    "        rectangles[j].rotate(orientationArray[j - 1])\n",
    "        rectangles[j].moveTo(locationsArray[j - 1])\n",
    "        add(rectangles[j])\n",
    "    wait(100)\n",
    "    # Removes VWM Array rectangles from the screen\n",
    "    for jj in range(1, nTrialItems[i] + 1):\n",
    "        remove(rectangles[jj]\n",
    "    wait(1000)\n",
    "    # Adds test array to the screen\n",
    "    if changeBinary == 1:\n",
    "        for yy in range(1, nTrialItems[i] + 1):\n",
    "            add(rectangles[yy]) # may need to set locations and rotations again?\n",
    "        rectangles[1].rotate(45)\n",
    "    else:\n",
    "        for ww in range(1, nTrialItems[i] + 1):\n",
    "            add(rectangles[ww]) # may need to set locations and rotations again?\n",
    "    # Records subject response\n",
    "    responses[i] = input(\"\") # may need action listeners instead\n",
    "    wait(1000)\n",
    "    # Removes test array\n",
    "    for zz in range(1, nTrialItems[i] + 1):\n",
    "        remove(rectangles[zz]\n",
    "    remove(fixationCross)\n",
    "    # Pauses 1000 ms or until response\n",
    "    timer = 0\n",
    "    while responses[i] == \"\":\n",
    "        responses[i] = input(\"\")\n",
    "        wait(1)\n",
    "        timer++\n",
    "        if timer == 1000:\n",
    "            break\n"
   ]
  }
 ],
 "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.5.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}

{'fraction_non_alphanumeric': 0.19402356902356901, 'fraction_numerical': 0.08249158249158249, 'mean_word_length': 2.7265242109390315, 'pattern_counts': {'":': 117, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7424536', 'n_tokens_mistral': 8789, 'n_tokens_neox': 7942, 'n_words': 1025}