wrong behavior of DriveSuma

Hi afni group:

I have a DriveSuma script that runs afni and suma, has them talking and save images. It works perfectly on one machine. While when I moved it to another machine, everything went well except the recording behavior. Basically I use


for pose in 'Ctrl+left' 'Ctrl+right'
do
	# get view and snap
	DriveSuma -com viewer_cont -key "$pose" -com viewer_cont -key 'Ctrl+r' 
	sleep 3 # give it a break to change the view and save the fig 
done

to change the angle and record the image, but sometimes the recorded image was like the images that I attached (and sometimes It worked perfectly with nothing changed). What’s weird is that this wrong behavior was not stable, some times it recorded at this weird angle, or another angle, or even black. I have assumed that maybe the record command is coming too soon after the changing angle command, I even split the two commands(changing angle and recording image) into two line and have a sleep between them, but still not working.

Here is the full commands.

Thanks!
Mengxing


#!/bin/bash

# set some environment variables
export AFNI_NOSPLASH=YES
export AFNI_SPLASH_MELT=NO
export AFNI_ENVIRON_WARNINGS=NO
export AFNI_PBAR_FULLRANGE=NO
export SUMA_DriveSumaMaxCloseWait=20
export SUMA_DriveSumaMaxWait=10

portnum=`afni -available_npb_quiet`

epi=Cj_Ch_IPL_005_PS.nii
suma=./suma_MNI152_2009
anat=MNI152_2009_SurfVol.nii

