In [3]:
from __future__ import division
import pygaze
from pygaze import libscreen
import psychopy
from psychopy import core, visual, event, monitors
from warnings import warn
from pprint import pprint
from copy import deepcopy

class Session(object):
    
    def __init__(self, scanner=None, eyetracker=None, monitor='u2715h', debug=False):
        
        if monitor not in monitors.getAllMonitors():
            raise(IOError('Monitor %s not found in settings...' % monitor))
        
        self.scanner = scanner
        self.eyetracker = eyetracker
        self.clock = core.Clock()
        self.stopped = False
        self.debug = debug
        self.t_start = None
        self.phase_start = None
        self.setup_screen(monitor=monitor)
        
        if self.eyetracker is not None:
            self.setup_eyetracker
    
        if self.scanner is not None:
            from psychopy.hardware.emulator import launchScan
            self.scanner = launchScan(win=self.window, settings={'TR': 2.0, 'volumes': 100, 'sound': False, 'sync': 't'}, globalClock=self.clock)
    
    def setup_screen(self, monitor):
        self.display = libscreen.Display(disptype='psychopy', screennr=0)
        self.window = pygaze.expdisplay
        self.window.monitor = monitors.Monitor(monitor)  # this is necessary because the physical size is specified here

        self.frame_rate = self.window.getActualFrameRate()
        if self.frame_rate is None:
            warn('Could not fetch frame rate! Guessing it is 60Hz...')
            self.frame_rate = 60
            self.frame_duration = 1/60
        else:
            self.frame_rate = np.round(self.frame_rate)
            self.frame_duration = 1/self.frame_rate

    def setup_eyetracker(self):
        self.eyetracker.calibrate()
    
    def run(self, n_trials=5):
        fltr = FlashTrial(window=self.window, session=self, debug=self.debug)
        
        for trial_n in range(n_trials):
            fltr.reset()
            fltr.run()
            
            # After every trial, check for stop signal
            if self.stopped:
                pprint(fltr.events)
                self.stop()

        # Currently, at the end of the block, stop
        pprint(fltr.events)
        self.stop()

    def stop(self):
        
        # Print events and close window, exit python
        self.window.close()
        core.quit()


class Trial(object):
    
    def __init__(self, session, window, phase_durations, experiment_handler):
        self.session = session
        self.window = window
        self.phase_durations = phase_durations
        self.experiment_handler = experiment_handler
        self.phase = 0
        self.stopped = False
        self.events = []
        self.trial_answer = None
        
    def event(self):
        pass

    def draw(self):
        self.window.flip()
    
    def phase_forward(self):
        self.phase += 1
        self.phase_start = self.session.clock.getTime()

