log_11_passive.txt 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. sub_id: 11
  2. age: 29
  3. sex: Female
  4. yoke_to: 9
  5. optional_stopping: False
  6. seed: 3
  7. -------------------------------------
  8. """Provide constants for several settings in the experiment."""
  9. import os
  10. from collections import OrderedDict
  11. import serial
  12. import numpy as np
  13. # MASTER SETTINGS
  14. # Set number of participants to record for your study. Must be divisible by 4
  15. n_participants = 40
  16. # Now define a function to create the experimental design for us
  17. def provide_experimental_design(n_participants):
  18. """Provide an experimental design given some participants.
  19. Parameters
  20. ----------
  21. n_participants : int
  22. The number of participants in the experiment. Must be divisible by 4.
  23. Returns
  24. -------
  25. yoke_map : collections.OrderedDict
  26. A dictionary that determines what kind of data participants see in the
  27. "yoked" condition. Participants are generally either yoked to
  28. themselves, or to another participant. See also the README.
  29. opt_stop_map : collections.OrderedDict
  30. A dictionary that determines whether a participant performs the
  31. experiment with or without optional stopping. True if with optional
  32. stopping, False otherwise.
  33. seed_map : collections.OrderedDict
  34. A dictionary that determines the payoff_settings to be used for the
  35. present participant in the "active" condition. The "yoked" (=passive)
  36. condition will be determined by `yoke_map`
  37. Notes
  38. -----
  39. This will produce a design as follows:
  40. ID yoke_to condition seed
  41. 1 1 fix 1
  42. 2 2 opt_stop 1
  43. 3 1 fix 1
  44. 4 2 opt_stop 1
  45. 5 5 fix 2
  46. 6 6 opt_stop 2
  47. 7 5 fix 2
  48. 8 6 opt_stop 2
  49. 9 9 fix 3
  50. ...
  51. """
  52. if n_participants % 4 != 0:
  53. raise ValueError('Your number of subjects MUST be divisible by 4.')
  54. # Below, we will automatically compute the design of the experiment
  55. # Set the IDs
  56. ids = np.arange(1, n_participants+1)
  57. # Set the yoke_map: Which participant gets yoked to whom
  58. yokes = np.empty(ids.size, dtype=int)
  59. yokes[0::4] = ids[::4]
  60. yokes[1::4] = ids[1::4]
  61. yokes[2::4] = ids[::4]
  62. yokes[3::4] = ids[1::4]
  63. yoke_map = OrderedDict(zip(ids, yokes))
  64. # Set the condition map: Which participant does optional stopping, and who
  65. # does not
  66. opt_stops = np.tile(np.array((False, True)), int(n_participants/2))
  67. opt_stop_map = OrderedDict(zip(ids, opt_stops))
  68. # Set the seed map: Controlling the payoff_settings that are generated for
  69. # each participant
  70. seeds = np.repeat(np.arange(1, n_participants / 4 + 1), 4)
  71. seeds = seeds.astype(int)
  72. seed_map = OrderedDict(zip(ids, seeds))
  73. return yoke_map, opt_stop_map, seed_map
  74. # And use the function to get the design
  75. yoke_map, opt_stop_map, seed_map = provide_experimental_design(n_participants)
  76. # The expected frames per second. Change depending on your hardware.
  77. EXPECTED_FPS = 60
  78. # Keylists for responses, "__" is a non-existent key serving as a placeholder
  79. KEYLIST_SAMPLES = ['s', 'd', '__', 'x'] # press x to quit
  80. KEYLIST_FINCHOICE = ['s', 'd', 'x']
  81. KEYLIST_DESCRIPTION = ['s', 'd', 'x']
  82. STOP_KEY = 'f' # used only if condition is optional stopping
  83. # Eyetracking variables
  84. GAZE_TOLERANCE = 0.2 # in psychopy norm units: the window where gaze is OK
  85. GAZE_ERROR_THRESH = 4 # after how many fixation errors to cancel the trial
  86. # Experiment settings
  87. txt_color = (0.45, 0.45, 0.45)
  88. circ_color = (-0.45, -0.45, -0.45)
  89. tfeeddelay_ms = (200, 400) # time for delaying feedback after an action
  90. toutmask_ms = (800, 800) # time for masking an outcome ("show blob")
  91. toutshow_ms = (500, 500) # time for showing an outcome ("show number")
  92. tdisplay_ms = (1000, 1000) # show color: new trial, error, final choice
  93. expected_value_diff = 0.9 # For payoff settings to be used
  94. # CUTOFF_P is used in get_random_payoff_settings. A negative value will lead
  95. # to a worse balanced set of random payoff settings, a value approaching 1
  96. # will lead to a better balance, but will decrease the pool of options to
  97. # draw randomly from. Middle ground is safe
  98. CUTOFF_P = 0.6
  99. # Set the fixation_stim colors for signalling state of the experiment
  100. color_standard = txt_color # prompt for an action
  101. color_newtrl = (0, 1, 0) # wait: a new trial is starting
  102. color_finchoice = (0, 0, 1) # wait: next action will be "final choice"
  103. color_error = (1, 0, 0) # wait: you did an error ... we have to restart
  104. # EXPERIMENT SETTINGS, including yoke_map to determine which participant
  105. # gets yoked to which
  106. monitor = 'room26' # see define_monitors.py
  107. maxwait = 3 # how long to wait before each action ... if longer: timeout
  108. exchange_rate = 0.005 # multiply this with accumulated points to get Euros
  109. lang = 'de'
  110. font = 'Liberation Sans'
  111. # Serial port
  112. # INSTRUCTIONS TRIGGER BOX
  113. # https://www.brainproducts.com/downloads.php?kid=40
  114. # Open the Windows device manager,
  115. # search for the "TriggerBox VirtualSerial Port (COM6)"
  116. # in "Ports /COM & LPT)" and enter the COM port number in the constructor.
  117. # If there is no TriggerBox, set ser to None
  118. ser = "COM4" # either address to serial port or None ... COM4
  119. if isinstance(ser, str):
  120. # Try to open a serial port
  121. try:
  122. ser = serial.Serial(ser)
  123. # If it doesn't work, raise an error ... except when we are on
  124. # Azure Pipelines for the CI testing. ('Agent.Id' is defined there.)
  125. except serial.SerialException as ee:
  126. agent_id = os.getenv('AZURE_PIPELINE', False)
  127. if not agent_id:
  128. raise ee
  129. else:
  130. print('serial "{}" does not exist. Not raising an error, assuming '
  131. 'we are on Azure Pipelines with Agend.Id={}'
  132. .format(ser, agent_id))
  133. # When sending EEG trigger signals / event markers it is important to "reset"
  134. # the serial port to zero after each sent byte. The time between the sent byte
  135. # and the resetting must be long enough so that the sampling rate of the EEG
  136. # system can pick up the change in signals. E.g., for a 1000Hz sampling
  137. # frequency, the trigger MUST be on for at least 1ms ... better for 2 or 3.
  138. # `WAITSECS` determines for how long triggers will be ON.
  139. # NOTE: `WAITSECS` should NOT be longer than the time the screen needs to
  140. # refresh, because we time our experimental presentations per frames and
  141. # window flips. If `WAITSECS` is longer than a flip takes, the following flip
  142. # will be delayed. Flip times for 60Hz=16.6mss, 120Hz=8.3ms, 144Hz=6.9ms
  143. WAITSECS = 0.002
  144. # Settings for sp task in all conditions
  145. # if no optional stopping, participants will always play `max_nsamples`
  146. # samples ... else, they can stop after a minimum of 1 sample ... or before
  147. # they have taken a maximum of `max_nsamples
  148. max_nsamples_opt_stop = 19
  149. max_nsamples = 12
  150. max_ntrls = 100
  151. block_size = 20
  152. # Settings for training
  153. test_max_ntrls = 2 # Up to a maximum of 5 ... bounded by sub-999 test file
  154. test_max_nsamples_opt_stop = max_nsamples_opt_stop
  155. test_max_nsamples = max_nsamples
  156. test_block_size = test_max_ntrls
  157. # In description
  158. DESCR_EXPERIENCED = True # Show experienced lotteries?
  159. fraction_to_run = 1. # what fraction of all trials to run?
  160. color_magnitude = (1, 0, 1)
  161. color_probability = (0, 0, 1)