Documentation

This part of the documentation details the complete neuropsydia for python API.

Core

newpage

neuropsydia.newpage(color_name='white', opacity=100, fade=False, fade_speed=60, fade_type='out', auto_refresh=True)[source]

Fill the background with a color.

Parameters:
  • color_name (str, tuple, optional) – name of the color (see color() function), or an RGB tuple (e.g., (122,84,01)).
  • opacity (int, optional) – opacity of the color (in percents).
  • fade (bool, optional) – do you want a fade effect?
  • fade_speed (int, optional) – frequency (speed) of the fading.
  • fade_type (str, optional) – “out” or “in”, fade out or fade in.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.newpage("blue")
>>> n.refresh()
>>> n.time.wait(500)
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • time

refresh

neuropsydia.refresh()[source]

Refresh / flip the screen: actually display things on screen.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.newpage("blue")
>>> n.refresh()
>>> n.time.wait(500)
>>> n.close()

Notes

Authors

Dependencies

  • pygame

Display

write

neuropsydia.write(text='Write something here', style='body', x=0, y=0, size=1.0, rotate=0, color='black', background=None, outline=False, outline_size=0.1, outline_color='black', allow=None, wait=None, long_text=False, fast=False)[source]

Display some text on screen.

Parameters:
  • text (str) – The text to display.
  • style (str) – ‘body’, ‘psychometry’, ‘psychometry_bold’, ‘light’, ‘bold’, ‘title’, ‘subtitle’ or ‘end’. Can overwrite other parameters such as position, size or allow. You can also insert the name of a system font, or the path to a specific font.
  • x (float) – Horizontal position of the center (from -10 (left) to 10 (right)).
  • y (float) – Vertical position of the center (from -10 (bottom) to 10 (top)).
  • size (float) – Text size.
  • rotate (int) – Rotation angle (0 to 360).
  • color (str or tuple) – Text color. See neuropsydia.color().
  • background (str) – Background color. See neuropsydia.color().
  • outline (bool) – Text outline (unperfect for now, as the outline is larger for horizontal than for vertical lines).
  • outline_size (float) – Outline size.
  • outline_color (str or tuple) – Outline color. See neuropsydia.color().
  • allow (str or list) – Wait until a specific key is pressed (e.g., ‘ENTER’, [‘LEFT’, ‘RIGHT’] or ‘any’).
  • wait (float) – Wait time (in milliseconds).
  • long_text (bool) – Set to True for longer texts on multiple lines. Then, the x and y parameters are not working, but you can jump lines using ‘backslash + n’ in your text. Some parameters are disabled. Unperfect for now.
  • fast (bool) – Disables some parameters for improved speed.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.write('here is my title', style='title')
>>> n.write('here is my text', font_color='red')
>>> n.write('press ENTER to quit', style='end')
>>> n.close()

Notes

Authors

Dependencies

  • pygame

image

neuropsydia.image(file, x=0, y=0, cache=None, path='', extension='', size=1.0, unit='n', scale_by='height', fullscreen=False, rotate=0, scramble=False, background=None, compress=False, compression=0, allow=None, wait=None, opacity=100, monitor_diagonal=24)[source]

Display an image on screen.

Parameters:
  • file (str) – Image filename.
  • x (float) – Horizontal position of image center (from -10 (left) to 10 (right)).
  • y (float) – Vertical position of image center (from -10 (bottom) to 10 (top)).
  • cache (dict) – Cache of preloaded files.
  • path (str) – File’s path.
  • extension (str) – File’s extension.
  • size (float) – Image size.
  • unit (str) – Size unit. ‘n’ for neuropsydia’s space, can be ‘cm’.
  • scale_by (str) – ‘height’ or ‘width’.
  • fullscreen (bool) – Fullscreen. Disable the size parameter.
  • rotate (int) – Rotation angle.
  • scramble (bool) – Scramble (randomize pixels).
  • background (str) – Background colour.
  • compress (bool) – Enable compression.
  • compression (int) – Compression rate.
  • allow (list) – Wait until a specific key is pressed (e.g., “ENTER”, [“LEFT”, “RIGHT”] or “any”).
  • wait (int) – Wait time (in milliseconds).
  • opacity (100) – Opacity (in percentage).
  • monitor_diagonal (int) – Monitor size (in inches).