class FlashTrial(Trial):

    def __init__(self, window, session, parameters={'flash_length': 3, 'increment_length': 7, 'n_increments': 10, 'frame_rate':60, 'prop_correct': .7, 'prop_incorrect': .4}, 
                 phase_durations=(0.5, 1.5, 0.5, 1), n_flashers=2, response_keys=['z', 'm'], radius=3, flasher_size=1, debug=False, 
                 experiment_handler=None):
    
        """ Initialize FlashTrial class. Handles everything for stimulus presentation and recording of the Flash Task 
        
        # ToDo: RECORD / LOG everything! -> superclass? session?
        """
        
        super(FlashTrial, self).__init__(session, window, phase_durations, experiment_handler)

        self.n_flashers = n_flashers
        self.response_keys = response_keys
        self.debug = debug
        
        if not len(self.response_keys) == self.n_flashers:
            self.window.close()
            raise(IOError('The number of flashers is not the same as the number of key response options.'))        

        # An increment consists of two parts: an 'evidence' part, and a pause. Together, these form an 'increment'.
        # How long does each increment in total take? Enter the duration in frames (Each frame (at 60Hz) takes 16.667ms)
        self.increment_length = parameters['increment_length']

        # How long do you want each flash to take? Enter the duration in frames
        self.flash_length = parameters['flash_length']

        # How long do you want the time between flashes to be? 
        # By default, this is the total increment length - flash length. You probably shouldn't change this.
        self.pause_length = self.increment_length - self.flash_length

        # Maximum duration of a trial: a trial either quits after a certain time has passed, or if a certain number of increments have been shown.
        # How many increments will totally be available in a trial?
        if self.phase_durations[1] is not None:
            self.n_increments = np.ceil(self.phase_durations[1] / (self.increment_length/self.session.frame_rate)).astype(int)
        else:
            self.n_increments = parameters['n_increments']

        # Here, we calculate how long each trial should maximally take in frames. Leave this untouched.
        self.max_frame = self.n_increments*self.increment_length

        # Next, we set the difficulty of the task. This is determined by the 'chance' of flashing for every flasher.
        # To make things really easy, set the chance of flashing for the correct flasher really high, and the incorrect flasher really low.
        # Proportions: (greater diff = easier; higher values = more flashes)
        self.prop_corr = parameters['prop_correct']
        self.prop_incorr = parameters['prop_incorrect']
        
        # Determine positions to show flashers
        if self.n_flashers == 2:
            t = 0 # modulo: start point on circle in radians. With 2 flashers, starting at t=0 means the flashers are shown horizontally. For vertical, try t=0.5*pi
        else:
            t = 0.5*np.pi # for more than 2 flashers, it's nice to start on the y-axis
        
        # Determine position of flashers in cm
        self.pos_x = radius * np.cos(t + np.arange(1, n_flashers+1) * 2 * np.pi / n_flashers)
        self.pos_y = radius * np.sin(t + np.arange(1, n_flashers+1) * 2 * np.pi / n_flashers)
        
        # Prepare mask
        self.mask_idx = np.tile(np.hstack((np.repeat(0, repeats=self.flash_length), 
                                           np.repeat(1, repeats=self.pause_length))), 
                                self.n_increments)
        self.mask_idx = self.mask_idx.astype(bool)
        
    def prepare_trial(self):
        """ Prepares everything for the next trial """
        
        # Define which flashing circle is correct
        self.correct = np.random.randint(low=0, high=self.n_flashers)
        
        # Define which keys are correct / incorrect
        self.correct_key = self.response_keys[self.correct]
        self.incorrect_keys = [x for x in self.response_keys if not x == self.correct_key]

        # Initialize 'increment arrays' for correct and incorrect. These are arrays filled with 0s and 1s, determining for each 'increment' whether a piece of evidence is shown or not.
        self.flashers = []
        for i in range(self.n_flashers):
            if i == self.correct:
                self.flashers.append(np.random.binomial(n=1, p=self.prop_corr, size=self.n_increments))
            else:
                self.flashers.append(np.random.binomial(n=1, p=self.prop_incorr, size=self.n_increments))

        self.full_increment_streams = deepcopy(self.flashers)
        
        for i in range(self.n_flashers):
            self.flashers[i] = np.repeat(self.flashers[i], self.increment_length)
            self.flashers[i][self.mask_idx] = 0

        # Keep track of actually shown evidence during trial
        self.counter_left = 0
        self.counter_right = 0
        
        # Prepare fixation cross component
        self.fix_cross = visual.TextStim(win=self.window, text='+', font='', pos=(0.0, 0.0), 
                                         depth=0, rgb=None, color=(1.0, 1.0, 1.0), colorSpace='rgb', 
                                         opacity=1.0, contrast=1.0, units='', ori=0.0)
        
        # Prepare actual stimuli components
        self.flasher_stim = []
        for i in range(self.n_flashers):
            self.flasher_stim.append(visual.Polygon(win=self.window, name='flasher_'+str(i), units='cm',
                                                   edges=90, size=[1,1], ori=0, pos=(self.pos_x[i], self.pos_y[i]),
                                                   lineWidth=0, lineColor=[0,0,0], lineColorSpace='rgb',
                                                   fillColor=[1,1,1], fillColorSpace='rgb', opacity=1, depth=-1.0, 
                                                   interpolate=True))

        # Prepare feedback component
        self.feedback_text_component = visual.TextStim(win=self.window, text='If you see this, updating of feedback text went wrong..', color=(100, 255, 100))
        
        # Prepare debug text component
        self.debug_text_component = visual.TextStim(win=self.window, text='', pos=(-4, 4), units='cm', height=0.5)
        
    def event(self):
        """ Get and process all events (keypresses) during the current frame """

        for i, ev in enumerate(event.getKeys()):
            if len(ev) > 0:
                if ev in ['esc', 'escape']:
                    self.stopped = True
                    self.session.stopped = True
                    self.phase = 0
                    self.events.append([-99, self.session.clock.getTime(), 'escape: user killed session'])
                    print('Session stopped!')
                
                elif ev in self.response_keys:
                    if self.phase == 0:
                        self.events.append([ev, self.session.clock.getTime(), 'early keypress'])
                        
                    if self.phase == 1:
                        self.trial_answer = ev

                        if i == 0:  # First keypress
                            if ev == self.correct_key:
                                self.events.append([ev, self.session.clock.getTime(), 'first keypress', 'correct', self.session.clock.getTime() - self.phase_start])
                            else:
                                self.events.append([ev, self.session.clock.getTime(), 'first keypress', 'incorrect', self.session.clock.getTime() - self.phase_start])
                        else:
                            self.events.append([ev, self.session.clock.getTime(), 'late keypress (during stimulus)'])

                    if self.phase == 2:
                        self.events.append([ev, self.session.clock.getTime(), 'late keypress (during feedback)'])

                    if self.phase == 3:
                        self.events.append([ev, self.session.clock.getTime(), 'late keypress (during ITI)'])

                elif ev == 't':  # Scanner pulse
                    self.events.append([99, self.session.clock.getTime(), 'pulse'])                    
    
    def draw(self, frame_n):
        """ Draws components in current phase """

        if self.debug:
            self.debug_text_component.text = 'Phase: ' + str(self.phase) + '\n' + \
                                             str(frame_n) + '\n' + \
                                             str(np.round(self.session.clock.getTime() - self.t_start, 3)) + '\n' + \
                                             str(np.round(self.session.clock.getTime() - self.phase_start, 3)) + '\n' + self.correct_key
            self.debug_text_component.draw()

        if self.phase == 0:
            self.fix_cross.draw()
        
        elif self.phase == 1:
            for flasher_n in range(self.n_flashers):
                self.flasher_stim[flasher_n].opacity = self.flashers[flasher_n][frame_n]
                self.flasher_stim[flasher_n].draw()
        
        elif self.phase == 2:
            self.feedback_text_component.draw()

        super(FlashTrial, self).draw()  # Super-class handles the window-flipping
        
    def run(self):
        """ Runs a single trial. In the current set-up, trial timing is handled by counting frames.
        If frames are dropped, timing is NOT accurate!!
        """
        
        # Prepare the trial
        self.prepare_trial()
        
        # Start timing
        self.t_start = self.session.clock.getTime()
        self.phase_start = self.session.clock.getTime()

        # Log start time and additional info about this trial
        start_log_msg = [1, self.t_start, 'trial start', self.correct, self.correct_key]
#         for i in range(self.n_flashers):
#             start_log_msg.append(self.full_increment_streams[i])
        
        self.events.append(start_log_msg)
        self.events.append([2, self.phase_start, 'fixation cross start'])
        
        frame_n = -1
        while not self.stopped:
            cur_time = self.session.clock.getTime()
            frame_n = frame_n + 1

            # Run trial phases
            if self.phase == 0:  # Fixation cross                
                if cur_time - self.phase_start >= self.phase_durations[self.phase]:
                    self.events.append([3, cur_time, 'stimulus start'])
                    self.phase_forward()
                    frame_n = 0

            if self.phase == 1:  # Stimulus
                if cur_time - self.phase_start >= self.phase_durations[self.phase]:
                    self.events.append([4, cur_time, 'trial timeout'])
                    self.phase_forward()
                    frame_n = 0

                elif self.trial_answer is not None:  # key was pressed
                    self.phase_forward()
                    frame_n = 0

            if self.phase == 2:  # Feedback
                if frame_n == 0:
                    if self.trial_answer is None:
                        self.feedback_text_component.color = (1, 100/255, 100/255)
                        self.feedback_text_component.text = 'Too late!'
                    elif self.trial_answer[0] == self.correct_key:
                        self.feedback_text_component.color = (100/255, 1, 100/255)
                        self.feedback_text_component.text = 'Correct!'
                    elif self.trial_answer[0] in self.incorrect_keys:
                        self.feedback_text_component.color = (1, 100/255, 100/255)
                        self.feedback_text_component.text = 'Wrong!'
                
                if cur_time - self.phase_start >= self.phase_durations[self.phase]:
                    self.phase_forward()
                    frame_n = 0

            if self.phase == 3:  # ITI
                if cur_time - self.phase_start >= self.phase_durations[self.phase]:
                    self.events.append([5, cur_time, 'trial end', cur_time - self.t_start])
                    self.stopped = True
            
            # Show screen/frame
            self.event()
            self.draw(frame_n)
            
    def reset(self):
        self.stopped = False
        self.phase = 0
        self.trial_answer = None
    
    def run_block(self, n_trials=5):
        for trial in range(n_trials):
            self.reset()
            self.run()