epi=Cj_Ch_IPL_005_PS.nii
suma=./suma_MNI152_2009
anat=MNI152_2009_SurfVol.nii
# name for output image file
jnam=CH_IPL
# drive AFNI to get the images we want
    afni -yesplugouts -niml $suma/$anat ./cj/* &
    plugout_drive \
         -com "OPEN_WINDOW sagittalimage opacity=6"          \
         -com "OPEN_WINDOW axialimage opacity=6"             \
         -com "OPEN_WINDOW coronalimage opacity=6"           \
         -com "SEE_OVERLAY +"                                \
         -com "SWITCH_UNDERLAY $anat"                        \
         -com "SWITCH_OVERLAY $epi"                          \
         -com "SET_PBAR_ALL +4 								 \
				3.5=violet 2.5=green 1.5=cyan 0.5=none"      \
		 -com "SET_FUNC_AUTORANGE -"						 \
         -quit

suma -spec $suma/std.141.MNI152_2009_both.spec \
     -sv $suma/$anat \
	 -niml &

# talk with afni

DriveSuma -com viewer_cont -key 't' -key:r2:d period
sleep 5 # talk needs some time, give it a break

# Remove crosshair and axes
# Change viewer size to 1200*1200 pixels
DriveSuma -com viewer_cont -key 'F3' -key 'F4' \
			-key 'F5' -key 'F9' -viewer_size 1200 1200 \
			-key:r2:d 'z' -key 'a'

sleep 5

for pose in 'Ctrl+left' 'Ctrl+right'
do
	# get view and snap

	DriveSuma -com viewer_cont -key "$pose" -com viewer_cont -key 'Ctrl+r' 
	sleep 3 # give it a break to change the view and save the fig 
done


Maybe put a sleep between your view control keys and the record in case those go too quickly together. Does this work when you do the equivalent yourself in the GUI? Otherwise, is it possible there is another keyboard shortcut grabbed by something else on the system?

Hi Daniel,

Even I tried with


DriveSuma -com viewer_cont -key "$pose"
sleep 3
DriveSuma -com viewer_cont -key 'Ctrl+r'

still didn’t work.

And I tried it manually with GUI by myself, nothing went wrong.

What’s weird is that sometimes the same codes worked perfectly, and sometimes it didn’t.
Thanks!

Mengxing

What OS are you using? Maybe I can try on a similar one?

Hi Daniel,

In short, I’m using Ubuntu 19.04, and the afni version Precompiled binary linux_ubuntu_16_64: Mar 8 2019 : AFNI_19.0.24 ‘Tiberius’

Just in case you want all the details, I have it here.

Also, if it took you too much time, and there was no apparently stupid bug in my code, feel free to ignore my report. After all you won’t have to save images often for one study, and the codes sometimes work well.

Many thanks!!!

best,
Mengxing

The OS on which it does not work well (after it, you will find the system_check info for another OS that I tested on which the codes worked perfectly):
mengxing@XPS:~/…/01_Data_Analysis/GUI$ afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture: 64bit
system: Linux
release: 4.15.0-1036-oem
version: #41-Ubuntu SMP Sun Apr 7 05:24:01 UTC 2019
distribution: Ubuntu 19.04 disco
number of CPUs: 8
apparent login shell: bash
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /home/mengxing/Application/afni/afni
afni version : Precompiled binary linux_ubuntu_16_64: Mar 8 2019
: AFNI_19.0.24 ‘Tiberius’
AFNI_version.txt : AFNI_19.0.24, linux_ubuntu_16_64, Mar 08 2019
which python : /usr/bin/python
python version : 2.7.16
which R : /usr/bin/R
R version : R version 3.5.2 (2018-12-20) – “Eggshell Igloo”
which tcsh : /usr/bin/tcsh

instances of various programs found in PATH:
afni : 1 (/home/mengxing/Application/afni/afni)
R : 1 (/usr/bin/R)
python : 1 (/usr/bin/python2.7)
python2 : 1 (/usr/bin/python2.7)
python3 : 1 (/usr/bin/python3.7)

testing ability to start various programs…
afni : success
suma : success
3dSkullStrip : success
uber_subject.py : success
3dAllineate : success
3dRSFC : success
SurfMesh : success
3dClustSim : 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: paran!
    These packages are not installed on the computer: psych!
    These packages are not installed on the computer: brms!

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

------------------------------ python libs -------------------------------
++ module ‘PyQt4’ found at /usr/lib/python2.7/dist-packages/PyQt4
++ module loaded: PyQt4

-------------------------------- env vars --------------------------------
PATH = /home/mengxing/Application/freesurfer/bin:/home/mengxing/Application/freesurfer/fsfast/bin:/home/mengxing/Application/freesurfer/tktools:/home/mengxing/Application/freesurfer/mni/bin:/home/mengxing/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/mengxing/Application/afni:/home/mengxing/Application/afni

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH =
DYLD_LIBRARY_PATH =
DYLD_FALLBACK_LIBRARY_PATH =

------------------------------ data checks -------------------------------
data dir : found AFNI_data6 under $HOME
top history: …9 [ptaylor]: added FT_analysis/results.QC_FT.05 tree
data dir : missing AFNI_demos
data dir : missing suma_demo
data dir : missing afni_handouts
atlas : found TT_N27+tlrc under /home/mengxing/Application/afni

------------------------------ OS specific -------------------------------
which apt-get : /usr/bin/apt-get
apt-get version : apt 1.8.0 (amd64)

have Ubuntu system: Ubuntu 19.04 disco
have Ubuntu afni : Precompiled binary linux_ubuntu_16_64: Mar 8 2019

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

  • login shell ‘bash’, trusting user to translate code examples from ‘tcsh’
  • shell bash: consider sourcing (non-login) .bashrc from (login) .profile
  • missing R packages (see rPkgsInstall)
  • insufficient data for AFNI bootcamp

The other OS that it worked well:

-------------------------------- general ---------------------------------
architecture: 64bit ELF
system: Linux
release: 3.10.0-862.3.2.el7.x86_64
version: #1 SMP Mon May 21 23:36:36 UTC 2018
distribution: CentOS Linux 7.5.1804 Core
number of CPUs: 16
apparent login shell: bash
shell RC file: .bashrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /opt/afni/linux_openmp_64/afni
afni version : Precompiled binary linux_openmp_64: Feb 4 2019
: AFNI_19.0.06 ‘Tiberius’
AFNI_version.txt : AFNI_19.0.06, linux_openmp_64, Feb 04 2019
which python : /usr/bin/python
python version : 2.7.5
which R : /usr/bin/R
R version : R version 3.5.0 (2018-04-23) – “Joy in Playing”
which tcsh : /usr/bin/tcsh

instances of various programs found in PATH:
afni : 2
/opt/afni/linux_openmp_64/afni
/opt/afni-stable/linux_openmp_64/afni
R : 1 (/usr/bin/R)
python : 1 (/usr/bin/python2.7)
python2 : 1 (/usr/bin/python2.7)
python3 : 0

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

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

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

------------------------------ python libs -------------------------------
++ module ‘PyQt4’ found at /usr/lib64/python2.7/site-packages/PyQt4
++ module loaded: PyQt4

-------------------------------- env vars --------------------------------
PATH = /opt/afni/linux_openmp_64:/opt/afni-stable/linux_openmp_64:/opt/Modules/bin:/opt/dtk:/opt/workbench/bin_rh_linux64:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/export/home/lmengxing/.local/bin:/export/home/lmengxing/bin

PYTHONPATH =
R_LIBS =
LD_LIBRARY_PATH = /usr/lib

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 /opt/afni/linux_openmp_64

------------------------------ OS specific -------------------------------
which dnf : /usr/bin/dnf
dnf version : 0.6.4
which yum : /usr/bin/yum
yum version : 3.4.3

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

  • login shell ‘bash’, trusting user to translate code examples from ‘tcsh’
  • have multiple versions of AFNI in PATH
  • consider running: cp /opt/afni/linux_openmp_64/AFNI.afnirc ~/.afnirc
  • consider running: apsearch -update_all_afni_help
  • insufficient data for AFNI bootcamp

Thanks!!

And just to be sure, this is not a remote application like ssh or vnc?

No, it’s not. It’s on a local machine.

I tried on my Ubuntu system, and I found a bit of strangeness; the recording would catch an intermediate position, usually on the first recorded position, but sometimes later on too. I found a workaround for this that helps:

DriveSuma -com viewer_cont -key:r2:d "$pose"

This tells suma to repeat the keystroke a second time and update the display. Doing this or repeating the entire command here seems to avoid incorrection position recordings.

Brilliant!! Thanks!

Mengxing