I am trying to use the output from 3dvolreg to adjust a data set using 3dAllineate -1Dparam_apply.
Reading the program help file: 3dvolreg outputs:
roll = rotation about the I-S axis }
pitch = rotation about the R-L axis } degrees CCW
yaw = rotation about the A-P axis }
dS = displacement in the Superior direction }
dL = displacement in the Left direction } mm
dP = displacement in the Posterior direction }
Question 1) Would ‘dL’ be x-shift; ‘dS’ be y-shift; and ‘dP’ be z-shift?
I ask this because I read in 1dApar2mat help file:
* The 12 parameters are, in the order used on the 1dApar2mat command line
(the same order as output by 3dAllineate):
x-shift in mm
y-shift in mm
z-shift in mm
z-angle (roll) in degrees (not radians!)
x-angle (pitch) in degrees
y-angle (yaw) in degrees
x-scale unitless factor, in [0.10,10.0]
y-scale unitless factor, in [0.10,10.0]
z-scale unitless factor, in [0.10,10.0]
y/x-shear unitless factor, in [-0.3333,0.3333]
[b]
Question 2) OR if my understanding of the ordering in question 1 is incorrect. Can someone please show me how to correct the below array using the output of 3dvolreg, to input in 3dAllineate (‘C1’ is Column 1 which is rolll, ‘C2’ is Column 2 which is pitch, etc.):
C1 C2 C3 C4 C5 C6 ===> ?
[/b]
Question 3) How can I easily add columns of zeros to the end of the 1Dfile output by volreg so it can have the required 12 columns for 3dAllineate? Currently, I do this in matlab, but to know how to do in AFNI would be very helpful.
OR is there a more simple way to do what I am trying to do?
I just tried to run ‘1d_tool.py’ and get the same error:
>> 1d_tool.py
Traceback (most recent call last):
File "/Users/ebaldelo/abin/1d_tool.py", line 2731, in <module>
sys.exit(main())
File "/Users/ebaldelo/abin/1d_tool.py", line 2719, in main
aint = A1DInterface()
File "/Users/ebaldelo/abin/1d_tool.py", line 1424, in __init__
self.init_options()
File "/Users/ebaldelo/abin/1d_tool.py", line 1756, in init_options
acplist = LAD.g_1D_write_styles,
AttributeError: 'module' object has no attribute 'g_1D_write_styles'
I ran afni_system_check.py to check the status of things but don’t see anything that sticks out to me (details below). Any thoughts or anything that sticks out to you?
>> afni_system_check.py -check_all
-------------------------------- general ---------------------------------
architecture: 64bit
system: Darwin
release: 17.7.0
version: Darwin Kernel Version 17.7.0: Thu Jun 21 22:53:14 PDT 2018; root:xnu-4570.71.2~1/RELEASE_X86_64
distribution: unknown Darwin
number of CPUs: 24
apparent login shell: bash
shell RC file: .bashrc (exists)
--------------------- AFNI and related program tests ---------------------
which afni : /Users/ebaldelo/abin/afni
afni version : Precompiled binary macos_10.12_local: Jan 6 2023
: AFNI_23.0.00 'Commodus'
AFNI_version.txt : AFNI_23.0.00, macos_10.12_local, Jan 06 2023
which python : /usr/bin/python
python version : 2.7.10
which R : /usr/local/bin/R
R version : R version 3.5.2 (2018-12-20) -- "Eggshell Igloo"
which tcsh : /bin/tcsh
instances of various programs found in PATH:
afni : 1 (/Users/ebaldelo/abin/afni)
R : 1 (/Library/Frameworks/R.framework/Versions/3.5/Resources/bin/R)
python : 1 (/usr/bin/python)
python2 : 0
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
3dMVM : FAILURE
Error in dyn.load(ll) :
unable to load shared object '/Users/ebaldelo/abin/R_io.so':
dlopen(/Users/ebaldelo/abin/R_io.so, 6): Library not loaded: /sw/Library/Frameworks/R.framework/Versions/3.6/Resources/lib/libR.dylib
Referenced from: /Users/ebaldelo/abin/R_io.so
Reason: Incompatible library version: R_io.so requires version 3.6.0 or later, but libR.dylib provides version 3.5.0
Calls: source ... withVisible -> eval -> eval -> set_R_io -> dyn.load
Execution halted
checking for R packages...
rPkgsInstall -pkgs ALL -check : success
R RHOME : /Library/Frameworks/R.framework/Resources
checking for $HOME files...
.afnirc : found
.sumarc : missing
.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
-------------------------------- env vars --------------------------------
PATH = /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/Users/ebaldelo/abin
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 /Users/ebaldelo/abin
------------------------------ OS specific -------------------------------
XQuartz version : 2.8.2
which brew : /usr/local/bin/brew
brew version : Homebrew 3.6.1
-- 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'
* AFNI programs show FAILURE
* please run: "suma -update_env" for .sumarc
* insufficient data for AFNI bootcamp
* OS X version might be old
* consider setting DYLD_LIBRARY_PATH to /opt/X11/lib/flat_namespace
Hmmm, that is a bit strange. Do you know of anything peculiar in your python setup? I don’t see anything strange in the system check output. But the error suggests maybe there is a discrepancy between versions of python files.
>> ls -l ~/abin/afnipy/lib_afni1D.py
-rw-r--r-- 1 20892 staff 152834 Aug 19 2020 /Users/ebaldelo/abin/afnipy/lib_afni1D.py
I really thought I did ‘@update.afni.binaries -defaults’ sometime last year. Either way… just tried it. and after downloading some files and extracting I start seeing a lot of ‘Permission Denied’, e.g:
-- running @update.afni.binaries version 3.21, July 22, 2022
-- have AFNI binaries under /Users/ebaldelo/abin
-- install dir: using existing /Users/ebaldelo/abin
-- any downloads will be from https://afni.nimh.nih.gov via curl -O -f
-- attempting to install package macos_10.12_local under
install dir: /Users/ebaldelo/abin...
-- have install dir
++ working in new temp dir, .tmp.install
++ getting install prog: curl -O -f bin/misc/@update.afni.binaries ...
curl -O -f https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 50045 100 50045 0 0 161k 0 --:--:-- --:--:-- --:--:-- 162k
-- fixing lost permissions on @update.afni.binaries
-- @update.afni.binaries is current, continuing with this version...
++ downloading test file: curl -O -f macos_10.12_local/afni ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11.7M 100 11.7M 0 0 13.4M 0 --:--:-- --:--:-- --:--:-- 13.4M
++ update needed, installing...
++ downloading full package: curl -O -f macos_10.12_local.tgz ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 975M 100 975M 0 0 26.5M 0 0:00:36 0:00:36 --:--:-- 26.8M
++ extracting package macos_10.12_local.tgz...
++ backing up current binaries to auto_backup.macos_10.12_local
mv: rename ../afniRTI to auto_backup.macos_10.12_local/afniRTI: Permission denied
mv: rename ../afnipy to auto_backup.macos_10.12_local/afnipy: Permission denied
mv: rename ../auto_backup.macos_10.12_local to auto_backup.macos_10.12_local/auto_backup.macos_10.12_local: Permission denied
mv: rename ../funstuff to auto_backup.macos_10.12_local/funstuff: Permission denied
mv: rename ../lib_RetroTS to auto_backup.macos_10.12_local/lib_RetroTS: Permission denied
mv: rename ../meica.libs to auto_backup.macos_10.12_local/meica.libs: Permission denied
mv: rename ../shiny to auto_backup.macos_10.12_local/shiny: Permission denied
deleting old backup directory, auto_backup.macos_10.12_local ...
and it goes on…I’d be happy to try a complete re-install?
Indeed, the output from that “ls -l” command shows that you do not own or have write permission to that library file (or any of the other ‘denied’ ones) It was possibly installed by an admin.
If you want to clean up, I would suggest a sequence like this:
cd
mv abin abin.corrupt
cp -r abin.corrupt abin
@update.afni.binaries -defaults
That will leave the current abin as abin.corrupt, if you ever want to mess with it (deleting might be fine, but that might require admin rights).
I don’t understand why either. It’s very strange. Here’s the output:
>>tcsh ~/abin.corrupt/@update.afni.binaries -bindir ~/abin -package macos_10.12_local -defaults
/Users/ebaldelo/abin.corrupt/@update.afni.binaries: No such file or directory.
Here’s this if it’s worth knowning:
>> ls -l ~/abin*
/Users/ebaldelo/abin:
total 0
drwxr-xr-x 10 ebaldelo staff 320 Mar 2 11:38 afniRTI
drwxr-xr-x 100 ebaldelo staff 3200 Mar 2 11:38 afnipy
drwxr-xr-x 958 ebaldelo staff 30656 Mar 2 11:38 auto_backup.macos_10.12_local
drwxr-xr-x 796 ebaldelo staff 25472 Mar 2 11:38 funstuff
drwxr-xr-x 14 ebaldelo staff 448 Mar 2 11:38 lib_RetroTS
drwxr-xr-x 8 ebaldelo staff 256 Mar 2 11:38 meica.libs
drwxr-xr-x 6 ebaldelo staff 192 Mar 2 11:38 shiny
/Users/ebaldelo/abin.corrupt:
total 0
drwxr-xr-x 10 20892 staff 320 Aug 20 2020 afniRTI
drwxr-xr-x 100 20892 staff 3200 Aug 20 2020 afnipy
drwxr-xr-x 958 root staff 30656 Aug 20 2020 auto_backup.macos_10.12_local
drwxr-xr-x 796 20892 staff 25472 Aug 19 2020 funstuff
drwxr-xr-x 14 20892 staff 448 Aug 20 2020 lib_RetroTS
drwxr-xr-x 8 20892 staff 256 Aug 19 2020 meica.libs
drwxr-xr-x 6 20892 staff 192 Aug 19 2020 shiny
I’m willing to delete related AFNI/abin files and try a fresh install if worth it…
++ update needed, installing...
++ downloading full package: curl -O -f macos_10.12_local.tgz ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 975M 100 975M 0 0 16.6M 0 0:00:58 0:00:58 --:--:-- 17.5M
++ extracting package macos_10.12_local.tgz...
++ backing up current binaries to auto_backup.macos_10.12_local
deleting previous backup directory, auto_backup.macos_10.12_local ...
++ installing new binaries...
++ will source .cshrc from newly created /Users/ebaldelo/.tcshrc
++ adding /Users/ebaldelo/abin to PATH in /Users/ebaldelo/.zshrc ...
++ setting DYLD_LIBRARY_PATH in /Users/ebaldelo/.zshrc ...
-- seem be be sourcing .bashrc from /Users/ebaldelo/.bash_profile
++ setting DYLD_LIBRARY_PATH in /Users/ebaldelo/.profile ...
/Users/ebaldelo/.profile: Permission denied.
I went in and manually changed ownership via:
>> sudo chown ebaldelo /Users/ebaldelo/.profile
this is what I got when I repeated:
>> tcsh @update.afni.binaries -bindir ~/abin -package macos_10.12_local -defaults
-- running @update.afni.binaries version 3.21, July 22, 2022
-- have AFNI binaries under /Users/ebaldelo/abin
-- any downloads will be from https://afni.nimh.nih.gov via curl -O -f
-- attempting to install package macos_10.12_local under
install dir: /Users/ebaldelo/abin...
-- have install dir
deleting old temporary directory...
++ working in new temp dir, .tmp.install
++ getting install prog: curl -O -f bin/misc/@update.afni.binaries ...
curl -O -f https://afni.nimh.nih.gov/pub/dist/bin/misc/@update.afni.binaries
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 50045 100 50045 0 0 202k 0 --:--:-- --:--:-- --:--:-- 202k
-- fixing lost permissions on @update.afni.binaries
-- @update.afni.binaries is current, continuing with this version...
++ downloading test file: curl -O -f macos_10.12_local/afni ...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 11.7M 100 11.7M 0 0 12.9M 0 --:--:-- --:--:-- --:--:-- 12.9M
++ no update needed
1d_tool.py now seems to work. And I am am able to (finally) attempt the original prompt. I attempted it on the same pre-registered data set I got the 1D file from. It looks pretty similar but there are a few places where the 3dvolreg data set looks different from the 3dAllineate data set. Is this to be expected?
Great, I am glad the install is settled. I should have asked if you had admin rights…
To be sure, are you using 3dAllineate to apply the (converted) 3dvolreg parameters and are comparing the results?
What is the 3dAllineate command?
Can you be more specific about in what way (in a few places) the result looks unexpected? Does that mean a few locations in the volume? At a few time points? Does the difference seem to be one of interpolation, or something bigger?
It seems that at a number of time points (>10) the 3dAllineate volume is spatially different/shifted, up to 2 voxels different, from the 3dVolreg volume… The rest, they are similar but I can still see some differences which may be due to interpolation differences.
I did not test it methodically. I went straight toward my desired application; SO I should ask, if I were to take the exact same volume (here, $AnimalID/$FolderID/${AnimalID}_${FolderID}.Box.DS+orig) and apply it using the 3dAllineate command, should I expect the two volumes to be near identical with only differences being due to interpolation differences?
*UPDATE: It seems to do the same thing regardless of which ‘master’ is used. I have another data set with much more noticeable motion, and the differences between the volreg volume and 3dAllineate volume are more noticeable and confirmed.
SECOND UPDATE/QUESTION: Does it matter if the unregistered volume was segmented using:
I took a smaller subset and methodically edited the different values. It appears column 4, roll, value appeared to be the culprit. Below are values from a dfile_VolReg2_aff12.1D file:
I thought it was strange that each of the roll values are typically an order or two magnitude higher than the pitch or yaw. EDITED* I looked more closely through the data set and perhaps actual data/image volume does move more so in the roll direction. BUT it also seems to apply a translation! Or something weird.
Anyway, IF I use the dfile_VolReg2_aff12.1D file, BUT make all of column 4, roll values, zero, it looks MUCH more near identical to the registered volume using 3dvolreg. Could it be a order of operation, whether translation or rotation gets applied first??
QUESTION: Is there a way to make only this column zero in AFNI? Currently can only do in matlab…
I have looked at this, and there are more subtleties. Basically, the param files between 3dvolreg and 3dAllineate are not appropriate for passing between the programs. Besides the column order, there are appear to be negatives between the shifts. Also, 3dvolreg uses the center of the volume for rotations, while 3dAllineate uses xyz = (0,0,0) for its center. So the sets of rotations/shifts will not equate, even if they are “properly” rearranged and signed.
This brings up why both programs have -1Dmatrix_save options. The matrices translate better than the parameters. I will compare those, too…
Indeed, they produce approximately the same matrices. So you could use 3dvolreg -1Dmatrix_save and apply it with 3dAllineate -1Dmatrix_apply and get similar output (subject to interpolation choices).
The
National Institute of Mental Health (NIMH) is part of the National Institutes of
Health (NIH), a component of the U.S. Department of Health and Human
Services.