if __name__ == '__main__':
    import psychopy
    from psychopy import data, core
    from pygaze import libinput
    from pygaze.defaults import *
    import numpy as np
    from constants import *
    import os
    import sys
    
    try:
        import appnope
        appnope.nope()
        have_appnope = True
    except:
        have_appnope = False
    
    ses = Session(monitor='u2715h', scanner=True, debug=True).run()
    
    if have_appnope:
        appnope.nap()


[[1, 0.047840118408203125, 'trial start', 1, 'm'],
 [2, 0.04784202575683594, 'fixation cross start'],
 [3, 0.5490291118621826, 'stimulus start'],
 ['z', 1.4341011047363281, 'first keypress', 'incorrect', 0.8850610256195068],
 [99, 2.0185189247131348, 'pulse'],
 [5, 2.952500104904175, 'trial end', 2.9046599864959717],
 [1, 3.0034420490264893, 'trial start', 0, 'z'],
 [2, 3.0034430027008057, 'fixation cross start'],
 [3, 3.5086190700531006, 'stimulus start'],
 [99, 4.022221088409424, 'pulse'],
 [4, 5.021871089935303, 'trial timeout'],
 [99, 6.01951003074646, 'pulse'],
 [5, 6.534981966018677, 'trial end', 3.5315399169921875],
 [1, 6.588885068893433, 'trial start', 0, 'z'],
 [2, 6.588886976242065, 'fixation cross start'],
 [3, 7.091325998306274, 'stimulus start'],
 [99, 8.014070987701416, 'pulse'],
 [4, 8.592808961868286, 'trial timeout'],
 [99, 10.026701927185059, 'pulse'],
 [5, 10.111663103103638, 'trial end', 3.522778034210205],
 [1, 10.160898923873901, 'trial start', 1, 'm'],
 [2, 10.160901069641113, 'fixation cross start'],
 [3, 10.66356110572815, 'stimulus start'],
 [99, 12.015439987182617, 'pulse'],
 [4, 12.165360927581787, 'trial timeout'],
 [5, 13.68374490737915, 'trial end', 3.522845983505249],
 [1, 13.732403039932251, 'trial start', 1, 'm'],
 [2, 13.732404947280884, 'fixation cross start'],
 [99, 14.017291069030762, 'pulse'],
 [3, 14.234571933746338, 'stimulus start'],
 [4, 15.752742052078247, 'trial timeout'],
 [99, 16.012660026550293, 'pulse'],
 [5, 17.274709939956665, 'trial end', 3.542306900024414]]
212.8279 	WARNING 	Monitor specification not found. Creating a temporary one...
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0

In [1]:



[[1, 0.052100181579589844, 'trial start', 1, 'm'],
 [2, 0.052102088928222656, 'fixation cross start'],
 [3, 0.5638680458068848, 'stimulus start'],
 [99, 2.011427164077759, 'pulse'],
 [4, 2.0770180225372314, 'trial timeout'],
 [5, 3.607055187225342, 'trial end', 3.554955005645752],
 [1, 3.6553680896759033, 'trial start', 0, 'z'],
 [2, 3.6553690433502197, 'fixation cross start'],
 [99, 3.99971604347229, 'pulse'],
 [3, 4.156071186065674, 'stimulus start'],
 [4, 5.668258190155029, 'trial timeout'],
 [99, 6.0183281898498535, 'pulse'],
 [5, 7.1988160610198975, 'trial end', 3.543447971343994],
 [1, 7.243441104888916, 'trial start', 0, 'z'],
 [2, 7.243443012237549, 'fixation cross start'],
 [3, 7.746438980102539, 'stimulus start'],
 [99, 8.013288021087646, 'pulse'],
 [4, 9.259468078613281, 'trial timeout'],
 [99, 10.02515697479248, 'pulse'],
 [5, 10.789750099182129, 'trial end', 3.546308994293213],
 [1, 10.837723016738892, 'trial start', 0, 'z'],
 [2, 10.837725162506104, 'fixation cross start'],
 [3, 11.338046073913574, 'stimulus start'],
 ['z', 11.95360803604126, 'first keypress', 'correct', 0.6155509948730469],
 [99, 12.003657102584839, 'pulse'],
 [5, 13.499317169189453, 'trial end', 2.6615941524505615],
 [1, 13.550305128097534, 'trial start', 0, 'z'],
 [2, 13.55030608177185, 'fixation cross start'],
 [99, 14.015933990478516, 'pulse'],
 [3, 14.064831972122192, 'stimulus start'],
 ['m', 14.73021912574768, 'first keypress', 'incorrect', 0.6653759479522705],
 [99, 16.011183977127075, 'pulse'],
 [5, 16.276700973510742, 'trial end', 2.726395845413208]]
1.9746 	WARNING 	Monitor specification not found. Creating a temporary one...
1.9756 	WARNING 	User requested fullscreen with size [2560 1440], but screen is actually [1280, 800]. Using actual size
An exception has occurred, use %tb to see the full traceback.

SystemExit: 0
/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/IPython/core/interactiveshell.py:2889: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D.
  warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)

In [5]:
import numpy as np
from timeit import timeit

In [7]:
%%timeit
np.random.randint(0, 2, size=100)


The slowest run took 10.41 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 4.32 µs per loop

In [9]:
%%timeit
np.random.binomial(1, .6, 100)


The slowest run took 11.71 times longer than the fastest. This could mean that an intermediate result is being cached.
100000 loops, best of 3: 7.27 µs per loop

In [12]:
np.random.binomial(1, .6, (2, 100, 2))


