Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spm12 cannot find matlab #2939

Closed
barbrakr opened this issue May 31, 2019 · 5 comments
Closed

spm12 cannot find matlab #2939

barbrakr opened this issue May 31, 2019 · 5 comments

Comments

@barbrakr
Copy link

barbrakr commented May 31, 2019

Summary

I've been working my way through these suggestions #2436 "Matlab command cannot be found" and the related fix] and found that I have the proper base.py with the changes mentioned there.

Actual behavior when running from python3

smooth.run()
Traceback (most recent call last):
File "", line 1, in
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 375, in run
runtime = self._run_interface(runtime)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype/interfaces/spm/base.py", line 376, in _run_interface
results = self.mlab.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 375, in run
runtime = self._run_interface(runtime)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype/interfaces/matlab.py", line 162, in _run_interface
runtime = super(MatlabCommand, self)._run_interface(runtime)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype/interfaces/base/core.py", line 749, in _run_interface
runtime.hostname))
OSError: No command "matlab" found on host .local. Please check that the corresponding package is installed.

Expected behavior

That it will run the smoothing SPM12 algorithm smoothly.

How to replicate the behavior

every time I follow the instructions:
from nipype.interfaces.spm import Smooth smooth = Smooth() smooth.inputs.in_files = 'functional.nii' smooth.inputs.fwhm = 6 smooth.run()

Platform details:

python3  -c "import nipype; from pprint import pprint; pprint(nipype.get_info())"
{'commit_hash': '%h',
 'commit_source': 'archive substitution',
 'networkx_version': '2.3',
 'nibabel_version': '2.3.1',
 'nipype_version': '1.2.1-dev',
 'numpy_version': '1.15.4',
 'pkg_path': '/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/nipype',
 'scipy_version': '1.1.0',
 'sys_executable': '/Library/Frameworks/Python.framework/Versions/3.7/bin/python3',
 'sys_platform': 'darwin',
 'sys_version': '3.7.0 (v3.7.0:1bf9cc5093, Jun 26 2018, 23:26:24) \n'
                '[Clang 6.0 (clang-600.0.57)]',
 'traits_version': '5.1.1'}
@barbrakr
Copy link
Author

barbrakr commented Jun 3, 2019

Dear all, please let me know if you've got any suggestions for this please - I'm on 10.14.3 Mojave on a MacBook Pro.

@satra
Copy link
Member

satra commented Jun 3, 2019

@barbrakr - there may be a few issues related to this.

  1. can you launch matlab from the terminal?

nipype assumes (for most part) that commands you call from nipype are accessible to the terminal you ran nipype from.

  1. on unix systems, which os x is, everything that executes is controlled through the PATH environment variable. if you are unfamiliar with the shell, this intro and exercises may be useful to you: http://www.repronim.org/module-reproducible-basics/01-shell-basics/

  2. once you are comfortable with the above, you may want to consider using conda to install and work on python. the system python works fine, but conda will give you a bit more flexibility in the longer run, especially moving between machines that are not similar.

hope that helps.

@barbrakr
Copy link
Author

barbrakr commented Jun 3, 2019

Thank you @satra !

  1. Yes, I can do that - I realised I had to restart the terminal!!
  2. Yes, my path variable is set.
  3. Will Anaconda do a similar thing as Conda?

I have been trying to solve this error now for some time - apparently matlab cannot find SPM on the path. Couldn't really solve it with what I found online - would you have clue for me?

Standard error:
MATLAB code threw an exception:
SPM not in matlab path
File:/Users/NEURO-222/pyscript_smooth.m
Name:pyscript_smooth
Line:6
Return code: 0

@satra
Copy link
Member

satra commented Jun 3, 2019

in nipype you can always specify the spm path (actually recommended). take a look at this answer:

https://neurostars.org/t/error-running-spm-realign-node/1019/2

@barbrakr
Copy link
Author

barbrakr commented Jun 3, 2019

Awesome stuff - this finally worked - thanks a bunch!!

export SPM_PATH=/Users/NEURO-222/Documents/MATLAB/spm12

python3

from nipype.interfaces import spm; import os; spm.SPMCommand.set_mlab_paths(paths=os.environ['SPM_PATH'])

from nipype.interfaces.spm import Smooth ; smooth = Smooth(); smooth.inputs.fwhm = 6; smooth.inputs.in_files = '/Users/NEURO-222/Downloads/IGE002/2Dto3D_IGE02.nii' ; smooth.run()

<nipype.interfaces.base.support.InterfaceResult object at 0x1111969e8>

@effigies effigies closed this as completed Jun 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants