What i want to do now is to show many pictures in threading.When i tried using the ImageStim to display pictures in threading,the error,glUseProgram is not exported by the available OpenGL driver. VERSION_2_0 is required for this functionality,showed up.How could i fix this problem?Any hlep would highly appreciated.
See this thread for information about problems with using threads. Could you explain why you need to use threads? Perhaps there is another approach.
Thank you so much for your reply. Sorry for your reply twice about my similiar message about threads.In my experiment,processing signal in real-time is what i want to complete.Psychopy is used to show pictures as stimulus and Biosemi to record data.For this point,i think it’s ok to meet the nedd of synchronization with these two things in threads.Am i right?If not, how could i realize real-time processing?This really confused me for long time.
I haven’t used it much, but I think this is something that psychopy.iohub might be able to help with.
To guess (because you did not post any actual code) it looks like you might be mixing between threads the work of drawing to the screen. Never do that. If you need to animate the display while collecting data simultaneously from an instrument then put all of the animation drawing code in one process and all of the code for handling your instrument, BioSemi in this case, in another process. All of the animation drawing stuff includes the calls to open and close the window and load the PsychoPy modules for doing that, etc.
Without knowing what are your requirements, we can not tell whether threading is a viable solution. Consider whether you need multiple threads or instead multiple processes. The C-Python GIL and not having independent control of CPU scheduling priority in python threads limits their utility and can make that approach unworkable for some applications. The multiprocessing module might be the right choice here.
Something to consider is that you might not even need threads if you can poll the instrument which you are reading from fast enough from within the animation loop. That method is usually simplest and best when it works. And, of course, if you are displaying static images for a long enough duration, then you might not even need an animation loop, just draw and do one buffer flip then read from the instrument.
Finally, if your experiment is not branching according to input from the instrument during the experiment, multiprocessing is super easy because the IPC requirement are little or none. IPC can quickly become a can of worms without explicit definitions of states, transitions and signals of each process.
Thanks for your reply.According to your suggestions,i just used the IPC to satisfied my need of displaying images and collecting data simultaneously.Your opinion really do me a lot.