Out[12]:
array([[[1, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [1, 1],
        [0, 0],
        [1, 1],
        [1, 1],
        [0, 1],
        [0, 0],
        [0, 1],
        [1, 0],
        [1, 1],
        [1, 1],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 0],
        [0, 1],
        [1, 0],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 0],
        [0, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [0, 1],
        [1, 1],
        [0, 1],
        [0, 0],
        [1, 1],
        [0, 0],
        [0, 0],
        [1, 1],
        [1, 0],
        [1, 0],
        [0, 0],
        [1, 0],
        [0, 1],
        [1, 1],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 0],
        [0, 1],
        [1, 0],
        [1, 0],
        [1, 1],
        [1, 0],
        [0, 1],
        [0, 1],
        [0, 0],
        [0, 1],
        [0, 1],
        [1, 0],
        [0, 1],
        [1, 0],
        [1, 1],
        [0, 1],
        [0, 1],
        [0, 1],
        [1, 0],
        [1, 0],
        [0, 1],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [0, 0],
        [0, 0],
        [1, 0],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [1, 1],
        [0, 0],
        [1, 0],
        [1, 0],
        [0, 0],
        [0, 0],
        [1, 0],
        [1, 1]],

       [[0, 0],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [0, 1],
        [1, 0],
        [1, 1],
        [0, 0],
        [0, 1],
        [0, 0],
        [1, 1],
        [1, 0],
        [0, 1],
        [0, 0],
        [1, 0],
        [0, 1],
        [0, 0],
        [1, 1],
        [1, 1],
        [0, 0],
        [1, 1],
        [0, 1],
        [1, 1],
        [0, 1],
        [1, 0],
        [1, 1],
        [0, 0],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [0, 1],
        [0, 1],
        [0, 1],
        [0, 0],
        [1, 0],
        [1, 1],
        [0, 0],
        [1, 0],
        [1, 1],
        [1, 1],
        [1, 1],
        [0, 1],
        [1, 0],
        [1, 0],
        [1, 0],
        [1, 1],
        [0, 1],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 0],
        [0, 0],
        [1, 1],
        [0, 0],
        [1, 0],
        [1, 1],
        [0, 0],
        [0, 1],
        [1, 0],
        [0, 1],
        [0, 1],
        [0, 0],
        [0, 0],
        [0, 1],
        [0, 0],
        [0, 1],
        [0, 1],
        [1, 1],
        [1, 0],
        [0, 0],
        [1, 1],
        [0, 0],
        [1, 1],
        [1, 1],
        [0, 1],
        [1, 0],
        [1, 1],
        [1, 1],
        [1, 1],
        [1, 0],
        [1, 1],
        [1, 0],
        [1, 0],
        [0, 0],
        [1, 0],
        [1, 1],
        [0, 1],
        [1, 0],
        [1, 1],
        [0, 1],
        [0, 1],
        [1, 0],
        [0, 0],
        [1, 1],
        [1, 1],
        [1, 0],
        [1, 0],
        [1, 1]]])

In [16]:
response_keys = np.array(['a', 'b'])


Out[16]:
'a'

In [18]:
response_keys[np.array([0, 0, 1])]


Out[18]:
array(['a', 'a', 'b'], 
      dtype='|S1')

In [26]:
response_keys = ['a', 'b', 'c']
correct_answers = np.random.randint(0, 3, 100)
correct_keys = np.array(response_keys)[correct_answers]
print(correct_keys)


['c' 'a' 'b' 'b' 'b' 'b' 'a' 'b' 'c' 'c' 'a' 'a' 'b' 'c' 'b' 'a' 'c' 'c'
 'b' 'c' 'b' 'c' 'c' 'a' 'a' 'c' 'a' 'c' 'b' 'c' 'c' 'c' 'b' 'b' 'a' 'c'
 'c' 'c' 'c' 'b' 'c' 'b' 'a' 'c' 'a' 'b' 'b' 'b' 'a' 'c' 'a' 'c' 'c' 'a'
 'a' 'c' 'a' 'b' 'c' 'b' 'b' 'c' 'a' 'b' 'b' 'c' 'c' 'b' 'a' 'b' 'a' 'b'
 'c' 'b' 'c' 'a' 'a' 'a' 'c' 'b' 'a' 'b' 'b' 'a' 'b' 'b' 'b' 'a' 'a' 'b'
 'c' 'b' 'a' 'b' 'c' 'c' 'c' 'b' 'c' 'c']

In [24]:
incorrect_keys = [np.array(response_keys[response_keys != correct_keys[i]]) for i in range(100)]

In [25]:
incorrect_keys


Out[25]:
[array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1'), array('b', 
       dtype='|S1')]

In [40]:
response_keys[response_keys != correct_keys[0]]


Out[40]:
'b'

In [39]:
correct_keys[correct_keys == 'c']


Out[39]:
array(['c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c',
       'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c',
       'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c'], 
      dtype='|S1')

In [45]:
flash_length = 3
pause_length = 4
n_increments = 10
mask_idx = np.tile(np.hstack((np.repeat(0, repeats=flash_length),
                              np.repeat(1, repeats=pause_length))),
                   n_increments).astype(bool)

In [46]:
mask_idx


Out[46]:
array([False, False, False,  True,  True,  True,  True, False, False,
       False,  True,  True,  True,  True, False, False, False,  True,
        True,  True,  True, False, False, False,  True,  True,  True,
        True, False, False, False,  True,  True,  True,  True, False,
       False, False,  True,  True,  True,  True, False, False, False,
        True,  True,  True,  True, False, False, False,  True,  True,
        True,  True, False, False, False,  True,  True,  True,  True,
       False, False, False,  True,  True,  True,  True], dtype=bool)

In [47]:
mask_idx = np.tile(np.hstack((np.repeat(0, repeats=flash_length),
                              np.repeat(1, repeats=pause_length))),
                   n_increments)

In [69]:
n_trials = 100
n_flashers = 2
correct_answers = np.random.randint(0, n_flashers, n_trials)
response_keys = np.array(['a', 'b', 'c'])
correct_keys = response_keys[correct_answers]
incorrect_answers = [np.delete(np.arange(n_flashers), i) for i in correct_answers]
incorrect_keys = [response_keys[incorrect_answers[i]] for i in range(n_trials)]
pprint(correct_keys)
pprint(incorrect_keys)


array(['a', 'a', 'a', 'b', 'b', 'b', 'b', 'a', 'a', 'a', 'a', 'b', 'b',
       'b', 'a', 'a', 'b', 'a', 'a', 'b', 'b', 'a', 'b', 'a', 'a', 'b',
       'a', 'a', 'b', 'a', 'a', 'b', 'b', 'b', 'b', 'b', 'b', 'b', 'b',
       'a', 'b', 'b', 'b', 'a', 'a', 'b', 'b', 'b', 'b', 'a', 'b', 'b',
       'a', 'b', 'b', 'b', 'b', 'a', 'b', 'a', 'b', 'a', 'a', 'a', 'b',
       'a', 'a', 'b', 'a', 'b', 'a', 'a', 'a', 'b', 'a', 'b', 'b', 'b',
       'b', 'a', 'a', 'b', 'b', 'b', 'a', 'a', 'b', 'b', 'b', 'a', 'a',
       'b', 'b', 'b', 'a', 'a', 'b', 'a', 'b', 'b'], 
      dtype='|S1')
