AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
April 18, 2022 04:48PM
Thanks for the quick reply.

Other AFNI scripts work. I run the following code to make sure AFNI and MATLAB are working together:
setenv('DYLD_FALLBACK_LIBRARY_PATH',[ '/Users/conradbn/abin:' getenv('DYLD_FALLBACK_LIBRARY_PATH') ])

% is the path to AFNI already set?
[afninotfound, unixoutput] = unix('3dcopy');
% if not, then we will look for it...
if afninotfound
    % is AFNI in /abin?
    [afninotfound, unixoutput] = unix('/abin/3dcopy');
    if ~afninotfound % found it!
        setenv('PATH', [getenv('PATH') ':/abin']);
        disp(sprintf('Adding /abin to Matlab''s path (for AFNI).'));
    end
end
if afninotfound
    % is AFNI in ~/abin?
    [afninotfound, unixoutput] = unix('~/abin/3dcopy');
    if ~afninotfound % found it!
        current_directory = pwd;
        eval('cd ~');
        afni_directory = [pwd '/abin'];
        setenv('PATH', [getenv('PATH') ':' afni_directory]);
        disp(sprintf(['Adding ' afni_directory ' to Matlab''s path (for AFNI).']));
        eval(['cd ' current_directory]);
        clear current_directory afni_directory;
    end
end
if afninotfound
    % is AFNI in ~/Documents/abin?
    [afninotfound, unixoutput] = unix('~/Documents/abin/3dcopy');
    if ~afninotfound % found it!
        current_directory = pwd;
        eval('cd ~');
        afni_directory = [pwd '/Documents/abin'];
        setenv('PATH', [getenv('PATH') ':' afni_directory]);
        disp(sprintf(['Adding ' afni_directory ' to Matlab''s path (for AFNI).']));
        eval(['cd ' current_directory]);
        clear current_directory afni_directory;
    end
end
if afninotfound
    % if AFNI is not in /abin nor ~/abin, then the user will have to add
    % the correct path to AFNI before this function will work.
    disp(sprintf('*****'));
    disp(sprintf('The required AFNI functions cannot be found.'));
    disp(sprintf('AFNI needs to be added to Matlab''s path.'));
    disp(sprintf('You can do this with the following command:'));
    disp(sprintf(' '));
    disp(sprintf('   setenv(''PATH'', [getenv(''PATH'') '':/abin'']);'));
    disp(sprintf(' '));
    disp(sprintf('where (as an example) ''/abin'' is the AFNI directory.'));
    disp(sprintf('Exiting...'));
    disp(sprintf('*****'));
    return;
end
clear afninotfound unixoutput;


To answer your questions:
The unix env is in zsh.

>> unix(['echo $0'])
/bin/zsh

ans =

     0

However, python is not recognized. This is interested because other versions of Matlab have worked.

>> unix(['which python'])
python not found

ans =

     1

>> unix(['python -V'])
zsh:1: command not found: python

ans =

   127

>> unix(['/usr/bin/env python -V'])
env: python: No such file or directory

ans =

   127


I've run these on a different computer with MATLAB 2019a and I get the expected returns that are provided from terminal.

I suspect I need to add a few lines of code to my start up script above to map python to the unix/system env in MATLAB?
Subject Author Posted

calling afni python scrips through MATLAB

aclynn11 April 18, 2022 03:31PM

Re: calling afni python scrips through MATLAB

ptaylor April 18, 2022 04:16PM

Re: calling afni python scrips through MATLAB

Daniel Glen April 18, 2022 04:24PM

Re: calling afni python scrips through MATLAB

aclynn11 April 18, 2022 04:48PM

Re: calling afni python scrips through MATLAB

ptaylor April 18, 2022 05:01PM

Re: calling afni python scrips through MATLAB

aclynn11 April 18, 2022 05:04PM

Re: calling afni python scrips through MATLAB

ptaylor April 18, 2022 05:16PM

Re: calling afni python scrips through MATLAB

aclynn11 April 18, 2022 05:08PM

Re: calling afni python scrips through MATLAB

ptaylor April 18, 2022 05:17PM