Returns:

cache – The updated cache.

Return type:

dict

Example

>>> import neuropsydia as n
>>>
>>> n.start()
>>> for file in ["img1.png", "img2.png"]:
>>>    n.newpage()
>>>    n.image(file)
>>>    n.refresh()
>>>    n.time.wait(1000)
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • PIL

line

neuropsydia.line(left_x=-5, left_y=0, right_x=5, right_y=0, line_color='black', thickness=1)[source]

Draw a line.

Parameters:
  • left_x (float) – Left end horizontal position.
  • left_y (float) – Left end vertical position.
  • right_x (float) – Right end horizontal position.
  • right_y (float) – Right end vertical position.
  • line_color (str) – Line color.
  • thickness (float) – Line thickness.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.line()
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • pygame.gfxfraw

circle

neuropsydia.circle(x=0, y=0, size=10, line_color='black', thickness=0, fill_color='white')[source]

Draw a circle.

Parameters:
  • x (float) – Center’s horizontal position.
  • y (float) – Center’s vertical position.
  • size (float) – Diameter.
  • line_color (str) – Circle’s edges color.
  • thickness (float) – Circle’s edges thickness.
  • fill_color (str) – Circle’s fill color.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.circle()
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • pygame.gfxfraw

rectangle

neuropsydia.rectangle(x=0, y=0, width=10, height=10, line_color='black', thickness=1, fill_color=None)[source]

Draw a rectangle.

Parameters:
  • x (float) – Center’s horizontal position.
  • y (float) – Center’s vertical position.
  • width (float) – Rectangle’s width.
  • height (float) – Rectangle’s height.
  • line_color (str) – Rectangle’s edges color.
  • thickness (float) – Rectangle’s edges thickness.
  • fill_color (str) – Rectangle’s fill color.

Example

>>> import neuropsydia as n
>>> n.start()
>>> n.rectangle()
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • pygame.gfxfraw

Input

response

neuropsydia.response(allow=None, enable_escape=True, time_max=None, get_RT=True)[source]

Get a (keyboard, for now) response.

Parameters:
  • allow (str or list) – Keys to allow.
  • enable_escape (bool) – Enable escape key to exit.
  • time_max (int) – Maximum time to wait for a response (ms).
  • get_RT (bool) – Return response time.
Returns:

returns a tuple when get_RT is set to True

Return type:

str or tuple

Notes

Authors

Dependencies

  • pygame

ask

neuropsydia.ask(text='Write something here:', style='light', x=-8, y=0, order=None, size=1.0, color='black', background='white', hide=False, detach_question=False, question_style='light', question_x=0, question_y=0, question_size=1, question_color='black', question_long_text=False, allow=None, allow_length=None, allow_type=None, allow_max=None, allow_NA=True)[source]

Display a question and get the subject’s answer.

Parameters:
  • text (str) – The question to be displayed.
  • style (str) – “body”, “light” or ”bold”.
  • order (int) – For series of questions, it’s sometimes easier to just specify the order (1, 2 , 3, ...) and the quetsions will appear one under the other.
  • x (float) – Horizontal position (from -10 (left) to 10 (right)).
  • y (float) – Vertical position of the center (from -10 (bottom) to 10 (top)).
  • size (float) – Text size.
  • color (str or tuple) – Text color. See neuropsydia.color().
  • background (str or tuple) – Background color. See neuropsydia.color().
  • hide (bool) – Display “****” (stars) instead of the actual answer.
  • detach_question (bool) – If set to true, then the question can be manipulated separately using the parameters below.
  • question_style (str) – ‘body’, ‘psychometry’, ‘psychometry_bold’, ‘light’, ‘bold’, ‘title’, ‘subtitle’ or ‘end’. Can overwrite other parameters such as position, size or allow. You can also insert the name of a system font, or the path to a specific font.
  • question_x (float) – Horizontal position of the question (from -10 (left) to 10 (right)).
  • question_y (float) – Vertical position of the question (from -10 (bottom) to 10 (top)).
  • question_size (float) – Question size.
  • question_color (str) – Question color. See neuropsydia.color().
  • question_long_text (bool) – et to True for longer texts on multiple lines. Then, the x and y parameters are not working, but you can jump lines using ‘backslash + n’ in your text. Some parameters are disabled. Unperfect for now.
  • allow (list) – Allow only specific answers (e.g., [“yes”, “no”]).
  • allow_length (int) – Allow only a specific answer length.
  • allow_type (str) – “str”, “int” or “float”. Allow only a specific type.
  • allow_max (int) – When allow_type is int or float, set a maximum.
  • allow_NA (bool) – Allow absence of response.
