示例#1
0
# -*- coding: utf-8 -*-
import neuropsydia as n

n.start()

n.write("Welcome", style="title")
name = n.ask("What is your name?", y=5)
n.write("Ok, " + name + ", here is a super cool cat.", y=3)
n.image("cat.png", size=3, y=-3.5)
n.refresh()
n.time.wait(2000)

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
示例#3
0
        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
score = df["Answer"].sum()
示例#4
0
    df = processing(dfs)
    return(df)
#==============================================================================
# Run
#==============================================================================
n.start()
n.start_screen(name="CoCon", authors=authors)

experiment_start = datetime.datetime.now()



# Participant info
n.newpage()
participant_id = n.ask("Participant ID: ")



df = procedure()

# Save data
df["Participant_ID"] = participant_id
df["Experiment_Start"] = experiment_start
df["Experiment_End"] = datetime.datetime.now()
df["Version"] = version
df["Experiment_Duration"] = (datetime.datetime.now()-experiment_start).total_seconds()

n.save_data(df, filename="CoCon", path="./Data/", participant_id=participant_id, index=False)

n.end_screen(name="CoCon", authors=authors)
示例#5
0
staircase = False
n_trials = {"P1": 60, "P2": 80, "P3": 160, "P4": 160}
#n_trials = {"P1": 6, "P2": 6, "P3": 30, "P4": 6}

# Initialization
n.start()
t0 = datetime.datetime.now()
results = {}

# Identification
if testmode is True:
    participant = "test"
else:
    n.newpage((74,20,140))
    n.write("STAR CONTROL", y = 1.5, color = "white", size = 3)
    participant = n.ask("ID: ", x = -1, y = -3, color = "white", background = (74,20,140), size = 1.5)

# Create data folder
path = './data/' + participant + "/"
if os.path.exists(path) is False:
    os.mkdir(path)


# Instructions (can be activated to increase the pressure in the context of experiments with students)
n.instructions("This is a game designed to measure how fast your are, as speed has been shown to a reliable index of intellectual ability and mental agility.\n\nThe task is repetitive and long on purpose, as the ability of maintaining speed until the end is also an indicator of cognitive altertness and aptitude.\n\nHence, throughout the game, we would like you to try responding as fast as possible.", size=0.8, end_text="Press ENTER to start the game.")

# Part 1
# -----------------------------------------------------------------------------
start_time = datetime.datetime.now()
df_ProcessingSpeed = processing_speed(n_trials=n_trials["P1"], testmode = testmode, display_trigger = display_trigger)
save_data(df_ProcessingSpeed, start_time, participant, task = "Processing_Speed", path = path + participant + "_ProcessingSpeed")
示例#6
0
    sequence = np.random.randint(10, size=span)  # Generate sequence
    good_answer = ""  # Transform sequence of integers into string

    for digit in sequence:  # For every element in the sequence...
        good_answer = good_answer + str(
            digit)  # Add the current stimulus to sequence
        n.newpage("grey")
        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()  # Render 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
# Initialize trigger
trigger = n.Trigger(TTL=False, photosensor="black", photosensor_size=2.5)

#Create empty lists to store the stimuli displayed and the rating of the ppts
stimuli = []
rating_arousal = []
rating_valence = []
fixation = []

# =============================================================================
# Start
# =============================================================================
n.start()

participant = n.ask("ID: ")

n.instructions(
    "In this task, you will be presented with different images and your task is to rate how intense your feeling is when you see the images."
)

fixation_cross(3000)

for i in range(60):  # Number of trials
    n.newpage("grey", auto_refresh=False)
    random_image = random.choice(
        [x for x in list_stimuli if os.path.isfile(os.path.join(path, x))])
    n.image("images/" + random_image, size=20, y=0)
    trigger.start()
    n.refresh()
    n.time.wait(3000)