unable to run uber_subject.py

Hi,

I am new to AFNI. I installed AFNI in MacOS Catalina 10.15.6. I am trying to use the uber_subject.py command. However, I keep getting the error:

uber_subject.py

**** failed to import PyQt4.QtGui ****

PyQt4 must be installed to run the uber_subject.py GUI
→ see the output of: uber_subject.py -help_install

When I follow the help, I get the following:
brew install pyqt
Updating Homebrew…
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
Updated 3 formulae.

Warning: pyqt 5.15.0 is already installed and up-to-date
To reinstall 5.15.0, run brew reinstall pyqt

MY Python path is also set to :
echo $PYTHONPATH: /usr/local/lib/python3.8/site-packages

Following is result of afni_system_check

afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture: 64bit
system: Darwin
release: 19.6.0
version: Darwin Kernel Version 19.6.0: Sun Jul 5 00:43:10 PDT 2020; root:xnu-6153.141.1~9/RELEASE_X86_64
distribution: unknown Darwin
number of CPUs: 4
apparent login shell: bash
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/matava/abin/afni
afni version : Precompiled binary macos_10.12_local: Jul 23 2020
: AFNI_20.2.06 ‘Aulus Vitellius’
AFNI_version.txt : AFNI_20.2.06, macos_10.12_local, Jul 23 2020
which python : /usr/bin/python
python version : 2.7.16
which R : /usr/local/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 (/Users/matava/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
python : 1 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
python2 : 1 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
python3 : 2
/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7
/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 : 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 : /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.pyc

– python binaries under /usr/local/bin:
/usr/local/bin/python3 (sym link to /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7)
/usr/local/bin/python3.7 (sym link to /Library/Frameworks/Python.framework/Versions/3.7/bin/python3.7)

-------------------------------- env vars --------------------------------
PATH = /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/matava/abin

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH =
DYLD_FALLBACK_LIBRARY_PATH =

------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME
top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : found AFNI_demos under $HOME
top history: 22 Oct 2019 [discoraj]: added Cluster Explorer Demo
data dir : found suma_demo under $HOME
top history: …s_New/data/Build_tmp on Mon Mar 4 11:56:45 EST 2013
data dir : found afni_handouts under $HOME
atlas : found TT_N27+tlrc under /Users/matava/abin

------------------------------ OS specific -------------------------------
XQuartz version : 2.7.11

which brew : /usr/local/bin/brew
brew version : Homebrew 2.4.9

– 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 ‘bash’, but our code examples use ‘tcsh’
  • OS X version might be old
  • consider setting DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace

Can anyone help me out here?

Howdy-

Well, uber_subject.py is a GUI interface to help build afni_proc.py commands for full single subject processing. However, it is fairly old and doesn’t allow the user to have the full flexibility of afni_proc.py options, which are pretty wide-ranging. What we recommend people to do to set up processing is to start by looking at one of the several afni_proc.py examples, which exist for both task and rest:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/programs/afni_proc.py_sphx.html
… and to adapt those scripts (and also to ask questions from here). For example, Ex. 11 and 11b are good places to start for resting state processing. Having the code examples as starting points also makes it easier to send your processing back-and-forth for questions here.

This removes the need for PyQt4 or PyQt5 stuff, so that is why PyQt4 is no longer required in the setup instructions.

Also, from your afni_system_check.py, if you run each of the following commands in a terminal:


afni
suma

do the GUIs open? You have a note about needing to set an env variable in your AFNI setup. Perhaps, could you please redo this part of the setup by copy+pasting this in a terminal:


touch ~/.cshrc
echo 'if ( $?DYLD_LIBRARY_PATH ) then' >> ~/.cshrc
echo '  setenv DYLD_LIBRARY_PATH ${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace' >> ~/.cshrc
echo 'else' >> ~/.cshrc
echo '  setenv DYLD_LIBRARY_PATH /opt/X11/lib/flat_namespace' >> ~/.cshrc
echo 'endif' >> ~/.cshrc

touch ~/.bashrc
echo 'export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/opt/X11/lib/flat_namespace' >> ~/.bashrc

… and then opening a new terminal, run “afni_system_check.py -check_all” again, and see if the " consider setting DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace " line at the bottom of the system check output disappears?

–pt

Hi Paul,

Hope you’re well!

I need uber_subject.py for an “introduction to fMRI preprocessing workshop” I’m conducting, and thought a GUI would be useful to demonstrate how the “theory of preprocessing” they learned would translate to actually processing the data.

I’m having similar issues with starting uber_subject.py. I tried running uber_subject.py from both tcsh and bash and get the same “failed to import PyQt4.QtGui”. However, I am able to start afni and suma.

My $PATH is /usr/local/fsl/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/mrinmayi/abin:/Users/mrinmayi/abin.
And $PYTHONPATH is /usr/local/lib/python2.7/site-packages

Homebrew says “pyqt 6.1.1 is already installed and up-to-date”. And my afni_system_check.py -check_all generates the following:

-------------------------------- general ---------------------------------
architecture: 64bit
system: Darwin
release: 20.6.0
version: Darwin Kernel Version 20.6.0: Wed Jun 23 00:26:31 PDT 2021; root:xnu-7195.141.2~5/RELEASE_X86_64
distribution: 10.16
number of CPUs: 4
apparent login shell: bash
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/mrinmayi/abin/afni
afni version : Precompiled binary macos_10.12_local: Aug 22 2021
: AFNI_21.2.05 ‘Nerva’
AFNI_version.txt : AFNI_21.2.05, macos_10.12_local, Aug 22 2021
which python : /opt/local/bin/python
python version : 2.7.16
which R : /usr/local/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 (/Users/mrinmayi/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/3.6/Resources/bin/R)
python : 1 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
python2 : 1 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
python3 : 2
/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6
/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!
    These packages are not installed on the computer: phia!
    These packages are not installed on the computer: snow!
    These packages are not installed on the computer: lmerTest!
    These packages are not installed on the computer: paran!
    These packages are not installed on the computer: brms!
    These packages are not installed on the computer: metafor!

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 : /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/pyplot.pyc

– python binaries under /usr/local/bin:
/usr/local/bin/python3 (sym link to /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6)
/usr/local/bin/python3.6 (sym link to /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6)

-------------------------------- env vars --------------------------------
PATH = /usr/local/fsl/bin:/opt/local/bin:/opt/local/sbin:/opt/local/bin:/opt/local/sbin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/mrinmayi/abin

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH (sub-shell) = :/opt/X11/lib/flat_namespace
DYLD_FALLBACK_LIBRARY_PATH (sub-shell) =

------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME/AFNI_Bootcamp
top history: …7 Oct 2018 [rickr]: re-add FT_white.nii, FT_vent.nii
data dir : found AFNI_demos under $HOME/AFNI_Bootcamp
top history: … [pault]: remove rank from FATCAT_DEMO, FAT_MVM_DEMO
data dir : found suma_demo under $HOME/AFNI_Bootcamp
top history: …/SUMA_data/Build_tmp on Wed Aug 20 10:04:23 EDT 2014
data dir : found afni_handouts under $HOME/AFNI_Bootcamp
atlas : found TT_N27+tlrc under /Users/mrinmayi/abin

------------------------------ OS specific -------------------------------
XQuartz version : 2.8.0_beta3

which brew : /usr/local/bin/brew
brew version : Homebrew 3.2.9
which port : /opt/local/bin/port
port version : Error: Current platform “darwin 20” does not match expected platform “darwin 19”

– for PyQt4 under brew, consider running:
brew install cartr/qt4/pyqt
– consider installing gcc under homebrew
++ found valid link /usr/local/lib/libglib-2.0.dylib
to …/Cellar/glib/2.68.3/lib/libglib-2.0.dylib
++ found 1 dylib files under ‘/opt/X11/lib/flat_namespace’
– found ‘libXt’ dylib files:
/opt/X11/lib/flat_namespace/libXt.6.dylib
– recent OS X, cheating to check DYLD_LIBRARY_PATH in cur shell ‘bash’…
++ found evar DYLD_LIBRARY_PATH = :/opt/X11/lib/flat_namespace
– recent OS X, cheating to check DYLD_LIBRARY_PATH in shell ‘tcsh’…
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

========================= summary, please fix: =========================

  • just be aware: login shell ‘bash’, but our code examples use ‘tcsh’
  • shell bash: consider sourcing (non-login) .bashrc from (login) .bash_profile
  • missing R packages (see rPkgsInstall)

Is there something else I’m missing?

Thank you,
Mrinmayi

PS: Even if I do get uber_subject working, I’ll be sure to tell the attendees that afni_proc is the preferred way to do preprocessing, and show them how to use it as well! :slight_smile:

Hi, Mrinmayi-

I’m doing alright, thanks, and I things are good for you, too. That is great that you are running a FMRI processing workshop!

About uber_subject.py—
[caveat—I am not the best person to answer about this, but that person is on leave for a couple days, so I will have a go…]
Firstly, I don’t believe that there is currently a way to get it to run in Python 3.*, and many participants might have that, so it might be hard/impossible for them to follow along with it. It requires PyQt4 specifically, I believe, and this might only run in Python 2.7 at the moment.

I see you are using Python 2.7, and then I think the trick would be to have PyQt4 (not PyQt6, as it appears to be showing up). To manage different package things, esp. when Python is involved, I have found Conda (–> and in particular Miniconda) to be the easiest way to go—you can specify the packages+version numbers you want, and in theory they shouldn’t interact with each other and you can purge them at your leisure.

Some more notes about (mini)conda specifically are—note there is both a verbose and a quick set of descriptions:
https://afni.nimh.nih.gov/pub/dist/doc/htmldoc/background_install/miniconda.html

I tried to make a conda environment with PyQt4, which would run uber_subject.py, and here were my results:

Failed and failed (conflict between matplotlib+numpy and PyQt4):


conda create -y -n py27_tiny_pyqt4     -c conda-forge       pyqt=4  python=2.7    matplotlib numpy
conda create -y -n py27_tiny_pyqt4     -c conda-forge       pyqt=4  python=2.7    matplotlib 

Failed (Python 3.7 and PyQt4 wouldn’t play nicely together):


conda create -y -n py37_tiny_pyqt4     -c conda-forge       pyqt=4  python=3.7

Worked, but extremely limited and won’t have the nice, “pythonic” QC HTML output from afni_proc.py (just the plainer/less informative will be output—boooo):


conda create -y -n py27_tiny_pyqt4     -c conda-forge       pyqt=4  python=2.7

… so, this provides a way to open the GUI and use it, but I still might go for The Leap to afni_proc.py, parcellating the command into its component parts for understandability.

As an intro to afni_proc.py, there is this presentation given by The Bob from time to time at Bootcamps (also in the afni_handouts/ dir of the Bootcamp tarball):
https://afni.nimh.nih.gov/pub/dist/edu/data/CD.expanded/afni_handouts/afni_proc.pdf
I have shorter+similar one from talking at the Resting State conference that I can send you, which might be useful.

–pt

Hi Paul,

Thanks a lot for this information. I’ll give it a shot! And I think I’ll uninstall PyQt4 after the workshop so I can continue to get the helpful output from matplotlib, etc.

We’ve been pointing attendees of our workshop to the AFNI documentation and YouTube channel in every session. So I’m sure you’re going to get a bunch of views from Milwaukee in the next few weeks! :slight_smile:

Thank you,
Mrinmayi

Hi, Mrinmayi-

OK, glad that is useful.

For the PyQt4: I hope you can still show the afni_proc.py output QC HTML—I really find it useful for seeing (most) all of the pieces of the analysis in one spot. The driver scripts in each results directory are useful, too (basically, that content became the core of the QC HTML). The benefit of using Conda is that you can make an environment in which PyQt4 exists, and then also one in which the other “normal” stuff (like matplotlib+numpy) exist, and you can switch between them. Part of this is possible because essentially every AFNI Python program runs in both Python 2.7 and 3.* (I hear you asking, “Which progs don’t?” and the answer is meica.py and the meica.libs/tedana.py distributed in AFNI–those were written long ago, and the developer no longer updates them, so they just live in Python 2.7).

So, you could have:


# env for uber_subject
conda create -y -n py27_tiny_pyqt4     -c conda-forge       pyqt=4  python=2.7

# env for all other analyses
conda create -y      -n py37_afni_tiny    python=3.7  matplotlib numpy

… and then “conda activate py27_tiny_pyqt4” when you want to run uber_subject.py, and “conda activate py37_afni_tiny” (or have the latter be default) when you want to do everything else.

Re videos—we now have a very “shortest of short” introduction to preparing for an AFNI Bootcamp on FMRI—some notes about background/philosophy of data analysis, some intro GUI videos, and then some lectures on the basics of single subject analysis FMRI (GLM setup, etc.). I belieeeeve it clocks in at an easily digestible 2.5 hours of videos, so surely everyone will want to do that! It is here:
https://www.youtube.com/watch?v=l6lDA1_p5t8&list=PL_CD549H9kgoiCyRuHjlxlu6WMJRnMU7f
The attendees might find that useful for sharing with others, or for quick review.

Sounds like a great summer for Milwaukee: first the Bucks win the championship, and now an AFNI FMRI workshop! (Maybe you should invite Giannis to the workshop?)

–pt