PTB adding folders to Matlab path on startup

The pre-cursors, firstly:
Ubuntu Linux 20.04
Matlab R2021b 64-bit
PTB 3 v3.0.19 sourced from NeuroDebian (with Mario’s patches to CalibrateMonSpd.m as previously discussed).

Paid support info:
Order Numbers: TJ3HSUNX and VCCC6L4H

Where is the PTB script or macro that automatically updates the Matlab path upon starting Matlab?

This is a “temporary problem”, as we are part-way through an experiment and don’t want to change or update PTB in case it causes the experiment script to crash. Hence we are stuck with an old version of PTB3.

The issue is that I have changed a few lines in one or two PTB functions to make them suit our experiment, and saved those modified files in a separate directory (mainly because PTB3 installs by default in /usr/share and non-sudo users can’t save from Matlab to those directory locations). In order to ensure Matlab calls up my modified functions - and not the old, unmodified PTB versions of those functions - I deleted one or two PTB folders from the Matlab path and added the path to my local directory in their place.

All was good, until we came back the next day and re-started Matlab, whereupon the old, redundant directory references had been re-inserted into pathdef.m.

Therefore the experimenter needs to edit the Matlab path each time Matlab is started, to remove those redundant folders from the pathdef and ensure Matlab finds the correct, modified functions in my local directory.

I tried re-naming the directories in usr/share/psychtoolbox-3/ to be (for example) “PsychHardware_old”, but the very clever PTB script added a reference to those “_old” folders in the Matlab path! So it still requires the path to be edited each time Matlab is re-started.

I appreciate this is a problem of my own making, in a sense, because PTB is only doing what it was designed to do, and ensuring the Matlab path allows access to all PTB functions. However… it’s a real pain for us, until the current experiment is done and we can update PTB3.

The question is: where is the PTB script or macro that is updating the Matlab path? I searched for a startup.m and looked in PsychStartup.m and PsychInitialize.m, but nowhere seems to be updating the Matlab path, as far as I can see.

All suggestions or insights gratefully received (especially by the person running the experiment, who has to keep going into “Set path” each morning!).

Thanks,
Eric

you can use the function rmpath and addpath (and perhaps genpath) to edit your path from code. I’d put that atop your script

To answer your question:
Psychtoolbox\PsychInitialize\startup.m and what it calls is all that does any form of path updating.

All those PTB folders are only added to the path during install, not during each start. Probably your changes did not persist. savepath() is your friend, assuming you have sufficient permissions

Hi Eric,

so the way to do it would be to savepath() once everything is right, and the proper permissions are set on your Matlab install, and then next time just launch Matlab regularly, ie. via. clicking the Matlab icon, or on terminal via matlab, instead of ptb3-matlab from a terminal.

The afaik only thing ptb3-matlab does is launch Matlab with the auto-generated path to Psychtoolbox temporarily added for that session, but not saved! The idea being that ptb3-matlab allows to use ptb for a session without permanent change to the Matlab path. I think NeuroDebian has similar launchers for other Matlab toolboxes. The magic for auto-generating and setting that path is in more /etc/ptb3/matlab.sh - it is written by the NeuroDebian team, not part of PTB, not written by us.

Btw. those “Order Numbers: TJ3HSUNX and VCCC6L4H”, which made no sense to me first, now i get. These were for extra support hours paid by your admin, apparently at 15th December 2023, to back-pay for part of the 11 unpaid hours of work from this issue and previous convdersation Single row entries in "theClut" during calibration with a spectroradiometer (CalMonSpd) - #5 by Erroric. I was quite confused why somebody unprompted bought multiple work hours, so that makes sense now, and big thanks for back-paying that.

As of now, Orderid VCCC6L4H is completely used up, and most of TJ3HSUNX, but I’ll leave you 20 minutes remaining time-budget on OrderId TJ3HSUNX. You’d have to mention that for future requests, and that it is an extra-hour package, to actually find it again, as your regular one-year membership has ran out last December, as well as the entitlement for discounts.

Thank you both. I didn’t know what ptb3-Matlab was doing - but now I do.

Now sorted, so thanks for your help.

Also @mariokleiner I had forgotten that our regular paid membership had expired. I will ask the admin to re-purchase that as soon as they can.