Back to the main page.

Bug 2137 - ft_componentanalysis reports a randomseed error on newer versions of matlab

Status CLOSED INVALID
Reported 2013-04-25 22:30:00 +0200
Modified 2019-08-10 12:03:55 +0200
Product: FieldTrip
Component: core
Version: unspecified
Hardware: PC
Operating System: Linux
Importance: P3 normal
Assigned to:
URL:
Tags:
Depends on:
Blocks:
See also:

Ana Todorovic - 2013-04-25 22:30:11 +0200

I am running Matlab and FieldTrip internally, from mentat001. I have previously preprocessed and resampled my data. When running ft_componentanalysis from Matlab (versions R2012, R2009, R2008b), I get one of these two errors back (depending on the version): -------------------- Undefined function or variable 'rng'. Error in randomseed (line 44) s=rng; Error in ft_preamble_randomseed (line 11) ftFuncRandomseed=randomseed(cfg.randomseed); Error in ft_preamble (line 54) evalin('caller', ['ft_preamble_' cmd]); Error in ft_componentanalysis (line 163) ft_preamble randomseed -------------------- ??? Undefined variable "RandStream" or class "RandStream.getDefaultStream". Error in ==> randomseed at 41 stream = RandStream.getDefaultStream; Error in ==> ft_preamble_randomseed at 11 ftFuncRandomseed=randomseed(cfg.randomseed); Error in ==> ft_preamble at 54 evalin('caller', ['ft_preamble_' cmd]); Error in ==> ft_componentanalysis at 163 ft_preamble randomseed -------------------- Here is what I ran prior to getting the error: cfg = []; cfg.detrend = 'no'; cfg.resamplefs = 150; data = ft_resampledata(cfg, data); cfg = []; cfg.channel = {'MEG'}; cfg.numcomponent = 60; comp = ft_componentanalysis(cfg, data); I don't get this error if I'm running version 2008a. In other words ft_componentanalysis works when I ask for matlab76 in the terminal, but not 77, 78, 79.


Johanna - 2013-04-26 09:01:44 +0200

Hi Ana, this is strange, I cannot replicate it. The core of the error is in calling >> state=randomseed([]); It seems as if it's running in Matlab2008a (or older) when in fact the function 'matlabversion' detects a different (newer) version. When you open a Matlab (any version) from the beginning and type 'which randomseed' or 'which matlabversion', does it point to a file, or does it say (as it should) 'not found'? If you subsequently change directory into fieldtrip/utilities/private, then run the line >> state=randomseed([]); does it work ok (no errors)? (for the matlab versions you tested?)


Ana Todorovic - 2013-04-26 11:28:26 +0200

(In reply to comment #1) I did 'which randomseed' and 'which matlabversion' on two versions of Matlab, one that did the ICA with no error (76) and one that gave an error (79). In both cases these functions were not found. When I go to fieldtrip/utilites/private in matlab79 and type state=randomseed([]), I get the same error as with ICA: ??? Undefined variable "RandStream" or class "RandStream.getDefaultStream". Error in ==> randomseed at 41 stream = RandStream.getDefaultStream; When I do it with matlab76, I get a bunch of numbers.


Robert Oostenveld - 2013-04-26 12:05:44 +0200

I did the following on matlab2012b on torque and with that I am NOT able to reproduce the error. Could you please try this as well and see whether the error persists? restoredefaultpath clear all addpath /home/common/matlab/fieldtrip ft_defaults cfg = []; cfg.dataset = '/home/common/matlab/fieldtrip/data/Subject01.ds'; % cfg.dataset = dccnfilename('/home/common/matlab/fieldtrip/data/Subject01.ds'); data = ft_preprocessing(cfg); cfg = []; cfg.detrend = 'no'; cfg.resamplefs = 150; data = ft_resampledata(cfg, data); cfg = []; cfg.channel = {'MEG'}; cfg.numcomponent = 60; comp = ft_componentanalysis(cfg, data);


Robert Oostenveld - 2013-04-26 12:10:00 +0200

(In reply to comment #2) I am also not able to replicate the low-level problem on matlab 79/2009b on torque: >> restoredefaultpath >> cd /home/common/matlab/fieldtrip/utilities/private/ >> ver ------------------------------------------------------------------------------------- MATLAB Version 7.9.0.529 (R2009b) MATLAB License Number: 38957 Operating System: Linux 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 Java VM Version: Java 1.6.0_12-b04 with Sun Microsystems Inc. Java HotSpot(TM) 64-Bit Server VM mixed mode ------------------------------------------------------------------------------------- MATLAB Version 7.9 (R2009b) ... >> randomseed(1) ans = 1 1812433254 3713160357 3109174145 64984499 ...


Ana Todorovic - 2013-04-26 12:25:48 +0200

(In reply to comment #4) Restoring the default path helped! Thanks so much to both of you. I have no idea why my path wasn't what it should be, I barely ever used the matlabs above 76.


Johanna - 2013-04-26 13:18:57 +0200

Hi Ana, I mark this as resolved. ('Invalid' since it wasn't actually a bug in the code, but something in your path). Feel free to re-open if still a problem.


Robert Oostenveld - 2019-08-10 12:03:55 +0200

This closes a whole series of bugs that have been resolved (either FIXED/WONTFIX/INVALID) for quite some time. If you disagree, please file a new issue describing the issue on https://github.com/fieldtrip/fieldtrip/issues.