SPM/Octave
The SPM Wikibooks moved to https://www.fil.ion.ucl.ac.uk/spm/docs/ |
GNU Octave
editGNU 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: https://octave.org/
- Octave project: http://hg.savannah.gnu.org/hgweb/octave/
- Octave Help mailing list: https://lists.gnu.org/mailman/listinfo/help-octave
- Octave Maintainers mailing list: https://lists.gnu.org/mailman/listinfo/octave-maintainers
- Octave bug tracker: http://savannah.gnu.org/bugs/?group=octave
- Octave GitHub: https://github.com/gnu-octave
- Octave-Forge: http://octave.sourceforge.net/
- GNU Octave and reproducible research by John W. Eaton
MATLAB/Octave compatibility
editGNU Octave is mostly compatible with MATLAB:
- http://wiki.octave.org/FAQ#Differences_between_Octave_and_Matlab
- https://en.wikibooks.org/wiki/MATLAB_Programming/Differences_between_Octave_and_MATLAB
- http://wiki.octave.org/Compatibility
Compatibility status from other neuroimaging MATLAB packages:
Current status for SPM/Octave compatibility
editSPM is currently not officially supported under Octave but many modules are effectively compatible. Feedbacks about further evaluation and validation are very welcome. In most situations, the standalone version of SPM might be a sufficient alternative.
Feel free to contact fil.spm@ucl.ac.uk if this is something you are interested in. You need to use the latest versions of SPM12 and GNU Octave (7.3).
Compilation
editFor compilation of the MEX files for Octave, run the following:
cd /home/login/spm12/src make PLATFORM=octave make PLATFORM=octave install
An all-in-one Octave script to download, configure and install SPM in the current directory is as follow (to be typed at the Octave prompt):
%% Store current working directory cwd = pwd; %% Download SPM12 r7771 unzip ("https://github.com/spm/spm12/archive/r7771.zip", cwd); %% Patch SPM12 urlwrite ("https://raw.githubusercontent.com/spm/spm-octave/main/spm12_r7771.patch", "spm12_r7771.patch"); system ("patch -p3 -d spm12-r7771 < spm12_r7771.patch"); %% Compile MEX files cd (fullfile (cwd, "spm12-r7771", "src")); system ("make PLATFORM=octave"); system ("make PLATFORM=octave install"); %% Add SPM12 to the function search path addpath (fullfile (cwd, "spm12-r7771")); cd (cwd); %% Start SPM12 spm
How to contribute
editYou 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 between SPM and Octave
editRequires changes in SPM
edit- Compilation of MEX files: use "mkoctfile --mex" and the MEX-file extension is ".mex" on all platforms.
- 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.
Requires changes in Octave
editIt is not possible to create a function handle with a function name that does not exist (eg, x = @crash fails).fixedLine continuation "..." does not ignore anything that appears after it, unless there is a comment sign % (MATLAB does).fixedstrrep.m works on strings but not cell arrays.fixedisdeployed.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). fixeddialog, 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 inputs.fixed- 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);).fixedstr2num(',1,1') returns [1 1] in MATLAB and [] in Octave.fixedObjects 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')).fixedCompatibility: save with empty variable names.fixedTest on fileparts input argument.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'}, won't fix
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. in progress
desktop function does not exist, particularly useful for calls desktop('-inuse').fixedCompilation with SuiteSparse 3.2 fails.fixedundefined symbol: mexCallMATLAB.fixedSegmentation fault with clf.m test.fixedW specifier in fopen does not work.fixedParser oddity with if statements.fixedProblem with mxArray in MEX files.fixedParse error with local functions in classdef files.fixedind2rgb does not handle float inputs in the same way than MATLAB.fixedInvalid conversion from string to real scalar with %c., fixedCompilation error yylex was not declared in this scope., fixedCompilation failure due to openGL.fixed-depth argument in findobj., fixedevalc is not defined.fixed- io64.h is not defined, in progress.
- save function handle variables in MATLAB's binary data format, in progress
Support of close all force., fixedwarning in findobj when using regexp., fixedPrinting a figure not containing axes.fixedError following an error in a callback of a uimenu.fixedSelectionType open for double-click non available (Qt-only).fixed- hgload can't open MATLAB figures, in progress
- Difference with figure/uicontrol between Octave and MATLAB, in progress
- Segmentation fault when loading a MAT-file containing a function_handle to a subfunction, in progress
Behaviour of figure property ToolBar when set to auto.fixedProperties of a popupmenu uicontrol.fixedCallback execution of an edit uicontrol.fixed- Mouse interaction with image objects don't work in fltk toolkit, in progress
Property value of checkbox uicontrol.fixed- Changing the style of a uicontrol after creation, in progress
- Display of popupmenu uicontrol (Qt) in progress
- Mouse click callbacks of a listbox uicontrol, in progress
Interpretation of cell array in String property of a text uicontrol.fixedIncorrect output in textscan/strread with trailing delimiter.fixedFailure to exit when running Octave in --no-gui mode.fixedFreeze with drawnow.fixedPrint options: -noui, -painters, -opengl.fixed- Reset submenus of a uicontextmenu, in progress
- Legend object printed below lines in plot, in progress
Order of uimenus.fixedCreateMode argument for msgbox/errordlg/warndlg.fixedError no method for 'scalar struct = scalar'.fixed- Print does not preserve multiline text and TeX markup, in progress
Removing a context menu.fixedCase-sensitive listdlg's SelectionMode values.fixed- Image display in a 3D view, in progress
Issues with copy to clipboard.fixed- Error base_graphics_object::get_properties: invalid graphics object, in progress
Visible property of a uicontextmenu.fixedmake attempts to build libgui even with --disable-gui.fixedfunction localfunctions not implemented.fixed- function import not implemented, in progress
- Access to object arrays, in progress
- Loading a function handle from a MAT-file, in progress
Segmentation fault with missing warning state "all".fixedcorrcoef is missing.fixedThird output of uiputfile undefined when user presses Cancel.fixedMEX object files "*.o" are not automatically deleted after compilation (they are with MATLAB's mex).fixedOctave buffers output, which can be blocking. fflush(stdout) or page_screen_output has to be used.pager disabled by default in 4.4/usr/X11R6/lib/libGL.so: could not read symbols on Suse 64 bits.fixedCHOLMOD_NOT_POSDEF was not declared in this scope.fixedsortrows/sort: only cell arrays of character strings may be sorted error.fixed- Error in concatenation of classdef objects, in progress
Restore window button does not trigger a repaint event for its content.fixedginput doesn't correctly process shift/ctlr/alt key combinations.fixed- GUI Command Window could support syntax highlight, in progress
Ctrl+C doesn't interrupt and causes SIGABRT at exit.fixedmxCreateNumericArray with zero size.fixedBuild error with mx-cdm-dm.cc.fixedlinspace() incompatibility with Matlab when N < 2.fixedMake display of coordinates in figure's status bar optional.fixedCrash when uicontrol's callback returns an error.fixedRefresh when using waitfor.fixedButtonDownFcn callback of an image.fixedrun behaves differently from Matlab on function m-files.fixeddoc build fails with texi2dvi/texi2pdf errors on Ubuntu 14.04.fixedFigure handle input argument for close(...,'force').fixed"parse error" error message in GUI callbacks.fixeddelete(allchild(fig)) in a "deletefcn" callback raises error.fixedmissing getframe function.fixedSpecial characters in uicontrol's string.fixedprefdir should not be a private function.fixedHelp menu of Qt figures.fixedDetection of Qscintilla libraries.fixed- Root graphics property "MonitorPositions" not fully implemented, in progress
Default settings with uicontrols.fixedSegmentation fault with Qt figures.fixed- uicontrols extent is incorrect, in progress
mexCallMATLABWithTrap not implemented.fixedmxSetDimensions for cell arrays.fixedrealpow: produced complex result.fixed- Cannot set breakpoints in subfunctions from GUI editor when not using "endfunction" keyword, in progress
- Missing MEX function mxArrayToUTF8String, in progress
- Backgroundcolor ignored for pushbutton and radiobutton, in progress
Using exit() in batch mode throws octave::exit_exception.fixedDisplay of images for axes partially outside a figure.fixeduicontrol popupmenu sizing.fixedImplementation of containers.Map.fixedError in the unwind_protect_cleanup section of print.m.fixed- strmatch, incompatible result on 'empty' input, in progress
- Patch with zero area not displayed with OpenGL, in progress
questdlg displays buttons in reverse order.fixedwaitfor should silently accept an empty graphics handle.fixedSegmentation fault after a caught error in an Octave script.fixedNon-empty ouput for non-matching regexp with 'names' option.fixedInvalid FID and fopen(FID).fixed- Matlab eval function accepts a column vector string input, in progress
__have_gnuplot__ does not return anything.fixed- uimenu 's position is sometimes 0, in progress
- rotate3d compatibility with Matlab, in progress
Output of uicontrol.fixedisequalwithequalnans is missing.fixedfwrite input argument type.fixedset() is case-sensitive.fixedUpdate list of missing functions.fixed- sum, cumsum, etc. mishandle integer inputs, in progress
Error using print and the append flag.fixed- ${cmd} replacement operator in regexprep, in progress
Position of uimenu.fixedLoading of figures (and other objects) from Octave IDE.fixedorderfields is slow.fixedUndefined input to a classdef method.fixed- zeros: like keyword, in progress
- textscan option MultipleDelimsAsOne does not apply to space or tab characters, in progress
ismember fails if the string ends in a space.fixedInfinite loop in normest1.fixedpinv(0) different from Matlab.fixedcenter() relies on broadcasting.fixedprivate function in classdef file.fixed- max_recursion_depth error in classdef constructor, in progress
isequal is slow.fixed- display of multidimensional arrays uses 'ans', in progress
- strcmp with multidimensional char arrays, in progress
- Implementation of class categorical, in progress
- Support for "import" keyword, in progress
modal windowstyle property not working.fixedMissing keyword help for classdef keywords.fixedmakeValidName and makeUniqueStrings.fixedPDF user manual uses a backward apostrophe ` in code examples.fixed- Implementation of histcounts, in progress
- Implement jsondecode, jsonencode functions, in progress
- Figure property IntegerHandle does not work fully with Qt toolkit, in progress
"Number" property for figure.fixedImplementation of movegui.fixedImplementation of savefig.fixed- Octave 4.3.0+ can't load figures saved with previous versions, in progress
Unknown command `codequoteundirected' in help text.fixedwarning message when qcollectiongenerator and qhelpgenerator are not found.fixedSyntax of documentation with texinfo 4.13.fixedSegmentation fault when executing a script containing a figure.fixedwarning from opengl_renderer about light object.fixeduicontrol/uibuttongroup: focusing not implemented yet.fixed- octave deadlocks with deletefcn callback that calls graphical function, in progress
doc: some default Qt properties are different between systems.fixedMEX file in a private directory of a class.fixedismember error with mixed numeric and char arrays inputs.fixedError with whos -file: 'load' not found.fixed- Behavior of open with unknown or non-existing files, in progress
Colors of a uicontrol pushbutton.fixeduipanel doesnt show border in linux.fixedcamlight (axis_handle, ...) should work for Matlab Compatibility.fixedImplementation of isfolder.fixed- Private directory in +package, in progress
Figure's Position when MenuBar is none.fixed- load() should issue an error if specified variable does not exist in file, in progress
- subsasgn call when the subscripted expression contains the end keyword, in progress
- Implementation of memmapfile, in progress
- File browser unresponsive, in progress
uicontrol: validation of cdata property.fixedsavefig should accept a vector of figure handles for Matlab compatibility.fixedcolormap property of a figure cannot be empty.fixed- Interpreter cannot find methods in files of classdefs in packages, in progress
Implement uicontrol focusing behavior.fixedUse of camlight when a patch is not visible.fixed- Removal of called_from_builtin, in progress
Property VertexNormals not updated.fixedgunzip/bunzip2 error with cell array of strings input.fixedDOCSTRING macro does not recognize matlab.lang.makeValidName.fixedChange of a togglebutton uicontrol's value not reflected graphically.fixed- Global variable in a MEX file, in progress
warning: popupmenu value not within valid display range.fixed- Speed issue with uicontrols, in progress
gcbf and HandleVisibility property.fixedAdd support for more types for image's cdata.fixed- Binary input image for edge, in progress
- colorbar properties need listeners to invoke actions, in progress
Implementation of lightangle.fixed[MXE Octave] lib vs lib64.fixed- Path management in the GUI, in progress
isosurface is slow.fixedImage not displayed with YDir set to normal.fixed- Conflict between package namespace and function name, in progress
- subsref called in a subscripted assignment operation, in progress
- statistical CDF functions lack upper argument support, in progress
- Closing plots much slower in Octave 5.1.0, in progress
- dbup and dbdown not working as expected, in progress
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.
- 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).
Miscellaneous
edit- exist('OCTAVE_VERSION','builtin') can be used to detect if running in Octave or MATLAB.