Package for running memory experiments
author: Tyler M. Ensor (firstname.lastname@example.org)
Cogandmem (short for Cognition and Memory) is a Python package for running memory experiments. It relies heavily on Pygame, a Python package generally used for creating video games. Cogandmem can be used to present stimuli (currently supports single words, word pairs, and images), display instructions to the screen, collect input from the keyboard (e.g., subjects typing their responses to a free-recall test), and play Tetromino (a Tetris clone) as a distractor task. At present, free and cued recall are supported, with plans to add old/new and forced-choice recognition in the near future.
Apart from several packages included in the Python Standard Library, cogandmem requires pygame. Installing cogandmem via a pip command should automatically install pygame if it is not already on your system. Cogandmem also requires numpy version 1.7.0 or later (this is when numpy.random.choice() was added).
The cogandmem package is made up of six modules:
- experiment: classes and functions for running experiments.
- text: functions for rendering text (e.g., instructions) to an instance of pygame.Surface. Functions in this module allow the user to render text to the screen without "touching" a pygame.Surface object (i.e., creation of the instance of pygame.Surface is "under the hood"), but creating the main display surface beforehand will give the user more control (see Example below).
- tetromino: a module inspired by Al Sweigart in his online book Making Games with Python and Pygame (2012). The tetromino module allows presentation of a Tetris clone as a distractor task during experiments (see Example below).
- score: functions for scoring the results of experiments.
- writing: functions for writing results of experiments to files.
- generic: functions that used by cogandmem but that do not fit thematically into one of the other modules.
Please note that all modules, classes, and functions include docstrings. A docstring for a module lists all of the classes and functions included in the module. A docstring for a class describes all of the class methods and attributes. Function and method docstrings describe what the function does and, except where very obvious, describes the required and optional (i.e., keyword) parameters. A heavily commented example script is available in the package (examples/cued recall/main.py). I plan to add more example scripts in the future.
At present, cogandmem works fairly well for free- and cued-recall experiments. However, a number of features need to be added, and some of the code needs to be cleaned up. Below is a nonexhaustive list of planned features and changes.
- functions for running recognition experiments (old/new, 2AFC, and intact/rearranged)
- Better functions for writing data. In particular, taking advantage of Python's csv module should considerably improve the process of writing data to files.
- code cleanup: Currently, cogandmem does not use any decorators. This should be changed in the next version. Many functions have several lines of identical code--using decorators will have the twofold benefit of improving code readability and trimming function length.
- variable-name consistency: At present, functions use different names to refer to the same concept. For example, functions refer to pygame.Clock objects using variable names such as clock, c, ticker, timer, and so on. More uniformity across functions will help readability, and will prevent constant checking of keyword-parameter names.
- data classes: Subject results are currently stored in dicts. This is somewhat awkward, requiring the definition of constants for dict entries. Instead, classes for storing experimental data should be created.
- study/test-list classes. Classes currently exist for individual items (e.g., Stimulus, WordPair). Classes for study/test lists would help immensely.
Please report bugs on GitHub or by emailing me at email@example.com. If you email me, please put cogandmem in the subject line. One of the issues with the current version of cogandmem is that several functions have a great deal of flexibility (see, e.g., cogandmem.experiment.free_recall()). This has the advantage of giving the user a lot of control over how to implement an experiment, but also means that it is difficult to test every possible combination of options. The package works for the experiments I have programmed, but I imagine the code contains some bugs I have yet to notice.
The cogandmem package is released under an MIT license (see license.txt for more information).
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size & hash SHA256 hash help||File type||Python version||Upload date|
|cogandmem-0.1.0-py2.7.egg (129.8 kB) Copy SHA256 hash SHA256||Egg||2.7||Jun 24, 2018|
|cogandmem-0.1.0.tar.gz (69.2 kB) Copy SHA256 hash SHA256||Source||None||Jun 24, 2018|