further processing of MEICA-preprocessed resting state data & uber_subject.py (failure to locate pytq)

Hello,

I am quite new to MRI data processing. I have preprocessed my resting state data with meica and now I would like to start with ROI-seeded correlation maps and functional connectivity analysis but I am having a hard time executing some of the scripts discussed in proc.py examples ( i.e. example 11b). I have about 28 patients that underwent TMS to the calcimine sulcus and I am now looking at post-stem resting state network changes. My questions:

1-Now that I preprocessed my data with meica, Is there a stepwise approach that I can follow for correlation maps (DMN & stimulation site) and functional connectivity analysis?

2- I know uber_subject.py is not recommended and I should learn to use the scripts but It might be a good start for me to at least learn the steps. Though for the life of me I cannot get it to work and I get the pesky “failed to import PyQt4.QtGui” error despite afni_system_check.py -check_all showing no issues with installation. (I tried setenv PYTHONPATH /usr/local/lib/python2.7/site-packages and no cigar!) I even tried installing ANACONDA and fink and pytq directly. The afni system check is pasted at the bottom.

3- How can I automate my resting state analysis-- group analysis (I heard in one of your videos someone said I can beg to see if somebody is willing to share their scripts with me)?

Thank you and happy new year!

architecture: 64bit
system: Darwin
release: 19.6.0
version: Darwin Kernel Version 19.6.0: Tue Nov 10 00:10:30 PST 2020; root:xnu-6153.141.10~1/RELEASE_X86_64
distribution: 10.15.7
number of CPUs: 4
apparent login shell: tcsh
shell RC file: .tcshrc (exists)

--------------------- AFNI and related program tests ---------------------
which afni : /Users/remycohan/abin/afni
afni version : Precompiled binary macos_10.12_local: Dec 22 2020
: AFNI_20.3.04 ‘Vespasian’
AFNI_version.txt : AFNI_20.3.04, macos_10.12_local, Dec 22 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/remycohan/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.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 : 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.9/bin/python3.9)
/usr/local/bin/python3.9 (sym link to /Library/Frameworks/Python.framework/Versions/3.9/bin/python3.9)

-------------------------------- env vars --------------------------------
PATH = /Library/Frameworks/Python.framework/Versions/3.9/bin:/usr/local/opt/qt/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Library/Apple/usr/bin:/Users/remycohan/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
top history: 20 Feb 2020 [rickr]: updated FT_analysis examples
data dir : found AFNI_demos under $HOME
top history: …ct 2020 [taylorp]: updated scripts under FATCAT_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/remycohan/abin

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

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

++ found PyQt4 under /usr/local/lib/python2.7/site-packages
** warning: have brew? PyQt4, but non-brew python /usr/bin/python
** consider linking /usr/local/Cellar/gcc/10.2.0/lib/gcc/10/libgomp.1.dylib under /usr/local/lib
– consider installing glib under homebrew
++ 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 ‘tcsh’…
++ found evar DYLD_LIBRARY_PATH = /opt/X11/lib/flat_namespace

========================= nothing to fix, yay! =========================

Hi, Rémy-

Can you please share your existing afni_proc.py command here? It will make it easier to discuss. For example, are you warping to standard space (if so, which one?), or are you staying in native subject space and wanting to use, say, FreeSurfer ROIs as anatomical reference?

Note that the afni_proc.py help can include MEICA processing block-- examples 12*. You can choose to use tedana.py for denoising prior to that, or use the “optimally combined”, say (examples 12c and 12b, respectively).

Re. uber_subject.py: it’s just really so much better to use afni_proc.py directly, and the installation is a pain/not possible on some OSs at present. With the afni_proc.py command, we can send code directly back and forth and modify it; and I’m not sure that any of the MEICA “combine” block parts are included in uber_subject.py (I doubt it).

Re. automating resting state analysis: well, I’m not sure what that means… I don’t know that we hold any particular secrets on that. With afni_proc.py you can create a full processing pipeline for a single subject. To “automate” for a group, I would write a script with one afni_proc.py command, and loop over all subject directories, using the same commands for each (just changing the input files and output directory each time).

As for what to do at the group level… that is a question for your particular data. Having TMS data, I assume everyone has a similar TMS placement site, but that it would also be a bit unique to each subject?

–pt

Thank you for your response. Yes, by automation I meant group analysis. I also, look at both the atlas-based DMN and the stimulation site (anatomy based on calcrine sulcus using the BrainSight’s coordinates) I use the following steps for my MEICA-preprocessed data so I think I am using the free surfer ROI after denoising. But have not been able to go far because as you can see here after 3dmerge I receive an error. This happened when I used some of the commands from example 12 as well. And I am sure part of this problem is my limited knowledge of what these commands do and their purpose, despite watching your videos and reading the help texts!

Denoising steps:

3dmerge -1blur_fwhm 4.0 -doall -prefix s01_medn_blur _medn.nii.gz

dTstat -prefix rm.mean_s01 s01_medn_blur+orig (at this stage I receive a fatal error : cannot open dataset s01_blur+orig)

3dcalc -a s01_medn_blur+orig -b rm.mean_s01+orig -expr ‘min(200, a/b*100)*step(b)’ -prefix s01_medn_scaled

ROI:

echo “20 -40 15” >brainpart.txt

3dUndump -prefix ROIname -master *_medn_scaled -srad 6 -xyz brainpart.txt

3dmaskave -quiet -mask ROIname+orig *_medn_scaled > ROIname_timecourse.txt

3dfim+ -input *medn_scaled -ideal_file ROIname_timecourse.txt -out Correlation -bucket ROIname_corr

3dcalc -a ROIname_corr -expr ‘log((1+a)/(1-a))/2’ -prefix ROIname_corr_z

Should I just stick with the scripts used in example 12a.b.c?
I am also having a hard time to figure out what part of the command I need to change? In matlab or pycharm things are colour-coded so I know what is that I need to change but with UNIX I cannot tell for example where prefix is typed in the command line, do I just change the prefix or subject_id or the rest? That is why I was keen to use the GUI so I could look at the output based on the information I entered and see how the script changes.

Thank you!

Screen Shot 2021-01-04 at 4.32.03 PM.png