# -*- coding: utf-8 -*- import neuropsydia as n n.start() n.newpage() n.scale(title="Is Python great?", y=3.3, anchors=["", ""], style="blue", analog=False, edges=[1, 5], labels=["not at all", "not really", "maybe", "quite", "totally"], labels_size=0.6) n.scale(title="How is neuropsydia?", y=-3.3, line_length=12, edges=[0, 100], anchors=["atrocious", "brilliant"], point_center=True, separation_labels=["Bad", "Good"], style="purple", show_result=True, show_result_shape_line_color="blue") n.close()
# -*- coding: utf-8 -*- import neuropsydia as n n.start() n.newpage() response = n.choice(["Yes", "No"], y=5, title="Isn't it easy?") response = n.choice(["Hell no", "Nope", "Dunno", "Sure"], y=-5, title="Am I better looking?", height=-2, boxes_edge_size=0, boxes_background=["red", "amber", "teal", "blue"], help_list=["means not at all", "means no", "means you don't know", "means yes"]) n.close()
while number_of_fails < 3: # Do it while the number of errors is smaller than 3 sequence = np.random.randint(10, size=span) # Generate sequence of size span with ints ranging from 0 to 9 good_answer = "" # Initiate an empty good_answer for digit in sequence: # For every digit in the sequence... good_answer = good_answer + str(digit) # Add the current stimulus to the good answer n.newpage("grey") # Load a grey background n.time.wait(250) # Display an empty screen for 250 ms n.newpage("grey") # Load a grey background n.write(digit, size=3) # Load the stimulus n.refresh() # Display the stimulus on screen n.time.wait(1000) # Wait 1000 ms # Get answer n.newpage("white") answer = n.ask("Answer:") # Manage result if answer == good_answer: span = span + 1 # Increase span number_of_fails = 0 # Reset value else: number_of_fails = number_of_fails + 1 n.newpage() # Load a white background n.write("Max span: " + str(span-1)) # Write task result n.refresh() # Render it on screen n.time.wait(3000) # Wait for 3s n.close() # Close neuropsydia
n.refresh() # Diplay it on screen response, RT = n.response(time_max=1500) # Wait until 1.5s and collect the response and its time # Categorize the response if response == "SPACE" and stimulus == "green": response_type = "HIT" # Hit if response != "SPACE" and stimulus == "green": response_type = "MISS" # Miss if response == "SPACE" and stimulus == "red": response_type = "FA" # False Alarm if response != "SPACE" and stimulus == "red": response_type = "CR" # Correct Rejection # Store data by appending each item to its list data["Trial"].append(trial) data["Stimulus"].append(stimulus) data["ISI"].append(ISI) data["RT"].append(RT) data["Response"].append(response_type) # Data saving df = pd.DataFrame.from_dict(data) # Transform the data dictionary into a proper and savable dataframe df.to_csv("data.csv") # Save it # Quick analysis RTs = df.query('Response=="HIT"')["RT"] # Select the Hits' RTs print(np.mean(RTs), np.std(RTs)) # Print the mean and the standard deviation print(len(df.query('Response=="FA"'))) # Print the number of intrusions (false alarms) n.close() # Close neuropsydia