Returns:

answer – Input.

Return type:

str

Example

>>> import neuropsydia as n
>>> n.start()
>>> answer = n.ask("Hey, you're good?")
>>> print(answer)
>>> n.close()

Notes

Authors

Dependencies

  • pygame

scale

neuropsydia.scale(style='red', x=0, y=-3.3, anchors=None, anchors_space=2, anchors_size=0.7, edges=[0, 100], validation=True, analog=True, step=1, labels='numeric', labels_size=0.8, labels_rotation=0, labels_space=-1, labels_x=0, line_thickness=4, line_length=8, line_color='black', background='white', title=None, title_style='body', title_size=1, title_space=1.75, point_center=False, point_edges=True, reverse=False, force_separation=False, separation_labels=None, separation_labels_size=1, separation_labels_rotate=0, separation_labels_space=-1, show_result=False, show_result_shape='circle', show_result_shape_fill_color='white', show_result_shape_line_color='black', show_result_shape_size=0.8, show_result_space=1.25, show_result_size=0.5, show_result_color='black', show_result_decimals=1, cursor_size=1)[source]

Draw a scale.

Parameters:
  • style (str) – style, check neuropsydia.scale_styles() function to see what’s available.
  • x (float) – Horizontal position of the center (from -10 (left) to 10 (right)).
  • y (float) – Vertical position of the center (from -10 (bottom) to 10 (top)).
  • anchors (list of two str) – a list of two propositions to be displayed on the sides of the scale (e.g., [not at all, very much]).
  • anchors_space (float) – spacing betweeen the edge and the anchors.
  • anchors_size (float) – size of the anchors’ font.
  • edges (list) – the underlying numerical edges of the scale.
  • validation (bool) – confirm the response with a second left click or withdraw with a right click.
  • analog (bool) – continuous (discrete) scale.
  • step (int) – if analog is True, what are the step to go between the edges (determine the number of points on the scale).
  • labels (str or list) – “num”, “numeric” or “numbers” or list of actual text labels (e.g., [“not at all”, “a bit”, “very much”]).
  • labels_size (float) – Size of labels.
  • labels_rotation (float) – Labels rotation angle.
  • labels_space (float) – Space between scale and labels.
  • labels_x (float) – Horizontal dodging position.
  • line_thickness (float) – Scale line thickness.
  • line_length (float) – Scale line length.
  • line_color (str) – Scale line color.
  • background (str) – Scale background color.
  • title (str) – Scale title/question to ask.
  • title_style (str) – ‘body’, ‘psychometry’, ‘psychometry_bold’, ‘light’, ‘bold’. You can also insert the name of a system font, or the path to a specific font.
  • title_size (float) – Title size.
  • title_space (float) – Space between scale and title.
  • point_center (bool) – Place a point at the center.
  • point_edges (bool) – Place points at the edges.
  • reverse (bool) – The result is scored as inverse.
  • force_separation (int) – Creates visual separations with points.
  • separation_labels (list) – Place labels corresponding to the separations.
  • separation_labels_size (float) – Separation labels size.
  • separation_labels_rotate (float) – Separation labels rotation angle.
  • separation_labels_space (float) – Space between scale and separation labels.
  • show_result (bool) – Add a marker to show the value on scale.
  • show_result_shape (str) – Shape of this marker. “circle” or “rectangle”.
  • show_result_shape_fill_color (str) – Fill color of the marker.
  • show_result_shape_line_color (str) – Line color of the marker.
  • show_result_shape_size (float) – Marker’s shape size.
  • show_result_space (float) – Space between scale and marker.
  • show_result_size (float) – Results text size.
  • show_result_color (str) – Results text color.
  • show_result_decimals (int) – How many decimals to show.
  • cursor_size (float) – Size of the circle cursor.
Returns:

response – Response value.

Return type:

float

Example

>>> import neuropsydia as n
>>> n.start()
>>> response = n.scale()
>>> n.close()

Notes

Authors