[array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['b'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1'),
 array(['a'], 
      dtype='|S1')]

In [51]:
np.array(response_keys)


['a' 'b']

In [52]:
np.delete(['a', 'b'], 'b')


/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/ipykernel_launcher.py:1: DeprecationWarning: using a non-integer array as obj in delete will result in an error in the future
  """Entry point for launching an IPython kernel.
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-52-77e2b113385a> in <module>()
----> 1 np.delete(['a', 'b'], 'b')

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/numpy/lib/function_base.pyc in delete(arr, obj, axis)
   4709                 "using a non-integer array as obj in delete will result in an "
   4710                 "error in the future", DeprecationWarning, stacklevel=2)
-> 4711             obj = obj.astype(intp)
   4712         keep = ones(N, dtype=bool)
   4713 

ValueError: invalid literal for int() with base 10: 'b'

In [53]:
correct_answers


Out[53]:
array([1, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 1,
       0, 0, 1, 0, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 1, 0, 0, 0,
       1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0,
       0, 1, 1, 1, 0, 1, 1, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1,
       1, 0, 1, 0, 0, 1, 1, 0])

In [54]:


In [70]:
ls1 = ['a', 'b', 'c']
ls2 = ['1', '2', '3']
print(zip(ls1, ls2))


[('a', '1'), ('b', '2'), ('c', '3')]

In [6]:
from __future__ import division
import numpy as np

ppcm = 2560/63.1
screen_size = [2560, 1440]
eye_pos = (1440/2, 250/2)
mid_screen = [x/2 for x in screen_size]

dist_travelled = np.sqrt((eye_pos[0]-mid_screen[0])**2 + (eye_pos[1]-mid_screen[1])**2)/ppcm

In [7]:
dist_travelled


Out[7]:
20.139824855349726

In [3]:
from neurodesign import geneticalgorithm, generate,msequence,report
import os

EXP = geneticalgorithm.experiment(
    TR=2,
    n_trials=10,
    P = [0.5,0.5],
    C = [[1,0],[0,1],[1,-1]],
    n_stimuli = 2,
    rho = 0.3,
    resolution=1,
    stim_duration=1.5,
    t_pre = 0.5,
    t_post = 0.35,
    restnum=0,
    restdur=0,
    ITImodel = "exponential",
    ITImin = 1,
    ITImean = 2,
    ITImax=4
    )


POP = geneticalgorithm.population(
    experiment=EXP,
    weights=[0,0.5,0.25,0.25],
    preruncycles = 2,
    cycles = 2,
    seed=1,
    outdes=5,
    folder=os.getcwd()
    )

#########################
# run natural selection #
#########################

POP.naturalselection()
POP.download()
POP.evaluate()
POP.print_cmd()

################
# step by step #
################

POP.add_new_designs()
POP.to_next_generation(seed=1)
POP.to_next_generation(seed=1001)

#################
# export report #
#################

report.make_report(POP, os.path.join(os.getcwd(), 'rep.pdf'))


---------------------------------------------------------------------------
KeyboardInterrupt                         Traceback (most recent call last)
<ipython-input-3-82b5654fb390> in <module>()
     36 #########################
     37 
---> 38 POP.naturalselection()
     39 POP.download()
     40 POP.evaluate()

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/neurodesign/geneticalgorithm.pyc in naturalselection(self)
    893         if self.weights[1] > 0:
    894             self.clear()
--> 895             self.add_new_designs(weights=[0, 1, 0, 0])
    896             # loop
    897             bar = progressbar.ProgressBar()

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/neurodesign/geneticalgorithm.pyc in add_new_designs(self, weights, R)
    712             order = generate.order(self.exp.n_stimuli, self.exp.n_trials,
    713                                    self.exp.P, ordertype=ordertype, seed=self.seed)
--> 714             ITI,ITIlam = generate.iti(ntrials=self.exp.n_trials, model=self.exp.ITImodel, min=self.exp.ITImin, max=(self.exp.ITImax+self.exp.resolution), mean=self.exp.ITImean, lam=self.exp.ITIlam, seed=self.seed,resolution=self.exp.resolution)
    715 
    716             if ITIlam:

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/neurodesign/generate.pyc in iti(ntrials, model, min, mean, max, lam, resolution, seed)
     96             seed = seed+20
     97             np.random.seed(seed)
---> 98             smp = rtexp((ntrials-1),lam,min,max,seed=seed)
     99             smp = [np.floor(x / resolution)* resolution for x in smp]
    100             if np.sum(smp)<maxdur and abs(np.mean(smp)-mean)<(ESd/4.):

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/neurodesign/generate.pyc in rtexp(ntrials, lam, lower, upper, seed)
    124     b = float(upper)
    125     x = lam
--> 126     smp = stats.truncexpon((b-a)/x,loc=a,scale=x).rvs(ntrials)
    127     return smp

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/stats/_distn_infrastructure.pyc in __call__(self, *args, **kwds)
    770 
    771     def __call__(self, *args, **kwds):
--> 772         return self.freeze(*args, **kwds)
    773     __call__.__doc__ = freeze.__doc__
    774 

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/stats/_distn_infrastructure.pyc in freeze(self, *args, **kwds)
    767 
    768         """
--> 769         return rv_frozen(self, *args, **kwds)
    770 
    771     def __call__(self, *args, **kwds):

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/stats/_distn_infrastructure.pyc in __init__(self, dist, *args, **kwds)
    432 
    433         # create a new instance
--> 434         self.dist = dist.__class__(**dist._updated_ctor_param())
    435 
    436         # a, b may be set in _argcheck, depending on *args, **kwds. Ouch.

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/stats/_distn_infrastructure.pyc in __init__(self, momtype, a, b, xtol, badvalue, name, longname, shapes, extradoc, seed)
   1486                  shapes=None, extradoc=None, seed=None):
   1487 
-> 1488         super(rv_continuous, self).__init__(seed)
   1489 
   1490         # save the ctor parameters, cf generic freeze

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/stats/_distn_infrastructure.pyc in __init__(self, seed)
    593 
    594         # figure out if _stats signature has 'moments' keyword
