env: python: No such file or directory

Dear all,

I am trying to preprocess data and receive the following problem “env: python: No such file or directory” once AFNI should apply “align_epi_anat.py” in my preprocessing script. The same problem appears when using SSwarper. From my understanding, the problem basically appears everytime AFNI has to use Python.

In this topic https://afni.nimh.nih.gov/afni/community/board/read.php?1,167735,167735#msg-167735 people reported the exact same problem.
Now an interesting fact: I used the same script on the same data before without any problem. What has changed on my system meanwhile? I think that I updated AFNI, homebrew, and the Mac OS once, while the Python version remained the same (as far as I can remember). As I see, other people suddenly face the same problem.

This means that something has changed and AFNI cannot regocnize or find Python anymore. Its like Python does no longer exist for AFNI.

The output of


afni_system_check.py -check_all

is


env: python: No such file or directory

The output of


python -V

is


Python 3.10.4

I am not running Miniconda or any compareable tool. Is there a possible fix for this problem without using extra tools, such as Miniconda? I would like to keep it plain and simple (if that makes sense to you), since it worked before like this too. I am on a Macbook M1 with version 12.3.1 Monterey.

Thanks,
Philipp

Hi, Philipp-

I don’t see why updating AFNI would change anything with your path or environment variables. Updating your OS might certainly change things, yes. Note in the link that you cite, the solution on a Mac involved using miniconda—I think that will likely be the way to go ultimately to have necessary Python modules like Matplotilb, but you should at least have plain ‘python’ on your system.

What is the output of A):


which python

B)


\ls -l `which python`

C)


/usr/bin/env python -V

D)


echo $PATH

E)


echo $0

–pt

Hi Paul,

I am happy to see you here and helping me out. I am really sad to be stuck again. :frowning:
Here are the outputs of the codes that you suggested

which python


python: aliased to /usr/local/bin/python3

\ls -l which python


ls: aliased: No such file or directory
ls: python:: No such file or directory
ls: to: No such file or directory
lrwxr-xr-x  1 root  wheel  70 Apr  3 19:44 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3

/usr/bin/env python -V


env: python: No such file or directory

echo $PATH


/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/applications/AFNI/abin:/Library/Frameworks/R.framework/Versions/3.6/Resources/bin

echo $0


-zsh

Paul,

I realized that Python 2.x is not installed on the system anymore. I was a bit shocked to see this, since it was the system’s default. A quick google search provided me with the information that Apple indeed removed Python 2.7.x with one of their latest OS updates (that I installed).

Probably this is the reason why AFNI now fails everytime it needs Python (even though I ran my terminal/shell using Python 3.x before). But who knows if AFNI “internally” still used Python 2.7x for some AFNI programs.

Maybe this is the problem; not just for me, but for the other users too. This seems reasonable because the other topic with the problem we are talking about appeared in the time Python 2.7 was removed from Mac OS.

I don’t know how to fix it though, i.e., telling AFNI to use the currently installed version of Python.

If I recall from the previous email thread about this, you set up an alias referencing your specific Python version, 3.10, with (**edited, with correct ‘ln’ vs previously typed ‘ls’):


ln -s /usr/local/bin/python3.10 /usr/local/bin/python

I wonder if your system updates have changed that, so that no longer exists, but there is a different number there.

What is the output of F)


ls /usr/local/bin/python*

… and, based on what you typed above, G)


