SPM/Octave
From Wikibooks, open books for an open world
< SPM
GNU Octave [edit]
GNU Octave is a high-level language that is mostly compatible with MATLAB. It is free open source software under the terms of the GNU General Public License.
Octave [edit]
- Octave website: http://www.gnu.org/software/octave/
- Octave project: http://hg.savannah.gnu.org/hgweb/octave/
- Octave Help mailing list: https://mailman.cae.wisc.edu/listinfo/help-octave
- Octave Maintainers mailing list: https://mailman.cae.wisc.edu/listinfo/octave-maintainers
- Octave bug tracker: http://savannah.gnu.org/bugs/?group=octave
- Octave-Forge: http://octave.sourceforge.net/
MATLAB/Octave compatibility [edit]
GNU Octave is mostly compatible with MATLAB:
- http://wiki.octave.org/Compatibility
- http://wiki.octave.org/FAQ#Porting_programs_from_Matlab_to_Octave
- http://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB
- http://homepages.inf.ed.ac.uk/imurray2/compnotes/octave_matlab.html
Compatibility status from other neuroimaging MATLAB packages:
- EEGLAB: http://sccn.ucsd.edu/wiki/EEGLAB_and_Octave
- FieldTrip: http://fieldtrip.fcdonders.nl/faq/can_i_use_octave_instead_of_matlab
- Psychtoolbox: http://psychtoolbox.org/
Current status for SPM/Octave compatibility [edit]
Please contact fil.spm@ucl.ac.uk if you are interested.
You need to use latest version of SPM8 (r5236) and GNU Octave (3.6).
For compilation of the MEX files for Octave, run the following:
cd /home/login/spm8/src make distclean PLATFORM=octave make PLATFORM=octave && make install PLATFORM=octave make toolbox-distclean PLATFORM=octave make toolbox PLATFORM=octave && make toolbox-install PLATFORM=octave
How to contribute [edit]
You can contribute to improve the support of SPM on GNU Octave in several ways:
- Report bugs: using the development version of Octave, report problems you encounter when using SPM to SPM or Octave developers. Make sure to only report a bug in Octave when it's something that should not be fixed in SPM instead. Try to isolate the problem as much as possible.
- Propose patches in Octave for bugs from the list below that have not been fixed yet.
- Contribute financially to the Octave community.
Compatibility issues observed so far in SPM with Octave [edit]
Requires changes in SPM [edit]
- Compilation of MEX files: use "mkoctfile --mex" and the MEX-file extension is ".mex" on all platforms.
- It is not possible to create a function handle with a function name that does not exist (eg, x = @sdlkjfhg fails, see this).
- do is a reserved keyword in Octave (for a do-until loop) so cannot be used as variable name.
- disp should be called instead of display for standard variables (in OO programming).
- builtin('display',obj) does not work on user-defined objects (MATLAB returns 'classname object: x-by-y', i.e. it calls disp.m).
- class can only be called from the class constructor (and not in any other method function) (class(obj,'myclass') => myclass(obj)).
- The short-circuit && and || operators should be used in if statements, instead of binary operators & and |. This is reported by MLINT.
- MEX files should include "mex.h" but not "matrix.h", see this
- cd does not return current directory in Octave (unlikely to change, see this thread). Call pwd beforehand instead.
- Line continuation "..." does not ignore anything that appears after it, unless there is a comment sign % (MATLAB does).
Requires changes in Octave [edit]
strrep.m works on strings but not cell arraysfixedisdeployed.m does not exist (function X=isdeployed, X=false;)fixedtextscan.m, strread.m and textread.m do not exist (in 3.2.4; available in devel, see this and this). Note that in MATLAB, textscan should be preferred and replace strread and textread. The devel function crashes on textscan('aaa.bbb','%s','delimiter','.')fixedA subfunction of a private class method does not access fields directly (i.e. it's a step further from this) and calls subsref/subsasgn instead.fixed- which.m does not support the -ALL option (see this). in progress
trailing filesep in addpath/rmpathfixeda='a';b={};c=cellfun(@(x)strcmp(a,x),b); crashes with Octave (devel, not 3.2.4) while MATLAB returns c=[].fixedSame error with b=get(findobj(0,'Tag','xxx'),'a') which should return [], i.e. problem with functions that return empty output.fixedsave.m (and perhaps load.m) have trouble with MATLAB binary MAT-format(when some variables are not double precision (e.g. clear a;a.field1=single(1);save a.mat a -v6;load a.mat crashes on Octave dev ("error: load: invalid element type = 0")fixed). fixed- dialog, errordlg, helpdlg, inputdlg, listdlg, msgbox, warndlg do not exist in Octave.
gco.m now exists in Octave but creates a figure if none exists.fixed.- fcnchk.m does not exist in Octave (can usually be replaced by str2func.m)
isequal.m does not work with objects (error: find: wrong type argument `class', __isequal__.m at line 147).fixedlogm(eye(3)) crashes, MATLAB returns zeros(3).fixedlogm sometimes returns complex numbers.fixedmat2str fails on logical inputsfixed- Several problems with hierarchical classes. fixed, fixed, fixed, fixed, fixed, fixed, in progress
Assignment error with non-preallocated sparse matrices (clear a; a(1,:)=sparse(1,3,1,1,3); returns A(I,J,...) = X: dimensions mismatch.fixedtic/toc do not handle input/output arguments as in MATLAB (tStart=tic; any_statements; tElapsed=toc(tStart);).fixed- str2num(',1,1') returns [1 1] in MATLAB and [] in Octave, won't fix
Objects not converted as structure when loaded from a MAT-file if class definition is not in path.fixedAccessing graphics object properties from an empty handle displays obscure warning (get([],'x')).fixednargchk(1,1,1,'struct') returns a 1x1 struct with no fields in Octave and a 0x1 struct with fields message and identifier in MATLAB.fixed- [[];{'a'}] returns {[];'a'} instead of {'a'}, in progress
Empty struct struct([]) not preserved when saved in a MAT-file.fixedProblem in regexprep with backslash escape character.fixedSegmentation fault with [B,C]=chol(-speye(3))fixedmwSignedIndex is not defined => typedef int mwSignedIndex;fixedcell arrays of cell arrays as saved by matlabbatch are not parsed properly with Octave.fixed- mkoctfile does not recognize argument -outdir.
- desktop function does not exist, particularly useful for calls desktop('-inuse'). in progress
Compilation with SuiteSparse 3.2 fails.fixedundefined symbol: mexCallMATLAB.fixedW specifier in fopen does not work.fixed- io64.h is not defined.
Undecided yet [edit]
- mkoctfile's option to define output file name is "-o" or "--output" while mex's option is "-output". If used, no file extension ('.mex') is appended.
- MEX object files "*.o" are not automatically deleted after compilation (they are with MATLAB's mex).
- computer.m returns different strings than on MATLAB (PCWIN, GLNX86, PCWIN64, GLNXA64, MACI64), e.g. x86_64-unknown-linux-gnu.
- load.m and save.m automatically add a .mat file extension if not provided with MATLAB (Octave doesn't).
- Octave buffers output, which can be blocking. fflush(stdout) or page_screen_output has to be used.
Miscellaneous [edit]
- exist('OCTAVE_VERSION','builtin') can be used to detect if running in Octave or MATLAB.