Problem with 'Screen' function - PTB just installed

EEJDHUP7-20248131369:2ebe50a9f3c3fd2ab4d9300f9593b3b4bbd33d2c95b2f4f736b5296314c4c852

Hi,
I have a problem with the ‘Screen’ function.
I recently downloaded PTB the ‘Screen’ function gives me the following:
Invalid MEX-file ‘C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic\MatlabWindowsFilesR2007a\Screen.mexw64’: The specified module could not be found.
The file is actually there.

This is my MATLAB version:
‘24.1.0.2653294 (R2024a) Update 5’

The operating system is:
Windows 10 Pro

I used ‘vcredist_x64_2015-2019.exe’ to install.

I would appreciate your help.

Giorgio

Did you also install GStreamer (see “help GStreamer”)?

Yes, I did.
‘MinGW 64-bit 1.24.6 runtime installer’

That’s the wrong GStreamer flavor. Our docs stress that you must use the MSVC variant, not the MinGW variant. Uninstall that and then install the MSVC variant,
then retry.

-mario
[4 minutes out of 30 minutes paid support used up].

I guess you mean “then install the MSVC variant”.
I will do it.

After rerunning ‘SetupPsychtoolbox’, I saw some progress :slight_smile:

Good to hear. So it works now?

Yes, thank you very much

The problem I have now is that I have to run SetupPsychtoolbox each time I reboot

Try to run SetupPsychtoolbox when Matlab is started with Run As Administrator once, and I believe it should work next time.

I followed these instructions:
https://www.mathworks.com/matlabcentral/answers/344572-how-to-make-a-shortcut-to-always-run-as-administrator

Go to the MATLAB icon
Click on properties
Go to the Shortcut tab
Press Advanced…
Check the “Run as administrator” checkbox.

It didn’t work.

Didn’t SetupPsychtoolbox provide you with a helpful message on how to resolve this? It should have?

[7 minutes out of 30 minutes paid support used up].

Hi.
No Mario, I haven’t found anything.
Even if I ran SetupPsychtoolbox while running Matlab as administrator, I continue having to run SetupPsychtoolbox each time I start a session.
Any other suggestion?

I assume you downloaded the zip file with the latest Psychtoolbox? Or the MLTBX file?

What is the full output of SetupPsychtoolbox and PsychtoolboxRoot? What is the output of which pathdef?What is the output after quitting and restarting Matlab? What is the output of which pathdef after restarting Matlab?

[14 minutes out of 30 minutes paid support used up].

Hi Mario,

I paste here the information you asked.

PsychStartup: Adding path of installed GStreamer runtime to library path. [D:\gstreamer\1.0\msvc_x86_64\bin]

  • If I run the ‘Screen’ function, I initially get this:

In place of the expected mex file this placeholder file was executed:

Screen

This mex file seems to be missing or inaccessible on your Matlab path or it is dysfunctional:

Screen.mexw64

It is important that the folder which contains the Screen mex file is located before
the PsychBasic folder on your Matlab path.
On Matlab V7.4 (R2007a) or later versions, the folder
C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic\MatlabWindowsFilesR2007a\ must be before the folder
*C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic\ *

type path to display the current path and check for this condition.
If the order is wrong, simply cd into your Psychtoolbox root folder
C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\ and then run SetupPsychtoolbox again.
That is the simplest way of fixing such path problems - Or to get more diagnostic output.

Seems Screen.m is in the Matlab path before/above Screen.mexw64 instead of after/below it!
This will cause the mex file to be ignored, leading to this error.
Please run SetupPsychtoolbox again, to rectify this problem, or use Matlabs pathtool
to shuffle things into the right order. This folder:

C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic\MatlabWindowsFilesR2007a

needs to go above/before this folder:

C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic

On Microsoft Windows with supported Matlab versions (>= V7.4) it could also be that
the required Visual C++ 2015-2019 runtime libraries are missing on your system.
The Psychtoolbox/PsychContributed/ subfolder contains installer files for them, which
you can execute after quitting Matlab. The name of the file is:
vcredist_x64_2015-2019.exe and maybe also vcredist_x64_2010.exe.

NOTE: You may want to acquire paid support for future issues like this.
Please type ‘PsychPaidSupportAndServices’ to learn more.

Error using AssertMex (line 216)
Missing or dysfunctional Psychtoolbox Mex file for this operating system. Read the help text above carefully!!

Error in Screen (line 158)
AssertMex(‘Screen.m’);

  • Then I run “SetupPsychtoolbox” as suggested, and I get this:

Will setup working copy of the Psychtoolbox folder inside: C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox

Your old Psychtoolbox appears in the MATLAB/OCTAVE path:
Your old Psychtoolbox appears 1084 times in the MATLAB/OCTAVE path.
Before you decide to delete the paths, do you want to see them (yes or no)? n
You didn’t say “yes”, so I’m taking it as no.
Shall I delete all those instances from the MATLAB/OCTAVE path (yes or no)? y
Success.

Now adding the new Psychtoolbox folder (and all its subfolders) to your MATLAB/OCTAVE path.
Success.

Running post-install routine…

PsychStartup: Adding path of installed GStreamer runtime to library path. [D:\gstreamer\1.0\msvc_x86_64\bin]
Matlab release 2014b or later detected. Will prepend the following
folder to your Matlab path: C:\Users\User1\AppData\Roaming\MathWorks\MATLAB Add-Ons\Collections\Psychtoolbox-3\Psychtoolbox\PsychBasic\MatlabWindowsFilesR2007a\ …
PTB-INFO: Multi-display setup in explicit multi-display mode detected. Using the following mapping:
PTB-INFO: Screen 0 corresponds to the full Windows desktop area. Useful for stereo presentations in stereomode=4 …
PTB-INFO: Screen 1 corresponds to the display area of the monitor with the Windows-internal name \.\DISPLAY1 …
PTB-INFO: Screen 2 corresponds to the display area of the monitor with the Windows-internal name \.\DISPLAY2 …

*PTB-INFO: Your version of Matlab 64-Bit is global system DPI aware. On Windows-8 or later, fullscreen onscreen windows will only work *
PTB-INFO: properly timing-wise when displayed on displays with the same pixel density as your systems primary display monitor.
PTB-INFO: For your multi-display setup the stimulus display monitor must have a DPI of (144, 144), matching that of
PTB-INFO: your primary display monitor. Ideally you will only display on the primary display in the first place.
PTB-INFO: Displaying on anything with a different DPI will cause mysterious visual timing problems, sync failures etc.
PTB-INFO: Read ‘help RetinaDisplay’ for more info on this topic.

Trying to trigger an update of the fontconfig cache if that should prove neccessary.
This may take a couple of seconds, or sometimes even minutes. Please be patient…

Done with post-installation. Psychtoolbox is ready for use.

GENERAL LICENSING CONDITIONS AND TERMS OF USE:
----------------bla bla--------------------

BEGINNERS READ THIS:
------bla bla---------

Enjoy!

  • After doing this, I run the ‘Screen’ function again and it works.

  • It is necessary to run “SetupPsychtoolbox” at every new session, irrespective of whether I run MATLAB as Administrator or not.

  • “which pathdef” always gives me:
    C:\Program Files\MATLAB\R2024a\toolbox\local\pathdef.m

I hope this helps.

Giorgio

Ok, I think I know what happened. You, or someone before you originally installed Psychtoolbox via the Matlab toolbox add-on package via Matlabs Add-On Manager, ie. the file with the .mltbx ending. Iow. the 3.0.19.14.mltbx file instead of the 3.0.19.14.zip file.

The problem with the Matlab add-on manager method is that it adds Psychtoolbox folders in the wrong order, ie. the MatlabWindowsFilesR2007a subfolder after instead of before the PsychBasic folder, so the proper mex files can’t be found. SetupPsychtoolbox fixes this, but Matlab restores the old order and undo’s the fix at every restart. The add-on manager is not the brightest piece of software and I found it buggy in other areas as well, so while it looks like the most convenient way of installing Psychtoolbox, it is actually the most troublesome/clunky way at the moment. That’s why we don’t advertise it on our page with Download instructions. I’m tempted to disable the whole .mltbx download method, but Mathworks wanted us to offer this method for Matlab users, despite it not adding any advantages to the user experience.

I have an idea for how to make it less worse in some future PTB releases, but for now the advice is to avoid that method. Do this:

  1. Use the Matlab Add-on manager to completely remove your Psychtoolbox.
  2. Download the regular and recommended 3.0.19.14.zip file from currently https://github.com/Psychtoolbox-3/Psychtoolbox-3/releases/download/3.0.19.14/3.0.19.14.zip for the latest current release.
  3. Unzip it, cd() into its unzipped Psychtoolbox folder.
  4. Run SetupPsychtoolbox again.

After this, the path should persist across restarts of Matlab and things should hopefully work.

-mario
[32 minutes out of 30 minutes paid support used up - Paid support exhausted].