def _create_window(self): """ Creates a window based on the settings and calculates framerate. """ win = Window(monitor=self.monitor.name, **self.settings['window']) win.flip(clearBuffer=True) self.actual_framerate = win.getActualFrameRate() t_per_frame = 1. / self.actual_framerate logging.warn(f"Actual framerate: {self.actual_framerate:.5f} " f"(1 frame = {t_per_frame:.5f})") return win
def _create_window(self): """ Creates a window based on the settings and calculates framerate. """ win = Window(monitor=self.monitor.name, **self.settings['window']) win.flip(clearBuffer=True) self.actual_framerate = win.getActualFrameRate() if self.actual_framerate is None: logging.warn("framerate not measured, substituting 60 by default") self.actual_framerate = 60.0 t_per_frame = 1. / self.actual_framerate logging.warn(f"Actual framerate: {self.actual_framerate:.5f} " f"(1 frame = {t_per_frame:.5f})") return win
def __init__(self, window: visual.Window, static_clock, experiment_clock: core.Clock, marker_writer: Optional[MarkerWriter] = None, task_color: List[str] = ['white'], task_font: str = 'Times', task_pos: Tuple[float, float] = (-.8, .9), task_height: float = 0.2, task_text: str = '1/100', info_color: List[str] = ['white'], info_text: List[str] = ['Information Text'], info_font: List[str] = ['Times'], info_pos=[(.8, .9)], info_height=[0.2], stim_font='Times', stim_pos=(-.8, .9), stim_height=0.2, stim_sequence: List[str] = ['a'] * 10, stim_colors: List[str] = ['white'] * 10, stim_timing: List[float] = [1] * 10, is_txt_stim: bool = True, static_time: float = .05, trigger_type: str = 'image', space_char: SPACE_CHAR = SPACE_CHAR): """Initialize RSVP window parameters and objects. PARAMETERS: ---------- # Experiment window(visual.Window): PsychoPy Window static_clock(TODO): no idea experiment_clock(core.Clock): Clock used to timestamp experiment marker_writer(MarkerWriter): object used to write triggers to the daq stream. # Task task_color(list[string]): Color of the task string. Shares the length of the task_text. If of length 1 the entire task bar shares the same color. task_font(string): Font of task string task_pos(tuple): position of task string task_height(float): height for task string task_text(string): text of the task bar # Info info_text(list[string]): Text list for information texts info_color(list[string]): Color of the information text string info_font(list[string]): Font of the information text string info_pos(list[tuple]): Position of the information text string info_height(list[float]): Height of the information text string # Stimuli stim_height(float): height of the stimuli object stim_pos(tuple): position of stimuli stim_font(string): font of the stimuli stim_sequence(list[string]): list of elements to flash stim_colors(list[string]): list of colors for stimuli stim_timing(list[float]): timing for each letter flash """ self.window = window self.refresh_rate = window.getActualFrameRate() self.logger = logging.getLogger(__name__) self.stimuli_sequence = stim_sequence self.stimuli_colors = stim_colors self.stimuli_timing = stim_timing self.is_txt_stim = is_txt_stim self.staticPeriod = static_clock self.static_time = static_time self.experiment_clock = experiment_clock self.timing_clock = core.Clock() # Used to handle writing the marker stimulus self.marker_writer = marker_writer or NullMarkerWriter() # Length of the stimuli (number of flashes) self.stim_length = len(stim_sequence) # Informational Parameters self.info_text = info_text # Stim parameters self.stimuli_font = stim_font self.stimuli_height = stim_height self.stimuli_pos = stim_pos # Trigger Items self.first_run = True self.trigger_type = trigger_type self.trigger_callback = TriggerCallback() # Callback used on presentation of first stimulus. self.first_stim_callback = lambda _sti: None self.size_list_sti = [] self.space_char = space_char self.task = visual.TextStim(win=self.window, color=task_color[0], height=task_height, text=task_text, font=task_font, pos=task_pos, wrapWidth=None, colorSpace='rgb', opacity=1, depth=-6.0) # Create multiple text objects based on input self.text = [] for idx in range(len(self.info_text)): self.text.append( visual.TextStim(win=self.window, color=info_color[idx], height=info_height[idx], text=self.info_text[idx], font=info_font[idx], pos=info_pos[idx], wrapWidth=None, colorSpace='rgb', opacity=1, depth=-6.0)) # Create Stimuli Object if self.is_txt_stim: self.sti = visual.TextStim(win=self.window, color='white', height=self.stimuli_height, text='+', font=self.stimuli_font, pos=self.stimuli_pos, wrapWidth=None, colorSpace='rgb', opacity=1, depth=-6.0) else: self.sti = visual.ImageStim(win=self.window, image=None, mask=None, pos=self.stimuli_pos, ori=0.0)
person.id = demographics[0] person.first = demographics[1].upper() person.last = demographics[2].upper() person.country = demographics[3].upper() person.adress = demographics[4].upper() person.birth = demographics[5].upper() person.animal = demographics[6].upper() person.age = demographics[7] expVersion = int(demographics[8]) #setup Window win = Window(windowSize, fullscr=fullScr, waitBlanking=True, color='grey') #-------------------------------- FRAMERATE CHECK ---------------------------------------- if win.getActualFrameRate() > 62: print( 'Warning!!! Actual FrameRate is above 60Hz, display times may be inaccurate!!!' ) print('Actual Framerate is: ', win.getActualFrameRate()) print( 'If you want to proceed anyway, delete or comment the corresponding lines of code' ) quit() #delete this line if you want to proceed anyway #----------------------------------------------------------------------------------------- fixationCross = TextStim(win, text='+', units='norm', height=fixationHeight) practiceInstructions = '\ Herzlich willkommen, und vielen Dank fürs Teilnehmen! \n\ \n\