--> 595         sign = _getargspec(self._stats)
    596         self._stats_has_moments = ((sign[2] is not None) or
    597                                    ('moments' in sign[0]))

/Users/steven/anaconda/envs/subcortex/lib/python2.7/site-packages/scipy/_lib/_util.pyc in getargspec_no_self(func)
    334             python 2.x, and inspect.signature() under python 3.x.
    335         """
--> 336         argspec = inspect.getargspec(func)
    337         if argspec.args[0] == 'self':
    338             argspec.args.pop(0)

/Users/steven/anaconda/envs/subcortex/lib/python2.7/inspect.pyc in getargspec(func)
    814     if not isfunction(func):
    815         raise TypeError('{!r} is not a Python function'.format(func))
--> 816     args, varargs, varkw = getargs(func.func_code)
    817     return ArgSpec(args, varargs, varkw, func.func_defaults)
    818 

/Users/steven/anaconda/envs/subcortex/lib/python2.7/inspect.pyc in getargs(co)
    748     'varargs' and 'varkw' are the names of the * and ** arguments or None."""
    749 
--> 750     if not iscode(co):
    751         raise TypeError('{!r} is not a code object'.format(co))
    752 

KeyboardInterrupt: 

In [7]:
import numpy as np
n_wrong = 0
printed = False
for i in range(int(1e6)):
    corr = np.random.binomial(n=1, p=.7, size=10)
    incorr = np.random.binomial(n=1, p=.4, size=10)
    if corr.sum() <= incorr.sum():
        n_wrong += 1
        
        if not printed:
            print(corr)
            print(incorr)
            printed = True


[1 0 1 1 1 0 1 1 0 1]
[1 0 1 0 1 1 1 1 1 0]

In [20]:
import pandas as pd
block_n = 4
design = pd.read_csv('/Users/steven/Documents/Syncthing/PhDprojects/subcortex/flashtask/designs/pp_001/all_blocks/trials.csv')
design.loc[design['block'] == block_n, 'trial_ID'].iloc[-1]


Out[20]:
451

In [1]:
import math
physical_screen_size = (67, 33.5)
physical_screen_distance = 75
size = (2560, 1440)

screen_height_degrees = 2.0 * 180.0/math.pi * math.atan((physical_screen_size[1]/2.0)/physical_screen_distance)
pixels_per_degree = (size[1]) / screen_height_degrees
centimeters_per_degree = physical_screen_size[1] / screen_height_degrees
pixels_per_centimeter = pixels_per_degree / centimeters_per_degree

In [9]:
screen_height_degrees


Out[9]:
25.178919069915437

In [4]:
centimeters_per_degree


Out[4]:
1.3304780839470924

In [8]:
0.5*centimeters_per_degree


Out[8]:
0.6652390419735462

In [40]:
import os

In [47]:
with open(os.path.join('instructions', 'en', 'practice_instructions.txt'), 'rb') as f:
    a = f.read().split('\n\n\n')

In [51]:
a[6]


Out[51]:
'You will again practice the flashing circles-task. The task is to decide which circle flashes most often.\n\nIf you think the left circle flashes most often, PRESS the BUTTON with your left hand. If you think the right circle flashes most often, PRESS the BUTTON with your right hand.\n\nPress a button to continue to next instruction screen'

In [46]:
with open(os.path.join('instructions', 'en', 'welcome_screen.txt'), 'rb') as f:
    b = f.read().split('\n\n')
b[0]


Out[46]:
'Welcome to this practice session!\\n\\nPlease, always read the instructions carefully before continuing.\\n\\nPress <space bar> to continue'

In [13]:
import pandas as pd
import os
from glob import glob

initials = 'SM'
ppnum = 1
fn = glob(os.path.join('data', initials + '_' + str(ppnum) + '*.csv'))[-1]
last_score = pd.read_csv(fn).tail(1)['score'].values[0]


Out[13]:
8

In [4]:
os.listdir('data')


