# -*- coding: utf-8 -*- """ Code example of a minimal digit span task. Authors: Dominique Makowski Copyright: The Neuropsydia Development Team Site: https://github.com/neuropsychology/Neuropsydia.py """ import neuropsydia as n # Load neuropsydia import numpy as np # For generation of random sequence n.start() # Initialize neuropsydia n.instructions("Listen to the experimenter.") # Display instructions # Initialize values number_of_fails = 0 # Initial number of errors span = 2 # Initial span 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
# -*- 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()
# -*- coding: utf-8 -*- """ Code example of a minimal Stroop task. Authors: Dominique Makowski Copyright: The Neuropsydia Development Team Site: https://github.com/neuropsychology/Neuropsydia.py """ import neuropsydia as n # Load neuropsydia import numpy as np # Load numpy import pandas as pd # Load pandas n.start() # Start neuropsydia # Initialize data storage data = {"Stimulus": [], "Stimulus_Color": [], "Answer": [], "RT": [], "Condition": [], "Correct": []} #============================================================================== # Part 1: Denomination #============================================================================== n.instructions("Press LEFT when RED, DOWN when GREEN and RIGHT when BLUE.") n_trials = 10 for trial in range(n_trials): n.newpage("grey") # Neutral grey background n.write("+") # Fixation cross
from unittest import TestCase import neuropsydia as n n.start(open_window=False) class TestColor(TestCase): def test_is_string(self): c = n.color("w") self.assertTrue(isinstance(c, tuple))
# -*- coding: utf-8 -*- """ Code example of a minimal go/no-go task. Authors: Dominique Makowski Copyright: The Neuropsydia Development Team Site: https://github.com/neuropsychology/Neuropsydia.py """ import neuropsydia as n # Load neuropsydia import random # Import the random module import pandas as pd # To manipulate and save the data import numpy as np # To do some maths n.start() # Start neuropsydia n.instructions("Goal: Hit SPACE whenever a GREEN circle appears. \nWhen it is RED, don't press anything.") # Display instructions and break line with \n n.newpage("grey") # Fill the screen n.countdown() # Display countdown # Initialize the data storage with a dictionary containing empty lists data = {"Trial": [], "Stimulus": [], "ISI":[], "RT":[], "Response":[]} for trial in range(5): # Iterate over the number of trials stimulus = random.choice(["green", "red"]) # Select a stimulus type ISI = random.randrange(start=500, stop=2000, step=500) # Select the inter-stimuli interval (ISI) n.newpage("grey") # Fill the screen n.write("+") # Fixation cross n.refresh() # Diplay it on screen
1: "I feel calm.", 2: "I feel secure.", 3: "I am tense.", 4: "I feel strained.", 5: "We're not allowed to reveal all the questions :(" # As it is the last dict item, no comma after that. }, "Reverse": { 1: True, 2: True, 3: False, 4: False, 5: False } } n.start() # Initialize neuropsydia participant_id = n.ask("Participant ID:", order=1) # Get participant id participant_gender = n.ask("Gender:", order=2) # Get participant's gender participant_age = n.ask("Age:", order=3) # get participant's age df = n.questionnaire(questions_dictionary, # The questions participant_id=participant_id, analog=False, # Lickert-like edges=[1, 4], # Values underneath labels=["Almost never", "Sometimes", "Often", "Almost always"], style="blue", # The cursor's color instructions_text="A number of statements which people have used to describe themselves are given below. \nSelect the number that indicate how you feel right now, that is, at this moment. \nThere are no right or wrong answers. Do not spend too much time on any one statement but give the answer which seems to describe your present feelings best.") # Add instructions at the beginning # Scoring