psychopy | For running psychology and neuroscience experiments | Machine Learning library

 by   psychopy Python Version: 2024.1.4 License: GPL-3.0

kandi X-RAY | psychopy Summary

kandi X-RAY | psychopy Summary

psychopy is a Python library typically used in Artificial Intelligence, Machine Learning, Deep Learning applications. psychopy has no vulnerabilities, it has a Strong Copyleft License and it has high support. However psychopy has 117 bugs and it build file is not available. You can install using 'pip install psychopy' or download it from GitHub, PyPI.

PsychoPy is an open-source package for creating experiments in behavioral science. It aims to provide a single package that is:. To meet these goals PsychoPy provides a choice of interface - you can use a simple graphical user interface called Builder, or write your experiments in Python code. The entire application and library are written in Python and is platform independent.
Support
    Quality
      Security
        License
          Reuse

            kandi-support Support

              psychopy has a highly active ecosystem.
              It has 1428 star(s) with 806 fork(s). There are 68 watchers for this library.
              There were 5 major release(s) in the last 6 months.
              There are 214 open issues and 1329 have been closed. On average issues are closed in 462 days. There are 30 open pull requests and 0 closed requests.
              It has a positive sentiment in the developer community.
              The latest version of psychopy is 2024.1.4

            kandi-Quality Quality

              OutlinedDot
              psychopy has 117 bugs (12 blocker, 3 critical, 77 major, 25 minor) and 10488 code smells.

            kandi-Security Security

              psychopy has no vulnerabilities reported, and its dependent libraries have no vulnerabilities reported.
              psychopy code analysis shows 0 unresolved vulnerabilities.
              There are 77 security hotspots that need review.

            kandi-License License

              psychopy is licensed under the GPL-3.0 License. This license is Strong Copyleft.
              Strong Copyleft licenses enforce sharing, and you can use them when creating open source projects.

            kandi-Reuse Reuse

              psychopy releases are available to install and integrate.
              Deployable package is available in PyPI.
              psychopy has no build file. You will be need to create the build yourself to build the component from source.
              psychopy saves you 134262 person hours of effort in developing the same functionality from scratch.
              It has 140478 lines of code, 6568 functions and 669 files.
              It has high code complexity. Code complexity directly impacts maintainability of the code.

            Top functions reviewed by kandi - BETA

            kandi has reviewed psychopy and discovered the below as its top functions. This is intended to give you an instant insight into psychopy implemented functionality, and help decide if they suit your requirements.
            • Layout the text .
            • Make the menu
            • Runs the program diagnostics .
            • Imports conditions from file .
            • Write iohub code to file .
            • Save an event report .
            • Load plugin .
            • Launch Hub server .
            • Create a texture .
            • Load a file into memory .
            Get all kandi verified functions for this library.

            psychopy Key Features

            No Key Features are available at this moment for psychopy.

            psychopy Examples and Code Snippets

            Communicating with PsychoPy to render faces online,Setting up PsychoPy
            Pythondot img1Lines of Code : 88dot img1License : Strong Copyleft (GPL-3.0)
            copy iconCopy
            from py_client import PythonMHC
            makehuman = PythonMHC()
            
            import atexit
            # when the session ends, close the link, but keep the server alive, waiting for the next PsychoPy run.
            # at the end of a run, makehuman.close() will send the string, 'exit', 
            #  t  
            copy iconCopy
            # ...
            from pylsl import StreamInfo, StreamOutlet
            info = StreamInfo(name='my_stream_name', type='Markers', channel_count=1,
                              channel_format='int32', source_id='uniqueid12345')
            # Initialize the stream.
            outlet = StreamOutlet(info)
            # ...  
            copy iconCopy
            pip install pylsl
              
            copy iconCopy
            >>> from psychopy import logging
            >>> help(logging.log)
            
            Help on function log in module psychopy.logging:
            
            log(msg, level, t=None, obj=None)
                Log a message
            
                usage::
                    log(level, msg, t=t, obj=obj)
            
                Log the
            copy iconCopy
            def onExit():
                """Restore keystroke echo when we exit"""
                os.system('stty echo')
            
            def captureControl_C(signum, frame):
                """If user types control-c, restore keystroke echo before quitting"""
                # Restore th
            Why is my event.getKeys() memory buffer not clearing?
            Pythondot img6Lines of Code : 27dot img6License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
                    if kb.status == STARTED:
                       
                        # At the start of the loop, we check whether the scale is at either of its poles, 
                        # and if so, we reset the keys variable and clear the event log.
                        if abs(y1)
            PsychoPy - If user doesn’t press anything, automatic assignment for key to “left” key
            Pythondot img7Lines of Code : 3dot img7License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            if keyDecisionResponse.keys is None:
                keyDecisionResponse.keys = "left" # Or however you assign it
            
            Simple rectangle experiment in psychopy
            Pythondot img8Lines of Code : 4dot img8License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            datafile = open("stimuli.csv", "rt")
            
            datafile = open("stimuli.csv", "r", encoding="utf-8-sig")
            
            PYTHON : Make a list of 4 columns with 2 lists of 2 columns
            Pythondot img9Lines of Code : 15dot img9License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            Mouse = [['x1', 'y1'], ['x2', 'y2']]
            Target = [['xA', 'yA'], ['xB', 'yB']]
            
            [item for sublist in zip(Mouse, Target) for item in sublist]
            
            [['x1', 'y1'], ['xA', 'yA'], ['x2', 'y2'], ['xB', 'yB']]
            
            <
            Read multiple csv data files and sort the data into a new csv file
            Pythondot img10Lines of Code : 24dot img10License : Strong Copyleft (CC BY-SA 4.0)
            copy iconCopy
            import csv
            import glob
            import os
            
            path = r'.\_reading data-2'  # Path of directory containing data files.
            extension = 'csv'
            fieldnames = 'key_resp.rt', 'key_resp_4.rt', 'participant'
            output_filename = 'sort.csv'  # Output filename.
            output_

            Community Discussions

            QUESTION

            PsychoPy: Runtime error while logging a message ("TypeError: '<' not supported between instances of 'str' and 'int'")
            Asked 2022-Feb-19 at 03:12

            I get a syntax error in PsychoPy’s PTB logging code. My code:

            ...

            ANSWER

            Answered 2022-Feb-19 at 03:12

            If you look at the documentation for logging.log...

            Source https://stackoverflow.com/questions/71181635

            QUESTION

            PTB-WARNING: During PsychHID invocation: Some other running application is preventing me from accessing the keyboard/keypad/mouse/
            Asked 2022-Feb-12 at 20:36

            I'm using the Psychopy module in Python. My code calls waitKeys(...) to get keypresses and reaction times. 90% of the time it works perfectly, but occasionally when I launch it I get this (exactly this, not an infinite repetition):

            ...

            ANSWER

            Answered 2022-Feb-12 at 20:36

            Solved (kind of!).

            For UI reasons, I stop keys typed during the experiment from being echoed to the screen (otherwise the screen gets full of random junk). I do this by sending stty -echo to the parent shell.

            But when exiting from the program (for any reason) I need to undo this by sending stty echo. So I set up an exit handler:

            Source https://stackoverflow.com/questions/71088710

            QUESTION

            How to make sound read by PsychoPy
            Asked 2021-Dec-17 at 12:11

            I'm trying to figuring the problem out I'm facing with PsychoPy. When I try to upload this file

            that actually is a .svp file I get this error:

            ...

            ANSWER

            Answered 2021-Dec-17 at 12:11

            From the error message I believe the sound file you've used here has a sampling rate of 32000 Hz, but you have another sound in your project sampled at 48000 Hz. Switching between sample rates is called resampling but resampling takes time. PsychoPy is designed to provide low-latency playback of sounds but to do this it will not perform any resampling for you. As a result, you should convert all your sounds to use the same sampling rate before the study runs using some audio software

            Source https://stackoverflow.com/questions/70290639

            QUESTION

            Simple rectangle experiment in psychopy
            Asked 2021-Jun-06 at 22:00

            enter image description hereI am trying to adapt an existing script to create a very simple experiment in psychopy in which the aim is that a rectangle with different colours and dimensions loops through the screen.

            ...

            ANSWER

            Answered 2021-Jun-06 at 22:00

            I see no problem in your code.

            Most likely the problem is in your CSV file. I think it was saved with encoding UTF-8 with BOM-signature. Try to change one line in your code:

            Source https://stackoverflow.com/questions/67672482

            QUESTION

            Failure to Psychopy GetKeys
            Asked 2021-Mar-25 at 04:42

            My task is to design a square block. It will run randomly from one side of the screen to the other. And a beep will be played sometime. One has to push the botton(Here is keyboard) as soon as he hears the beep. The question is, when I use the "getkeys" method, it always returns an empty list. The RT shows that it main get the very first input in the buffer. I also tried eventclear, but seemed useless.

            Here is the code.

            ...

            ANSWER

            Answered 2021-Mar-25 at 04:42

            The question is, when I use the "getkeys" method, it always returns an empty list.

            event.getKeys() is an instantaneous check of the keyboard buffer. It will always return an empty list unless a key has been pressed since the last call to the function. So it is usually called in a loop, often once per screen refresh, to detect when a keypress has occurred. The result is that it will return an empty list many times, until a key is actually pressed.

            But PsychoPy's event module has actually been deprecated in favour of the newer Keyboard class. This has the advantage that it returns the actual time that the key was pressed: when using event.getKeys(), one just infers the reaction time from the time that the function was called. This is some time after the key is pressed - even if you are calling the function on every screen refresh (typically at 60 Hz), this limits the time resolution to 16.7 ms. The Keyboard class, meanwhile, runs in a separate process and continually checks the keyboard hardware, allowing a precision more at the millisecond level.

            Documentation on the Keyboard class is here: https://www.psychopy.org/api/hardware/keyboard.html

            Source https://stackoverflow.com/questions/66792963

            QUESTION

            PYTHON : Make a list of 4 columns with 2 lists of 2 columns
            Asked 2021-Mar-08 at 00:23

            I'm really sorry if the question was already answered, I haven't found the correct topic ... I'm on a project with Pavlovia and Pyschopy.

            I want my participants to keep the cursor of the mouse inside a moving box (target). I'm recording the data, and I want to:

            1. record the position of the mouse and the target
            2. calculate the distance between the mouse and the centre of the target during each frame
            3. count how often the mouse was out of the box

            The problem is between step 1 & step 2 :

            • I can record in file "Mouse.csv" the position of the mouse (column for x and column for y)
            • I can record in the file "Target.csv" the position of the target (column for x and column for y)

            BUT I can't have the positions in 1 file with 4 columns (Mouse x ; Mouse y ; Target x ; Target y)

            My problem is very similar as :

            But it's not working correctly

            The lists are looking like :

            • Mouse : [['x1', 'y1'], ['x2', 'y2'], [...]]
            • Target : [['xA', 'yA'], ['xB', 'yB'],[...]]

            And I would like to get [['x1', 'y1'], ['xA', 'yA'], ['x2', 'y2'],['xB', 'yB'],[...]]

            But when I can join the lists I just have something like [['x1', 'y1'], ['x2', 'y2'], ['xA', 'yA'], ['xB', 'yB'],[...]] :-(

            ...

            ANSWER

            Answered 2021-Mar-05 at 21:50

            You can do this with zip and then flatten it to get items back. You can zip the 2 lists element-wise (corresponding elements of both lists added to a tuple together.

            Post that you can use [item for sublist in list for item in sublist] which lets you flatten and break the tuples into corresponding items.

            List this -

            Source https://stackoverflow.com/questions/66495962

            QUESTION

            Read multiple csv data files and sort the data into a new csv file
            Asked 2021-Feb-12 at 17:36

            I am trying to read through multiple csv files in a folder, extract three columns (key_resp.rt, key_resp_4.rt, and participant) from each csv file and write these information in a new csv file. I am able to get the for loop running without write the result into the csv files. But with the code below, the new csv file (sort.csv) only contains the header of the data strings without the real data.

            My code:

            ...

            ANSWER

            Answered 2021-Feb-12 at 17:36

            While it would be possible to open the output file multiple times and add data to it (by using a mode argument of 'a' for "append" instead of "w" for normal (over) writing—see the open() function documentation—in this case it would be less awkward to just open the output file once and leave it that way while appending data to it from the input files, one-by-one.

            This is what I mean: (Note: no attempt was made to sort the data because you haven't specified how you wanted that done.)

            Source https://stackoverflow.com/questions/66164164

            QUESTION

            Alternatives to Psychopy
            Asked 2020-Nov-30 at 21:11
            Main question:

            I'm trying to build a brain-computer interface (BCI) experiment in Python that involves "high frequency" flashing (SSVEP), decision-making stimuli (P300), signal acquisition (EEG, with OpenBCI), and classifiers. I've been trying to use Psychopy toolbox for the interface part, but, unfortunately, it has been such a headache to make it work properly in parallel with the other processes on my current Lab PC that I'm starting to look for substitutes.

            I was wondering if anyone knows alternative toolkits, plugins, or libraries that would be suitable for implementing such interfaces (i.e., flashing, sending timestamps, and modifying interface based on classification feedback).

            Side-notes:

            Some toolkits that show up as alternatives to Psychopy are PsyToolkit, Paradigm and SuperLab 6, but I'm not sure they have the same functionality.

            I tried looking into OpenSesame in the past too, but it seems like it is not possible to acquire signals that easily with it. If you have any resources that could prove me wrong, please feel free to link them too.

            Thoughts on those would be also very welcomed.

            ...

            ANSWER

            Answered 2020-Nov-30 at 21:11

            If you are facing difficulties with PsychoPy, which is really just a set of modules with the full power of Python behind it, then you are certainly going to be frustrated with options like PsyToolKit, which, being browser-based, is never going to be able to give you the level of control you need over your system.

            OpenSesame is Python (and often PsychoPy) based under the hood. Paradigm seems to have a nice interface but to add more sophisticated functionality, also uses Python scripting (although seems to still be at version 2.6). I'm not that familiar with SuperLab, but it has been around a long time, and does seem to be focussed on lab equipment use.

            But it seems that your issues are more to do with working in parallel with other computer processes rather than PsychoPy per se (which doesn't impose any limitations other than those inherent in Python itself). As noted above, the alternatives you list either won't give the level of control you need, or will also require Python for hardware interfacing.

            You might be best to describe specific issues and seek help with those. Many other people have used PsychoPy and Python to display stimuli and record EEG - this task is in no way insurmountable.

            Source https://stackoverflow.com/questions/65077518

            QUESTION

            Does anyone know how to fix random green lines appearing on PsychoPy stimuli?
            Asked 2020-Nov-10 at 16:49

            I've just started using PsychoPy and I've tried to flip text and a grating, both of which appear broken up with green lines. Anyone know how to fix this?

            I'm using PyCharm with Python 3.8 and I get these error messages, not sure if related:

            ...

            ANSWER

            Answered 2020-Oct-29 at 15:50

            I'm experiencing the same issue but found that this is only the case on my computer. When I use the exact same code on a different computer, everything appears normal.

            Source https://stackoverflow.com/questions/64333695

            QUESTION

            How to add a confidence interval to a PsychoPy RatingScale?
            Asked 2020-Sep-24 at 00:42

            I am programming a task in PsychoPy (version 1.84.2), where participants have to rate the contrast difference between some gratings (e.g. a value between -1 and 1). I designed a rating scale using visual.RatingScale. Now I wanna ask the participants to add two more markers to the scale indicating their confidence interval. OR even better: participants could use the scroll wheel of the mouse to adapt the width of the interval.

            Is there any possibility to do this??

            Code:

            ...

            ANSWER

            Answered 2020-Sep-24 at 00:42

            I'm not sure if it's available back in version 1.84 (or why you need to use such an old version of PsychoPy), but the general advice now would be to avoid using the RatingScale class and instead use the simpler but more extensible Slider class.

            Regardless, what I'd suggest is that you avoid modifying that object by adding extra markers and so on. Instead create and draw a separate rectangular ShapeStim object: https://www.psychopy.org/api/visual/shapestim.html

            Set the vertical position of that rectangle to be a constant, either above, below, or behind the slider as required. On each frame, set its centre to correspond to the marker value of the slider or rating scale. Monitor the mouse scroll wheel, and use that to control the length of the rectangle, to indicate the uncertainty width.

            Source https://stackoverflow.com/questions/64025712

            Community Discussions, Code Snippets contain sources that include Stack Exchange Network

            Vulnerabilities

            No vulnerabilities reported

            Install psychopy

            You can install using 'pip install psychopy' or download it from GitHub, PyPI.
            You can use psychopy like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.

            Support

            To contribute, please fork the repository, hack in a feature branch, and send a pull request. For more, see CONTRIBUTING.md and the developers documentation at https://www.psychopy.org/developers/developers.html.
            Find more information at:

            Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items

            Find more libraries
            Install
          • PyPI

            pip install psychopy

          • CLONE
          • HTTPS

            https://github.com/psychopy/psychopy.git

          • CLI

            gh repo clone psychopy/psychopy

          • sshUrl

            git@github.com:psychopy/psychopy.git

          • Stay Updated

            Subscribe to our newsletter for trending solutions and developer bootcamps

            Agree to Sign up and Terms & Conditions

            Share this Page

            share link