Out[4]:
['.DS_Store',
 '.ipynb_checkpoints',
 'analyze_recorded_timing.ipynb',
 'DEBUG_1_2017-10-07_12.05.54.csv',
 'DEBUG_1_2017-10-07_12.05.54.psydat',
 'DEBUG_1_2017-10-07_12.05.54_frame_intervals.log',
 'DEBUG_1_2017-10-07_12.05.54_frame_intervals.png',
 'DEBUG_1_2017-10-07_12.05.54_outputDict.pickle',
 'SM_1_2017-10-25_16.27.34PRACTICE.csv',
 'SM_1_2017-10-25_16.27.34PRACTICE.log',
 'SM_1_2017-10-25_16.27.34PRACTICE.psydat',
 'SM_1_2017-10-25_16.28.30PRACTICE.csv',
 'SM_1_2017-10-25_16.28.30PRACTICE.log',
 'SM_1_2017-10-25_16.28.30PRACTICE.psydat',
 'SM_1_2017-10-25_16.28.32.log',
 'SM_1_2017-10-25_16.29.49PRACTICE.csv',
 'SM_1_2017-10-25_16.29.49PRACTICE.log',
 'SM_1_2017-10-25_16.29.49PRACTICE.psydat',
 'SM_1_2017-10-25_16.29.50.csv',
 'SM_1_2017-10-25_16.29.50.log',
 'SM_1_2017-10-25_16.29.50.psydat',
 'SM_1_2017-10-25_16.29.50_frame_intervals.log',
 'SM_1_2017-10-25_16.29.50_frame_intervals.png',
 'SM_1_2017-10-25_16.29.50_outputDict.pickle',
 'SM_1_2017-10-25_16.30.27PRACTICE.csv',
 'SM_1_2017-10-25_16.30.27PRACTICE.log',
 'SM_1_2017-10-25_16.30.27PRACTICE.psydat',
 'SM_1_2017-10-25_16.30.29.csv',
 'SM_1_2017-10-25_16.30.29.log',
 'SM_1_2017-10-25_16.30.29.psydat',
 'SM_1_2017-10-25_16.30.29_frame_intervals.log',
 'SM_1_2017-10-25_16.30.29_frame_intervals.png',
 'SM_1_2017-10-25_16.30.29_outputDict.pickle',
 'sm_1_2017-10-25_16.33.39PRACTICE.csv',
 'sm_1_2017-10-25_16.33.39PRACTICE.log',
 'sm_1_2017-10-25_16.33.39PRACTICE.psydat',
 'sm_1_2017-10-25_16.33.41.csv',
 'sm_1_2017-10-25_16.33.41.log',
 'sm_1_2017-10-25_16.33.41.psydat',
 'sm_1_2017-10-25_16.33.41_1.csv',
 'sm_1_2017-10-25_16.33.41_1.psydat',
 'sm_1_2017-10-25_16.33.41_frame_intervals.log',
 'sm_1_2017-10-25_16.33.41_frame_intervals.png',
 'sm_1_2017-10-25_16.33.41_outputDict.pickle',
 'sm_1_2017-10-25_16.34.49PRACTICE.csv',
 'sm_1_2017-10-25_16.34.49PRACTICE.log',
 'sm_1_2017-10-25_16.34.49PRACTICE.psydat',
 'sm_1_2017-10-25_16.34.51.csv',
 'sm_1_2017-10-25_16.34.51.log',
 'sm_1_2017-10-25_16.34.51.psydat',
 'sm_1_2017-10-25_16.34.51_frame_intervals.log',
 'sm_1_2017-10-25_16.34.51_frame_intervals.png',
 'sm_1_2017-10-25_16.34.51_outputDict.pickle',
 'sm_1_2017-10-25_16.35.45PRACTICE.csv',
 'sm_1_2017-10-25_16.35.45PRACTICE.log',
 'sm_1_2017-10-25_16.35.45PRACTICE.psydat',
 'sm_1_2017-10-25_16.35.47.csv',
 'sm_1_2017-10-25_16.35.47.log',
 'sm_1_2017-10-25_16.35.47.psydat',
 'sm_1_2017-10-25_16.35.47_frame_intervals.log',
 'sm_1_2017-10-25_16.35.47_frame_intervals.png',
 'sm_1_2017-10-25_16.35.47_outputDict.pickle',
 'sm_1_2017-10-25_16.36.34PRACTICE.csv',
 'sm_1_2017-10-25_16.36.34PRACTICE.log',
 'sm_1_2017-10-25_16.36.34PRACTICE.psydat',
 'sm_1_2017-10-25_16.36.36.csv',
 'sm_1_2017-10-25_16.36.36.log',
 'sm_1_2017-10-25_16.36.36.psydat',
 'sm_1_2017-10-25_16.36.36_frame_intervals.log',
 'sm_1_2017-10-25_16.36.36_frame_intervals.png',
 'sm_1_2017-10-25_16.36.36_outputDict.pickle',
 'SM_1_2017-10-25_16.40.38PRACTICE.csv',
 'SM_1_2017-10-25_16.40.38PRACTICE.log',
 'SM_1_2017-10-25_16.40.38PRACTICE.psydat',
 'SM_1_2017-10-25_16.40.39.csv',
 'SM_1_2017-10-25_16.40.39.log',
 'SM_1_2017-10-25_16.40.39.psydat',
 'SM_1_2017-10-25_16.40.39_frame_intervals.log',
 'SM_1_2017-10-25_16.40.39_frame_intervals.png',
 'SM_1_2017-10-25_16.40.39_outputDict.pickle',
 'SM_1_2017-10-25_16.40.52PRACTICE.csv',
 'SM_1_2017-10-25_16.40.52PRACTICE.log',
 'SM_1_2017-10-25_16.40.52PRACTICE.psydat',
 'SM_1_2017-10-25_16.40.54.log',
 'SM_1_2017-10-25_16.41.34PRACTICE.csv',
 'SM_1_2017-10-25_16.41.34PRACTICE.log',
 'SM_1_2017-10-25_16.41.34PRACTICE.psydat',
 'SM_1_2017-10-25_16.41.35.csv',
 'SM_1_2017-10-25_16.41.35.log',
 'SM_1_2017-10-25_16.41.35.psydat',
 'SM_1_2017-10-25_16.41.35_frame_intervals.log',
 'SM_1_2017-10-25_16.41.35_frame_intervals.png',
 'SM_1_2017-10-25_16.41.35_outputDict.pickle',
 'SM_1_2017-10-25_16.41.59PRACTICE.csv',
 'SM_1_2017-10-25_16.41.59PRACTICE.log',
 'SM_1_2017-10-25_16.41.59PRACTICE.psydat',
 'SM_1_2017-10-25_16.42.01.csv',
 'SM_1_2017-10-25_16.42.01.log',
 'SM_1_2017-10-25_16.42.01.psydat',
 'SM_1_2017-10-25_16.42.01_frame_intervals.log',
 'SM_1_2017-10-25_16.42.01_frame_intervals.png',
 'SM_1_2017-10-25_16.42.01_outputDict.pickle',
 'SM_1_2017-10-25_16.58.05PRACTICE.csv',
 'SM_1_2017-10-25_16.58.05PRACTICE.log',
 'SM_1_2017-10-25_16.58.05PRACTICE.psydat',
 'SM_1_2017-10-25_16.58.07.csv',
 'SM_1_2017-10-25_16.58.07.log',
 'SM_1_2017-10-25_16.58.07.psydat',
 'SM_1_2017-10-25_16.58.07_frame_intervals.log',
 'SM_1_2017-10-25_16.58.07_frame_intervals.png',
 'SM_1_2017-10-25_16.58.07_outputDict.pickle',
 'SM_1_2017-10-25_16.59.41PRACTICE.csv',
 'SM_1_2017-10-25_16.59.41PRACTICE.log',
 'SM_1_2017-10-25_16.59.41PRACTICE.psydat',
 'SM_1_2017-10-25_16.59.43.csv',
 'SM_1_2017-10-25_16.59.43.log',
 'SM_1_2017-10-25_16.59.43.psydat',
 'SM_1_2017-10-25_16.59.43_frame_intervals.log',
 'SM_1_2017-10-25_16.59.43_frame_intervals.png',
 'SM_1_2017-10-25_16.59.43_outputDict.pickle',
 'SM_1_2017-10-25_16.59.54PRACTICE.csv',
 'SM_1_2017-10-25_16.59.54PRACTICE.log',
 'SM_1_2017-10-25_16.59.54PRACTICE.psydat',
 'SM_1_2017-10-25_16.59.56.csv',
 'SM_1_2017-10-25_16.59.56.log',
 'SM_1_2017-10-25_16.59.56.psydat',
 'SM_1_2017-10-25_16.59.56_frame_intervals.log',
 'SM_1_2017-10-25_16.59.56_frame_intervals.png',
 'SM_1_2017-10-25_16.59.56_outputDict.pickle',
 'SM_1_2017-10-26_11.37.07PRACTICE.csv',
 'SM_1_2017-10-26_11.37.07PRACTICE.log',
 'SM_1_2017-10-26_11.37.07PRACTICE.psydat',
 'SM_1_2017-10-26_11.37.09.csv',
 'SM_1_2017-10-26_11.37.09.log',
 'SM_1_2017-10-26_11.37.09.psydat',
 'SM_1_2017-10-26_11.37.09_frame_intervals.log',
 'SM_1_2017-10-26_11.37.09_frame_intervals.png',
 'SM_1_2017-10-26_11.37.09_outputDict.pickle',
 'SM_1_2017-10-26_11.37.27PRACTICE.csv',
 'SM_1_2017-10-26_11.37.27PRACTICE.log',
 'SM_1_2017-10-26_11.37.27PRACTICE.psydat',
 'SM_1_2017-10-26_11.37.29.csv',
 'SM_1_2017-10-26_11.37.29.log',
 'SM_1_2017-10-26_11.37.29.psydat',
 'SM_1_2017-10-26_11.37.29_frame_intervals.log',
 'SM_1_2017-10-26_11.37.29_frame_intervals.png',
 'SM_1_2017-10-26_11.37.29_outputDict.pickle',
 'SM_1_2017-10-26_14.20.39PRACTICE.csv',
 'SM_1_2017-10-26_14.20.39PRACTICE.log',
 'SM_1_2017-10-26_14.20.39PRACTICE.psydat',
 'SM_1_2017-10-26_14.20.40.csv',
 'SM_1_2017-10-26_14.20.40.log',
 'SM_1_2017-10-26_14.20.40.psydat',
 'SM_1_2017-10-26_14.20.40_frame_intervals.log',
 'SM_1_2017-10-26_14.20.40_frame_intervals.png',
 'SM_1_2017-10-26_14.20.40_outputDict.pickle',
 'SM_1_2017-10-26_14.33.28.csv',
 'SM_1_2017-10-26_14.33.28.log',
 'SM_1_2017-10-26_14.33.28.psydat',
 'SM_1_2017-10-26_14.33.28_frame_intervals.log',
 'SM_1_2017-10-26_14.33.28_frame_intervals.png',
 'SM_1_2017-10-26_14.33.28_outputDict.pickle',
 'SM_1_2017-10-26_14.34.12PRACTICE.csv',
 'SM_1_2017-10-26_14.34.12PRACTICE.log',
 'SM_1_2017-10-26_14.34.12PRACTICE.psydat',
 'SM_1_2017-10-26_14.34.14.csv',
 'SM_1_2017-10-26_14.34.14.log',
 'SM_1_2017-10-26_14.34.14.psydat',
 'SM_1_2017-10-26_14.34.14_frame_intervals.log',
 'SM_1_2017-10-26_14.34.14_frame_intervals.png',
 'SM_1_2017-10-26_14.34.14_outputDict.pickle',
 'SM_1_2017-10-26_14.35.52PRACTICE.csv',
 'SM_1_2017-10-26_14.35.52PRACTICE.log',
 'SM_1_2017-10-26_14.35.52PRACTICE.psydat',
 'SM_1_2017-10-26_14.35.54.csv',
 'SM_1_2017-10-26_14.35.54.log',
 'SM_1_2017-10-26_14.35.54.psydat',
 'SM_1_2017-10-26_14.35.54_frame_intervals.log',
 'SM_1_2017-10-26_14.35.54_frame_intervals.png',
 'SM_1_2017-10-26_14.35.54_outputDict.pickle',
 'SM_1_2017-10-26_14.40.01PRACTICE.csv',
 'SM_1_2017-10-26_14.40.01PRACTICE.log',
 'SM_1_2017-10-26_14.40.01PRACTICE.psydat',
 'SM_1_2017-10-26_14.40.03.csv',
 'SM_1_2017-10-26_14.40.03.log',
 'SM_1_2017-10-26_14.40.03.psydat',
 'SM_1_2017-10-26_14.40.03_frame_intervals.log',
 'SM_1_2017-10-26_14.40.03_frame_intervals.png',
 'SM_1_2017-10-26_14.40.03_outputDict.pickle',
 'SM_1_2017-10-26_14.40.24PRACTICE.csv',
 'SM_1_2017-10-26_14.40.24PRACTICE.log',
 'SM_1_2017-10-26_14.40.24PRACTICE.psydat',
 'SM_1_2017-10-26_14.40.26.csv',
 'SM_1_2017-10-26_14.40.26.log',
 'SM_1_2017-10-26_14.40.26.psydat',
 'SM_1_2017-10-26_14.40.26_frame_intervals.log',
 'SM_1_2017-10-26_14.40.26_frame_intervals.png',
 'SM_1_2017-10-26_14.40.26_outputDict.pickle',
 'SM_1_2017-10-26_14.41.38.csv',
 'SM_1_2017-10-26_14.41.38.log',
 'SM_1_2017-10-26_14.41.38.psydat',
 'SM_1_2017-10-26_14.41.38_frame_intervals.log',
 'SM_1_2017-10-26_14.41.38_frame_intervals.png',
 'SM_1_2017-10-26_14.41.38_outputDict.pickle',
 'SM_1_2017-10-26_14.42.07.csv',
 'SM_1_2017-10-26_14.42.07.log',
 'SM_1_2017-10-26_14.42.07.psydat',
 'SM_1_2017-10-26_14.42.07_frame_intervals.log',
 'SM_1_2017-10-26_14.42.07_frame_intervals.png',
 'SM_1_2017-10-26_14.42.07_outputDict.pickle',
 'SM_1_2017-10-26_14.44.09.csv',
 'SM_1_2017-10-26_14.44.09.log',
 'SM_1_2017-10-26_14.44.09.psydat',
 'SM_1_2017-10-26_14.44.09_frame_intervals.log',
 'SM_1_2017-10-26_14.44.09_frame_intervals.png',
 'SM_1_2017-10-26_14.44.09_outputDict.pickle']

In [15]:
a = raw_input('bla?')


bla?

In [16]:
a == ''


Out[16]:
True

In [5]:
import numpy as np
import scipy.stats as stats

In [42]:
np.random.binomial(n=1, p=stats.norm.cdf(0.7, 1.25))


Out[42]:
0

In [27]:
stats.norm.cdf(self.response_time, 1)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-27-084d78903036> in <module>()
----> 1 stats.norm.cdf(self.response_time, 1)

NameError: name 'self' is not defined

In [ ]: