# SPM/Octave

## 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://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-Forge: http://octave.sourceforge.net/
- GNU Octave and reproducible research by John W. Eaton

### 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]

SPM is **not** supported under Octave and there is a number of known issues (especially regarding the graphical user interface) but feel free to contact fil.spm@ucl.ac.uk if you are interested. In most situations, the standalone version of SPM might be a sufficient alternative.

You need to use latest version of SPM12 and GNU Octave (4.4.1).

For compilation of the MEX files for Octave, run the following:

cd /home/login/spm12/src make distclean PLATFORM=octave make PLATFORM=octave && make 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.

### Requires changes in Octave[edit]

~~Line continuation "~~fixed**...**" does not ignore anything that appears after it, unless there is a comment sign**%**(MATLAB does).fixed**strrep.m**works on strings but not cell arrays.fixed**isdeployed.m**does not exist (function X=isdeployed, X=false;).fixed**textscan.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','.')*~~A 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~~fixed**filesep**in**addpath**/**rmpath**fixed*a='a';b={};c=*crashes with Octave (devel, not 3.2.4) while MATLAB returns c=[].**cellfun**(@(x)strcmp(a,x),b);~~Same error with~~fixed*b=*which should return [], i.e. problem with functions that return empty output.**get**(findobj(0,'Tag','xxx'),'a')(**save.m**(and perhaps**load.m**) have trouble with MATLAB binary MAT-format.~~when some variables are not double precision (e.g.~~fixed). fixed*clear a;a.field1=single(1);save a.mat a -v6;load a.mat*crashes on Octave dev ("error: load: invalid element type = 0")**dialog, errordlg, helpdlg, inputdlg, listdlg, msgbox, warndlg**do not exist in Octave.fixed.**gco.m**now exists in Octave but creates a figure if none exists.**fcnchk.m**does not exist in Octave (can usually be replaced by**str2func.m**)fixed**isequal.m**does not work with objects (*error: find: wrong type argument `class', __isequal__.m at line 147*).fixed**logm**(eye(3)) crashes, MATLAB returns zeros(3).fixed**logm**sometimes returns complex numbers.fixed**mat2str**fails on logical inputs.- Several problems with hierarchical
**classes**. fixed, fixed, fixed, fixed, fixed, fixed, in progress ~~Assignment error with non-preallocated~~fixed**sparse**matrices (*clear a; a(1,:)=sparse(1,3,1,1,3);*returns*A(I,J,...) = X: dimensions mismatch*.fixed**tic/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.~~Objects not converted as structure when loaded from a~~fixed**MAT-file**if class definition is not in path.~~Accessing graphics~~fixed**object properties**from an empty handle displays obscure warning (*get([],'x')*).~~Compatibility:~~fixed**save**with empty variable names.~~Test on~~fixed**fileparts**input argument.fixed**nargchk**(1,1,1,'struct') returns a 1x1 struct with no fields in Octave and a 0x1 struct with fields*message*and*identifier*in MATLAB.returns**[[];{'a'}]***{[];'a'}*instead of*{'a'}*, won't fix~~Empty struct~~fixed**struct([])**not preserved when saved in a MAT-file.~~Problem in~~fixed**regexprep**with**backslash**escape character.~~Segmentation fault with [B,C]=~~fixed**chol**(-speye(3)).fixed**mwSignedIndex**is not defined => typedef int mwSignedIndex;fixed**cell arrays of cell arrays**as saved by matlabbatch are not parsed properly with Octave.**mkoctfile**does not recognize argument**-outdir**.fixed**desktop**function does not exist, particularly useful for calls**desktop('-inuse')**.~~Compilation with~~fixed**SuiteSparse 3.2**fails.~~undefined symbol:~~fixed**mexCallMATLAB**.~~Segmentation fault with~~fixed**clf.m**test.fixed**W**specifier in fopen does not work.~~Parser oddity with~~fixed**if**statements.~~Problem with~~fixed**mxArray**in MEX files.~~Parse error with~~fixed**local functions**in classdef files.fixed**ind2rgb**does not handle float inputs in the same way than MATLAB.~~Invalid conversion from string to real scalar with~~, fixed**%c**.~~Compilation error~~, fixed**yylex**was not declared in this scope.~~Compilation failure due to~~fixed**openGL**., fixed**-depth**argument in**findobj**.fixed**evalc**is not defined.**io64.h**is not defined, in progress.- save
**function handle**variables in MATLAB's binary data format, in progress ~~Support of~~, fixed**close all force**.~~warning in~~, fixed**findobj**when using regexp.~~Printing a figure not containing axes.~~fixed~~Error following an error in a~~fixed**callback**of a uimenu.~~SelectionType~~fixed**open**for double-click non available (Qt-only).- 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~~fixed**ToolBar**when set to**auto**.~~Properties of a~~fixed**popupmenu**uicontrol.~~Callback execution of an~~fixed**edit**uicontrol.- Mouse interaction with image objects don't work in fltk toolkit, in progress
~~Property~~fixed**value**of**checkbox**uicontrol.- 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~~fixed**String**property of a**text**uicontrol.~~Incorrect output in~~fixed**textscan/strread**with trailing delimiter.~~Failure to exit when running Octave in~~fixed**--no-gui**mode.~~Freeze with~~fixed**drawnow**.~~Print options:~~fixed**-noui, -painters, -opengl**.- Reset submenus of a
**uicontextmenu**, in progress **Legend**object printed below lines in plot, in progress~~Order of~~fixed**uimenu**s.fixed**CreateMode**argument for msgbox/errordlg/warndlg.~~Error~~fixed**no method for 'scalar struct = scalar'**- Print does not preserve
**multiline**text and TeX markup in progress ~~Removing a context menu.~~fixed~~Case-sensitive listdlg's~~fixed**SelectionMode**values.- Image display in a 3D view, in progress
~~Issues with copy to~~fixed**clipboard**.- Error
**base_graphics_object::get_properties: invalid graphics object**, in progress fixed**Visible**property of a uicontextmenu~~make attempts to build libgui even with~~fixed**--disable-gui**.~~function~~fixed**localfunctions**not implemented.- 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~~fixed**warning state "all"**.fixed**corrcoef**is missing.~~Third output of~~fixed**uiputfile**undefined when user presses Cancel.~~MEX object files "*.o" are not automatically deleted after compilation (they are with MATLAB's mex).~~fixed~~Octave buffers output, which can be blocking.~~pager disabled by default in 4.4**fflush(stdout)**or page_screen_output has to be used.~~/usr/X11R6/lib/~~fixed**libGL.so**: could not read symbols on Suse 64 bitsfixed**CHOLMOD_NOT_POSDEF**was not declared in this scopefixed**sortrows/sort**: only cell arrays of character strings may be sorted error- Error in concatenation of
**classdef**objects in progress ~~Restore window button does not trigger a~~fixed**repaint event**for its contentfixed**ginput**doesn't correctly process shift/ctlr/alt key combinations- GUI Command Window could support
**syntax highlight**in progress fixed**Ctrl+C**doesn't interrupt and causes SIGABRT at exitfixed**mxCreateNumericArray**with zero size~~Build error with~~fixed**mx-cdm-dm.cc**fixed**linspace()**incompatibility with Matlab when N < 2~~Make display of coordinates in figure's~~fixed**status bar**optional~~Crash when~~fixed**uicontrol's callback**returns an error~~Refresh when using~~fixed**waitfor**fixed**ButtonDownFcn**callback of an imagefixed**run**behaves differently from Matlab on function m-files~~doc build fails with~~fixed**texi2dvi/texi2pdf**errors on Ubuntu 14.04~~Figure handle input argument for~~fixed**close(...,'force')**~~"~~fixed**parse error**" error message in GUI callbacksfixed**delete(allchild(fig))**in a "deletefcn" callback raises error~~missing~~fixed**getframe**functionfixed**Special characters**in uicontrol's stringfixed**prefdir**should not be a private functionfixed**Help menu**of Qt figures~~Detection of~~fixed**Qscintilla**libraries- Root graphics property "
**MonitorPositions**" not fully implemented in progress ~~Default settings with~~fixed**uicontrols**~~Segmentation fault with~~fixed**Qt figures****uicontrols extent**is incorrect in progressfixed**mexCallMATLABWithTrap**not implementedfixed**mxSetDimensions**for cell arraysfixed**realpow**: produced complex result- 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~~fixed**octave::exit_exception**~~Display of images for~~fixed**axes**partially outside a figure~~uicontrol~~fixed**popupmenu**sizing~~Implementation of~~fixed**containers.Map**~~Error in the~~fixed**unwind_protect_cleanup**section of print.m**strmatch**, incompatible result on 'empty' input in progress**Patch**with zero area not displayed with OpenGL in progressfixed**questdlg**displays buttons in reverse orderfixed**waitfor**should silently accept an empty graphics handle~~Segmentation fault after a~~fixed**caught error**in an Octave script~~Non-empty ouput for non-matching~~fixed**regexp**with 'names' option~~Invalid FID and~~fixed**fopen(FID)**- Matlab
**eval**function accepts a column vector string input in progress fixed**__have_gnuplot__**does not return anything**uimenu**'s position is sometimes 0 in progress**rotate3d**compatibility with Matlab in progress~~Output of~~fixed**uicontrol**fixed**isequalwithequalnans**is missingfixed**fwrite**input argument typefixed**set()**is case-sensitive~~Update list of~~fixed**missing functions****sum, cumsum**, etc. mishandle integer inputs in progress~~Error using print and the~~fixed**append**flag- ${cmd} replacement operator in
**regexprep**in progress ~~Position of~~fixed**uimenu**fixed**Loading of figures**(and other objects) from Octave IDEfixed**orderfields**is slow~~Undefined input to a~~fixed**classdef**method- zeros:
**like**keyword in progress - textscan option
**MultipleDelimsAsOne**does not apply to space or tab characters in progress fixed**ismember**fails if the string ends in a space~~Infinite loop in~~fixed**normest1**fixed**pinv(0)**different from Matlabfixed**center()**relies on broadcastingfixed**private**function in**classdef**file**max_recursion_depth**error in classdef constructor in progressfixed**isequal**is slow- 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 fixed**modal windowstyle**property not working~~Missing keyword~~fixed**help**for classdef keywordsfixed**makeValidName**and**makeUniqueStrings**~~PDF user manual uses a~~fixed**backward apostrophe**` in code examples- Implementation of
**histcounts**in progress - Implement
**jsondecode**,**jsonencode**functions in progress - Figure property
**IntegerHandle**does not work fully with Qt toolkit in progress ~~"~~fixed**Number**" property for figure~~Implementation of~~fixed**movegui**~~Implementation of~~fixed**savefig**- Octave 4.3.0+ can't
**load**figures saved with previous versions in progress ~~Unknown command `~~fixed**codequoteundirected'**in help text~~warning message when~~fixed**qcollectiongenerator**and**qhelpgenerator**are not found~~Syntax of documentation with~~fixed**texinfo**4.13~~Segmentation fault when executing a~~fixed**script**containing a figure~~warning from~~fixed**opengl_renderer**about light object~~uicontrol/uibuttongroup:~~fixed**focusing**not implemented yet- octave deadlocks with
**deletefcn**callback that calls graphical function in progress ~~doc: some~~fixed**default Qt properties**are different between systemsfixed**MEX file**in a**private**directory of a classfixed**ismember**error with mixed numeric and char arrays inputs~~Error with~~fixed**whos -file**: 'load' not found- Behavior of
**open**with unknown or non-existing files in progress ~~Colors of a~~fixed**uicontrol pushbutton**fixed**uipanel**doesnt show border in linuxfixed**camlight**(axis_handle, ...) should work for Matlab Compatibility~~Implementation of~~fixed**isfolder****Private**directory in**+package**in progress~~Figure's Position when~~fixed**MenuBar**is none**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~~fixed**cdata**propertyfixed**savefig**should accept a vector of figure handles for Matlab compatibilityfixed**colormap**property of a figure cannot be empty- Interpreter cannot find
**methods**in files of classdefs in**packages**in progress ~~Implement uicontrol~~fixed**focusing**behavior~~Use of~~fixed**camlight**when a patch is not visible- Removal of
**called_from_builtin**in progress ~~Property~~fixed**VertexNormals**not updatedfixed**gunzip/bunzip2**error with cell array of strings input~~DOCSTRING macro does not recognize~~fixed**matlab.lang.makeValidName**~~Change of a~~fixed**togglebutton**uicontrol's value not reflected graphically**Global**variable in a**MEX**file in progress~~warning:~~fixed**popupmenu**value not within valid display range- Speed issue with uicontrols in progress
- gcbf and HandleVisibility property in progress
- Add support for more types for image's cdata in progress
- Binary input image for edge in progress
- colorbar properties need listeners to invoke actions in progress
- Implementation of lightangle 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.