ls -d /Library/Frameworks/Python.framework/Versions/*

?

–pt

AFNI works with both Python 2.7 and 3.—it’s just that at least one of those has to be available (and it used to be that Python 2.7 was the default to come with OSs, though now it indeed is 3.).

–pt

Here are the outputs.

ls -s /usr/local/bin/python3.10 /usr/local/bin/python


ls: /usr/local/bin/python: No such file or directory
304 /usr/local/bin/python3.10

ls /usr/local/bin/python*


/usr/local/bin/python3			/usr/local/bin/python3-intel64		/usr/local/bin/python3.10-config
/usr/local/bin/python3-config		/usr/local/bin/python3.10		/usr/local/bin/python3.10-intel64

ls -d /Library/Frameworks/Python.framework/Versions/*


/Library/Frameworks/Python.framework/Versions/3.10	/Library/Frameworks/Python.framework/Versions/Current

Paul,

I googled a bit more and found out that many people have this problem since the latest big Mac OS update when Python 2.7.16 was removed from the OS. This problem is not just related to AFNI or caused by AFNI, as you already pointed out, but the problem appears with all kinds of programs that use Python.

One solution is to simply reinstall Python 2.7.16 (the version that came with Mac OS by default). For example, one can use the following solution using homebrew: https://github.com/kamilturek/homebrew-python2
Maybe this helps out other people in here. You don’t even have to use miniconda then.

I used this solution and it everything seems to work fine again. Using the command “python -V” prints


Python 3.10.4

This means that my shell/terminal uses the current version of Python, i.e., it is linked correctlly. But it appears that AFNI internally somehow still tries to link itself with Python2, since the problem no longer appears once I additionally reinstalled Python2 on my system. As you know, I am not a professional on this topic, so this is just based on my assumption.

In case you know about an even cleaner solution (instead of using 2 parallel versions of Python on my computer), and if you have some further thoughts, please let me know.

Thanks,
Philipp

Just to chime in a little here, note that lack of python 2.7 is not the problem.
The problem is (or was, now that you have reinstalled 2.7) that while python3 is on your system, there is no actual “python” in you PATH.
The command “which python” returned an alias, which was not being applied in the scripts, or via the “env” command.

Paul’s suggestion was to create a python in the PATH via the “ln” command (not “ls” as you entered).
That seems quite reasonable, though perhaps linking to simply pyhon3 would generalize more:

ln -s /usr/local/bin/python3 /usr/local/bin/python

But since this is under homebrew, there might to be more appropriate commands, such as

brew link python

This will take more investigation…

  • rick

Hi, Philipp-

I’m glad that is sorted. I want to reiterate that nothing should be special about using either Python 2.7 or Python 3.*, from AFNI’s point of view.

I am just guessing that the issue is that your OS used to have a program or symlink called ‘python’ (which happened to be Python 2.7), and after updating, it only had ‘python3’, so any aliasing you did for ‘python’ specifically wasn’t working. You installed something called ‘python’ (which happened to be Python 2.7), and now things calling ‘python’ can work.

AFNI is not trying to link to anything separately—it is merely using what is available in the terminal, which is a combination of the system and environment variable setups.

Many AFNI scripts use csh/tcsh, while your login shell is zsh. It is possible that you have something explicitly set in ~/.tcshrc or ~/.cshrc that is pointing at ‘python’, which is the Python 2.7 you installed. If you open a new terminal, and type:


tcsh
python -V
/usr/bin/env python -V
which python

… what is output? (you can go back to your other shell by typing Ctrl+d)

Can you run “afni_system_check.py -check_all” now? What is the output?

–pt

Hi,

this is the output of afni_system_check.py -check_all:


-------------------------------- general ---------------------------------
architecture:         64bit 
system:               Darwin
release:              21.4.0
version:              Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
distribution:         12.3.1
number of CPUs:       10
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /applications/AFNI/abin/afni
afni version         : Precompiled binary macos_10.12_local: Mar 20 2022 
                     : AFNI_22.0.21 'Hadrian'
AFNI_version.txt     : AFNI_22.0.21, macos_10.12_local, Mar 20 2022
which python         : /opt/homebrew/bin/python
python version       : 2.7.18
which R              : /Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
which tcsh           : /bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/applications/AFNI/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
    python  : 1   (/opt/homebrew/Cellar/python@2/2.7.18/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
    python2 : 1   (/opt/homebrew/Cellar/python@2/2.7.18/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
    python3 : 3 
      /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
      /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/bin/python3.9
      /usr/bin/python3


testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    uber_subject.py      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : FAILURE
        
        oo Warning: 
           These packages are not installed on the computer: afex!
        

R RHOME : /Library/Frameworks/R.framework/Resources

checking for $HOME files...
    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

** failed to load module matplotlib.pyplot
-- matplotlib.pyplot is required

-- python binaries under /usr/local/bin:
    /usr/local/bin/python3 (sym link to /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10)

-------------------------------- env vars --------------------------------
PATH = /Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/applications/AFNI/abin:/Library/Frameworks/R.framework/Versions/3.6/Resources/bin

PYTHONPATH = 
R_LIBS = 
LD_LIBRARY_PATH = 
DYLD_LIBRARY_PATH = 
DYLD_FALLBACK_LIBRARY_PATH = 

------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : found TT_N27+tlrc  under /applications/AFNI/abin

------------------------------ OS specific -------------------------------
XQuartz version      : 2.8.1

which brew           : /opt/homebrew/bin/brew
brew version         : Homebrew 3.4.4

-- for PyQt4 under brew, consider running:
   brew install cartr/qt4/pyqt
++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
   -- found 'libXt' dylib files:
      /opt/X11/lib/flat_namespace/libXt.6.dylib
** env var DYLD_LIBRARY_PATH is not set to contain /opt/X11/lib/flat_namespace
   (so afni and suma may fail)

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  missing R packages (see rPkgsInstall)
*  python library matplotlib is required
   (see AFNI install docs for details)
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  OS X version might be old
*  consider setting DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace


I see that AFNI also does not find matplotlib, but matplotlib is installed. Furthermore AFNI relies on Python2, but not Python 3. I assume thats due to the wrong PATH settings and so on… How can I fix this? I tried using


ln -s /usr/local/bin/python3 /usr/local/bin/python

as suggested again by Rick, but get access denied. I think that we faced this problem some months ago when you helped me, Paul.

And this is the output of

tcsh
python -V
/usr/bin/env python -V
which python


Python 2.7.18
/usr/bin/env python -V
which python[MacBook-Pro-16:~] philipp% /usr/bin/env python -V
Python 2.7.18

I think my AFNI installation or “linking” with Python is really messed up. Please let me know what changes I should do. For example, what PATH line should I add to my .zshrc file (which is invisible in the home folder, and can be seen by pressing CMD + shift + . )? It would be cool if I can at least fix the matplotlib problem, since otherwise I won’t get QC images after preprocessing and so on.

To make things more clear, here is the content of my .zshrc file.


# Prompt design
PROMPT='%B%F{201}%n%f%b %1~ '

# auto-inserted by @update.afni.binaries :
export PATH=$PATH:/applications/AFNI/abin
export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace

# Linking R and Python
export PATH=$PATH:/Library/Frameworks/R.framework/Versions/3.6/Resources/bin
alias python=/usr/local/bin/python3

# The following lines were added by compinstall
zstyle ':completion:*' completer _complete _ignored _approximate
zstyle ':completion:*' list-colors ''
zstyle :compinstall filename '/Users/philipp/.zshrc'

autoload -Uz compinit
compinit
# End of lines added by compinstallexport PATH="/opt/homebrew/opt/python@3.10/bin:$PATH"

Hi, Philipp-

From this part of your system check output:


which python         : /opt/homebrew/bin/python
python version       : 2.7.18
...
instances of various programs found in PATH:
...
    python  : 1   (/opt/homebrew/Cellar/python@2/2.7.18/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
    python2 : 1   (/opt/homebrew/Cellar/python@2/2.7.18/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
    python3 : 3 
      /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
      /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/bin/python3.9
      /usr/bin/python3

… we see that you have multiple Python packages installed, and that the one called ‘python’ specifically points to Python 2.7. Again, AFNI is not doing something specific to point to Python 2.7. It follows what your shells tell it. Certainly in tcsh, your shell is telling it that ‘python’ means the Python 2.7 version.

I tried setting up an alias like you have on my Mac. Note that if I type:


/usr/bin/env python

… I get a Python 2.7 session, but if I type


python

… I get a Python 3.9 session. The AFNI Python scripts have the shebangs set up in the first way, which means that they see python meaning Python 2.7. They are “immune” to that alias, as it were.

Thus, aliasing ‘python’ like that won’t get you the consistent behavior you always want—not everything on the system “follows” the alias; tcsh isn’t, and the shebangs in the scripts aren’t. I think Rick’s suggestion was a good/valid/helpful one—it might just be that you had a pre-existing definition for that link reference? What are the outputs of:


# A:
\ls -l /usr/local/bin/python3 
# B:
\ls -l /usr/local/bin/python

Also, please note that since there are multiple Pythons installed, stating that “Matplotlib is installed” isn’t specific enough—which of your Pythons has it?

–pt

Hi Paul,

the output of

A:

\ls -l /usr/local/bin/python3

B:

\ls -l /usr/local/bin/python

is


zsh: command not found: #
lrwxr-xr-x  1 root  wheel  70 Apr  3 19:44 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3
zsh: command not found: #
ls: /usr/local/bin/python: No such file or directory

True, you are right about your comment regarding the version of Python and matplotlib. I have matplotlib installed under pip3.

Here is an update.

I went back to Rick’s suggestion, i.e., adding the following command to the terminal/shell in order to assign a new path.


ln -s /usr/local/bin/python3 /usr/local/bin/python

However, the OS then prints a “permission denied”. I googled a bit more and found out that there is the possibility of adding the command “sudo” just before the command that Rick suggested.


sudo ln -s /usr/local/bin/python3 /usr/local/bin/python

The shell then requries to input your admin password and will consequently execute the command. However, people said that this can crash your whole OS. So you should really know what you are doing in such cases, namely when adding the sudo command on commands that are normally blocked by the OS. My reasoning was that since Apple already removed Python 2.7 from the OS anyway, what could go wrong?

I therefore uninstalled the homebrew installation of Python 2.7 again. After a fresh restart of the system afterwards, I used the command suggested by Rick above with adding “sudo” just before it. Now here is the new output of afni_system_check.py -check_all


-------------------------------- general ---------------------------------
architecture:         64bit 
system:               Darwin
release:              21.4.0
version:              Darwin Kernel Version 21.4.0: Fri Mar 18 00:46:32 PDT 2022; root:xnu-8020.101.4~15/RELEASE_ARM64_T6000
distribution:         12.3.1
number of CPUs:       10
apparent login shell: zsh
shell RC file:        .zshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni           : /applications/AFNI/abin/afni
afni version         : Precompiled binary macos_10.12_local: Apr  4 2022 
                     : AFNI_22.1.01 'Antoninus Pius'
AFNI_version.txt     : AFNI_22.1.01, macos_10.12_local, Apr 04 2022
which python         : /usr/local/bin/python
python version       : 3.10.4
which R              : /Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R
R version            : R version 3.6.3 (2020-02-29) -- "Holding the Windsock"
which tcsh           : /bin/tcsh

instances of various programs found in PATH:
    afni    : 1   (/applications/AFNI/abin/afni)
    R       : 1   (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
    python  : 1   (/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10)
    python2 : 0 
    python3 : 3 
      /opt/homebrew/Cellar/python@3.9/3.9.12/Frameworks/Python.framework/Versions/3.9/bin/python3.9
      /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10
      /usr/bin/python3

** have python3 but not python2

testing ability to start various programs...
    afni                 : success
    suma                 : success
    3dSkullStrip         : success
    uber_subject.py      : success
    3dAllineate          : success
    3dRSFC               : success
    SurfMesh             : success
    3dClustSim           : success
    3dMVM                : success

checking for R packages...
    rPkgsInstall -pkgs ALL -check : success

R RHOME : /Library/Frameworks/R.framework/Resources

checking for $HOME files...
    .afnirc                   : found
    .sumarc                   : found
    .afni/help/all_progs.COMP : found

------------------------------ python libs -------------------------------
** failed to load module PyQt4
-- PyQt4 is no longer needed for an AFNI bootcamp

++ module loaded: matplotlib.pyplot
   module file : /Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/matplotlib/pyplot.py
   matplotlib version : 3.5.1

-- python binaries under /usr/local/bin:
    /usr/local/bin/python (sym link to /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10)
    /usr/local/bin/python3 (sym link to /Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10)

-------------------------------- env vars --------------------------------
PATH = /opt/homebrew/bin:/opt/homebrew/sbin:/Library/Frameworks/Python.framework/Versions/3.10/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/applications/AFNI/abin:/Library/Frameworks/R.framework/Versions/3.6/Resources/bin

PYTHONPATH = 
R_LIBS = 
LD_LIBRARY_PATH = 
DYLD_LIBRARY_PATH = 
DYLD_FALLBACK_LIBRARY_PATH = 

------------------------------ data checks -------------------------------
data dir : missing AFNI_data6
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas    : found TT_N27+tlrc  under /applications/AFNI/abin

------------------------------ OS specific -------------------------------
XQuartz version      : 2.8.1

which brew           : /opt/homebrew/bin/brew
brew version         : Homebrew 3.4.5

-- for PyQt4 under brew, consider running:
   brew install cartr/qt4/pyqt
++ found 1 dylib files under '/opt/X11/lib/flat_namespace'
   -- found 'libXt' dylib files:
      /opt/X11/lib/flat_namespace/libXt.6.dylib
** env var DYLD_LIBRARY_PATH is not set to contain /opt/X11/lib/flat_namespace
   (so afni and suma may fail)

=========================  summary, please fix:  =========================
*  just be aware: login shell 'zsh', but our code examples use 'tcsh'
*  insufficient data for AFNI bootcamp
   (see "Prepare for Bootcamp" on install pages)
*  OS X version might be old
*  consider setting DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace


As we can see, AFNI now uses Python 3.10.4 and it also finds the up-to-date version of matplotlib which is installed under pip3. The reason why there is also a copy of Python 3.9 on my system is that homebrew tells me upon trying to deinstall it that some packages require Python 3.9. They are probably not yet supported by Python 3.10. Anyway, the problem, at least for now, seems to be fixed!

Edit: ok, I was too optimistic. Inside the preprocessing (using AFNI proc), I now get the following error already for the first despiking block.


3dDespike -NEW -nomask -prefix pb01.Subject1_Rest.r01.despike pb00.Subject1_Rest.r01.tcat+tlrc
dyld[4631]: Library not loaded: /sw/lib/libjpeg.9.dylib
  Referenced from: /Applications/AFNI/abin/3dDespike
  Reason: tried: '/sw/lib/libjpeg.9.dylib' (no such file), '/usr/local/lib/libjpeg.9.dylib' (no such file), '/usr/lib/libjpeg.9.dylib' (no such file)
Abort

Here is yet another update. What I did in order to fix the problem with the “libjpeg.9.dylib” file was the following.

  • I found this file under my AFNI installation (/Applications/AFNI/abin).
  • I then copy-pasted the file libjpeg.9.dylib to /usr/local/lib

This folder is one of the three folders where AFNI tried to search this file before, as you can see here


  Reason: tried: '/sw/lib/libjpeg.9.dylib' (no such file), '/usr/local/lib/libjpeg.9.dylib' (no such file), '/usr/lib/libjpeg.9.dylib' (no such file)

I then ran AFNI proc again and it worked (insofar as the problem with the libjpeg.9.dylib no longer appears). Here is my AFNI proc script first:


afni_proc.py \
-subj_id ${subject}_Rest \
-out_dir $directory/Results \
-dsets \
	$directory_warp/Warp_Align_Nwarp_RestingState_${subject}+tlrc \
-blocks despike tshift volreg mask blur regress \
-copy_anat $directory_warp/anat_final+tlrc \
-anat_has_skull no \
-tcat_remove_first_trs 4 \
-mask_segment_anat yes \
-mask_segment_erode yes \
-regress_anaticor \
-regress_ROI WMe CSFe \
-regress_apply_mot_types demean deriv \
-regress_motion_per_run \
-regress_censor_motion 0.3 \
-regress_censor_outliers 0.05 \
-blur_size 8.0 \
-regress_est_blur_epits \
-regress_est_blur_errts \
-html_review_style pythonic \
-execute

However, now another problem (and I am sure it is related to the problem stream inside my topic here) appears. After AFNI proc is done with preprocessing, it prints the following output (and QC images are also not produced):


subject ID                : Subject1_Rest
AFNI version              : AFNI_22.1.01
AFNI package              : macos_10.12_local
TR                        : 2.0
TRs removed (per run)     : UNKNOWN
num stim classes provided : 0
final anatomy dset        : anat_final.Subject1_Rest+tlrc.HEAD
final stats dset          : NO_STATS
final errts dset          : errts.Subject1_Rest.anaticor+tlrc.HEAD
final voxel resolution    : 3.000000	3.000000	3.000000

motion limit              : 0.3
num TRs above mot limit   : 0
average motion (per TR)   : 0.00957877
average censored motion   : 0.00957877
max motion displacement   : 0.0697734
max censored displacement : 0.0697734
outlier limit             : 0.05
average outlier frac (TR) : 0.00101504
num TRs above out limit   : 0

num runs found            : 1
num TRs per run           : 236
num TRs per run (applied) : 236
num TRs per run (censored): 0
fraction censored per run : 0
TRs total (uncensored)    : 236
TRs total                 : 236
degrees of freedom used   : 19
degrees of freedom left   : 217

TRs censored              : 0
censor fraction           : 0.000000
num regs of interest      : 0

TSNR average              : 247.085
global correlation (GCOR) : 0.0126185
anat/EPI mask Dice coef   : 0.814849
blur estimates (ACF)      : 0.941663 6.66755 3.5636
blur estimates (FWHM)     : 0 0 0


apqc_make_tcsh.py -review_style pythonic -subj_dir . -uvar_json out.ss_review_uvars.json
++ Found 33 files for QCing.
Traceback (most recent call last):
  File "/applications/AFNI/abin/apqc_make_tcsh.py", line 652, in <module>
    tspace    = lat.get_space_from_dset(ap_ssdict['template'])
  File "/Applications/AFNI/abin/afnipy/lib_apqc_tcsh.py", line 329, in get_space_from_dset
    dset_fullpath = com.so[0]
IndexError: list index out of range

What would be your idea? Is this problem related to the problems that I faced before? Or do I deal with something else here? In case this problem is related to something else, then of course lets try to fix the previous problems first. Please let me know what you think is going on with my AFNI installation.

PS: after my last updates, the new output of

A:

\ls -l /usr/local/bin/python3

B:

\ls -l /usr/local/bin/python

is


lrwxr-xr-x  1 root  wheel  70 Apr  3 19:44 /usr/local/bin/python3 -> ../../../Library/Frameworks/Python.framework/Versions/3.10/bin/python3
lrwxr-xr-x  1 root  wheel  22 Apr  5 09:01 /usr/local/bin/python -> /usr/local/bin/python3

Thanks,
Philipp

Hi, Philipp-

I ran your afni_proc.py command on my computer, and it ran fine (even using the +tlrc.HEAD dsets as inputs, which I thought could perhaps cause some oddities, but which didn’t).

I suspect this might be unrelated to your Python issues, actually, but I am not certain. It looks like what is happening is that it is searching for the designated ‘template’ file in the dictionary of outputs to be used for QC. The funny thing is that on my computer, there was no ‘template’ specified, because there is no tlrc or align block—so I don’t understand how that happened in your run. What is the output of


cat out.ss_review_uvars.json

?

–pt

Hi Paul and good morning,

the output of

cat out.ss_review_uvars.json

is


{
   "afni_package": "macos_10.12_local",
   "afni_ver": "AFNI_22.1.01",
   "censor_dset": "censor_Subject1_Rest_combined_2.1D",
   "copy_anat": "anat_final+tlrc.HEAD",
   "cormat_warn_dset": "out.cormat_warn.txt",
   "df_info_dset": "out.df_info.txt",
   "enorm_dset": "motion_Subject1_Rest_enorm.1D",
   "errts_dset": "errts.Subject1_Rest.anaticor+tlrc.HEAD",
   "final_anat": "anat_final.Subject1_Rest+tlrc.HEAD",
   "final_view": "tlrc",
   "gcor_dset": "out.gcor.1D",
   "mask_corr_dset": "out.mask_ae_dice.txt",
   "mask_dset": "full_mask.Subject1_Rest+tlrc.HEAD",
   "mot_limit": 0.3,
   "motion_dset": "dfile_rall.1D",
   "name": "user variables",
   "nt_applied": 236,
   "nt_orig": 236,
   "num_stim": 0,
   "out_limit": 0.05,
   "outlier_dset": "outcount_rall.1D",
   "pre_ss_warn_dset": "out.pre_ss_warn.txt",
   "ss_review_dset": "out.ss_review.Subject1_Rest.txt",
   "stats_dset": "NO_STATS",
   "subj": "Subject1_Rest",
   "sum_ideal": "sum_baseline.1D",
   "template": "./base.nii",
   "tr": 2.0,
   "tsnr_dset": "TSNR.Subject1_Rest+tlrc.HEAD",
   "volreg_dset": "pb03.Subject1_Rest.r01.volreg+tlrc.HEAD",
   "vr_base_dset": "vr_base+tlrc.HEAD",
   "xmat_regress": "X.xmat.1D",
   "xmat_uncensored": "X.nocensor.xmat.1D"
}


Back story: this file is made by gen_ss_review_scripts.py, getting information from lots of places in the results directory, including header information of files for some features.

That is how you can have a “template” entry, even though you don’t have an align or tlrc block in your AP command. I guess you ran one of the AFNI alignment programs with “base.nii” as the base dset. The problem arises that AFNI can’t find “base.nii” anywhere it is looking: in the current *results directory or in a directory specified in any of the following ~/.afnirc env variable locations:


AFNI_GLOBAL_SESSION
AFNI_SUPP_ATLAS_DIR
AFNI_ATLAS_PATH
AFNI_PLUGINPATH

If you had base.nii in any of those locations, then the problem should be resolved.

Note that this is fairly nonstandard usage of afni_proc.py, I think; not that things can’t be done this way, but I worry that separating out these pieces might lead to non-ideal processing, or potentially even mathematically problematic ones.

Can I ask what your processing pipeline is? It looks like you are using a subset of afni_proc.py features, but have done some other ones externally. It would likely be very advisable to have AP handle these together in one step (e.g., you can still run @SSwarper outside of afni_proc.py and provide it the warp results to use in a consistent manner).

–pt