Dependencies

  • pygame

choice

neuropsydia.choice(choices=['Yes', 'No'], write_choices=True, overwrite_choices_display=None, choices_size=1.0, choices_color='black', choices_style='body', y=0, height=-2, boxes_space=0.5, boxes_background='white', boxes_edge_color='black', boxes_edge_size=3, confirm_edge_color='orange', confirm_edge_size=3, help_list=None, help_background='lightgrey', title=None, title_position='top', title_x=-7.5, title_space=0.75, title_style='body', pictures=None, pictures_size=0.5)[source]

Create clickable choice boxes.

Parameters:
  • choices (list) – List of choices.
  • write_choices (bool) – Write choices inside the boxes.
  • overwrite_choices_display (list) – Display different choices (but does not affect what is returned).
  • choices_size (float) – Choices text size.
  • choices_color (str) – Choices text color.
  • choices_style (str) – Choices text style.
  • y (float) – Vertical position.
  • height (float) – Boxes height (Should be negative).
  • boxes_space (float) – Spaces between boxes.
  • boxes_background (str) – Boxes background color.
  • boxes_edge_color (str) – Boxes edges color.
  • boxes_edge_size (float) – Boxes edges width.
  • confirm_edge_color (str) – When clicked once, to what color should the edges change?
  • confirm_edge_size (float) – When clicked once, to what width should the edges change?
  • help_list (list) – Display some additional text for each choice.
  • help_background (str) – Background color of the help band.
  • title (str) – Title text.
  • title_position (str) – Title position. “top” or “left”.
  • title_x (float) – Title horizontal position.
  • title_space (float) – Space between choices and title.
  • title_style (str) – Title style.
  • pictures (list) – Picture filenames (and path) to put within each box.
  • pictures_size (float) – Size of those pictures.
Returns:

response – The selected choice.

Return type:

str or float

Example

>>> import neuropsydia as n
>>> n.start()
>>> answer = n.choice(["No", "Maybe", "Yes"])
>>> n.close()

Notes

Authors

Dependencies

  • pygame

Meta

questionnaire

neuropsydia.questionnaire(questions_dictionary, questions_list_key_name='Item', background='white', size=1, show_page_number=True, randomize=False, reverse=False, results_save=False, results_name='questionnaire_results', results_path='', participant_id='', dimensions_mean=False, dimensions_key_name='Dimension', style='red', x=0, y=-3.3, anchors=None, anchors_space=2, anchors_size=0.7, edges=[0, 100], validation=True, analog=True, step=1, labels='numeric', labels_size=0.8, labels_rotation=0, labels_space=-1, labels_x=0, line_thickness=4, line_length=8, line_color='black', title=None, title_style='body', title_size=1, title_space=2, point_center=False, point_edges=True, force_separation=False, separation_labels=None, separation_labels_size=1, separation_labels_rotate=0, separation_labels_space=-1, show_result=False, show_result_shape='circle', show_result_shape_fill_color='white', show_result_shape_line_color='red', show_result_shape_size=0.8, show_result_space=1.2, show_result_size=0.5, show_result_color='black', instructions_text=None, instructions_top_space=5, show_result_decimals=1, cursor_size=1)[source]

A wrapper function for easily creating questionnaires. You can go back and forth in the questions using the LEFT and RIGHT keyboard arrows.

Parameters:
  • questions_dictionary (dict) –

    A dict of the following stucture:

    >>> questions_dictionary = {
    >>>     "Item": {
    >>>         1: "Is Neuropsydia great?",
    >>>         2: "Is Neuropsydia not great?",
    >>>         3: "Is Python great?",
    >>>         4: "Is Python not great?"
    >>>         }
    >>> }
    
  • questions_list_key_name (str) – Key name of the sub-dict containing the items.
  • background (str) – Background color.
  • size (int) – Question’s size.
  • show_page_number (bool) – Show page number.
  • randomize (bool) – Randomize question presentation.
  • reverse (bool) – Needs a “Reverse” sub-dict with booleans showing which questions are reversed.
  • results_save (bool) – Save the results.
  • results_name (str) – Filename.
  • results_path (str) – Path where to save.
  • participant_id (str) – Append the participant’s name in the filename.
  • dimensions_mean (bool) – Compute the mean by dimension. Needs a “Dimension” sub-dict.
  • dimensions_key_name (str) – Key name of the sub-dict containing dimensions.
  • style (str) – style, check neuropsydia.scale_styles() function to see what’s available.
  • x (float) – Horizontal position of the center (from -10 (left) to 10 (right)).
  • y (float) – Vertical position of the center (from -10 (bottom) to 10 (top)).
  • anchors (list of two str) – a list of two propositions to be displayed on the sides of the scale (e.g., [not at all, very much]).
  • anchors_space (float) – spacing betweeen the edge and the anchors.
  • anchors_size (float) – size of the anchors’ font.
  • edges (list) – the underlying numerical edges of the scale.
  • validation (bool) – confirm the response with a second left click or withdraw with a right click.
  • analog (bool) – continuous (discrete) scale.
  • step (int) – if analog is True, what are the step to go between the edges (determine the number of points on the scale).
  • labels (str or list) – “num”, “numeric” or “numbers” or list of actual text labels (e.g., [“not at all”, “a bit”, “very much”]).
  • labels_size (float) – Size of labels.
  • labels_rotation (float) – Labels rotation angle.
  • labels_space (float) – Space between scale and labels.
  • labels_x (float) – Horizontal dodging position.
  • line_thickness (float) – Scale line thickness.
  • line_length (float) – Scale line length.
  • line_color (str) – Scale line color.
  • background – Scale background color.
  • title (str) – Scale title/question to ask.
  • title_style (str) – ‘body’, ‘psychometry’, ‘psychometry_bold’, ‘light’, ‘bold’. You can also insert the name of a system font, or the path to a specific font.
  • title_size (float) – Title size.
  • title_space (float) – Space between scale and title.
  • point_center (bool) – Place a point at the center.
  • point_edges (bool) – Place points at the edges.
  • reverse – The result is scored as inverse.
  • force_separation (int) – Creates visual separations with points.
  • separation_labels (list) – Place labels corresponding to the separations.
  • separation_labels_size (float) – Separation labels size.
  • separation_labels_rotate (float) – Separation labels rotation angle.
  • separation_labels_space (float) – Space between scale and separation labels.
  • show_result (bool) – Add a marker to show the value on scale.
  • show_result_shape (str) – Shape of this marker. “circle” or “rectangle”.
  • show_result_shape_fill_color (str) – Fill color of the marker.
  • show_result_shape_line_color (str) – Line color of the marker.
  • show_result_shape_size (float) – Marker’s shape size.
  • show_result_space (float) – Space between scale and marker.
  • show_result_size (float) – Results text size.
  • show_result_color (str) – Results text color.
  • show_result_decimals (int) – How many decimals to show.
  • cursor_size (float) – Size of the circle cursor.
Returns:

df – A pandas’ dataframe containing the data.

Return type:

pandas.DataFrame

Example

>>> import neuropsydia as n
>>> questions_dictionary = {
>>>     "Item": {
>>>         1: "Is Neuropsydia great?",
>>>         2: "Is Neuropsydia not great?",
>>>         3: "Is Python great?",
>>>         4: "Is Python not great?"
>>>     },
>>>     "Reverse": {
>>>         1: False,
>>>         2: True,
>>>         3: False,
>>>         4: True
>>>     },
>>>     "Dimension": {
>>>         1: "Neuropsydia",
>>>         2: "Neuropsydia",
>>>         3: "Python",
>>>         4: "Python"
>>>     }
>>> }
>>> n.start()
>>> n.questionnaire(questions_dictionary, anchors=["No", "Yes"], results_save=True, dimensions_mean=True)
>>> n.close()

Notes

Authors

Dependencies

  • pygame
  • pandas

instructions

neuropsydia.instructions(text, background='white', color='black', size=1.0, title='INSTRUCTIONS', title_color='black', subtitle=None, subtitle_color='black', end_text='Appuyez sur ENTRER pour commencer.', top_space=5)[source]

Help incomplete, sorry.

Parameters:NA
Returns:
Return type:NA

Example

NA

Dominique Makowski

  • pygame 1.9.2

Miscellaneous

scale_styles

neuropsydia.scale_styles()[source]

Returns available scale styles.

Example

>>> import neuropsydia as n
>>> n.start()
>>> print(n.scale_styles())
>>> n.close()

Notes

Authors