AFNI version info (afni -ver): Precompiled binary macos_10.12_local: Jun 3 2020 (Version AFNI_20.1.13 'Otho')
I am trying to run open_afni_suma.csh within MATLAB to open clusters that were previously extracted. I am getting to the point where it sets the labels, and then this is the end of the output (starting with the last 2 labels): set ind_label = sed "${li}q;d" temp_labels.txt sed 252q;d temp_labels.txt set rgb = sed "${li}q;d" roi256.1D sed 252q;d roi256.1D echo 239 roi239 0.85 0.02 0.46 1 end set ind_label = sed "${li}q;d" temp_labels.txt sed 253q;d temp_labels.txt set rgb = sed "${li}q;d" roi256.1D sed 253q;d roi256.1D echo 241 roi241 0.47 0.96 0.15 1 end ConvertDset -overwrite -input 3dclusters_r2_is1_thr2100.niml.dset -dset_labels R -o temp_marked_clusters.1D MakeColorMap -usercolutfile tempcmap.txt -suma_cmap tempcmap -overwrite if ( 3dclusters_r2_is1_thr2100.nii == ) then [1] 61449 sleep 1 afni -npb 0 -pif DriveAfniElectrodes -echo_edu -niml -yesplugouts -dset /Volumes/SeagateBackupPlusDrive/local_tal/NIH102/tal/zloc/ALICE/CT/ct_implant.nii 3dclusters_r2_is1_thr2100.nii if -e surf_xyz.1D then setenv AFNI_OUTPLUG surf_xyz.1D setenv SUMA_OUTPLUG lastsurfout.txt [2] 61456 DriveSuma -npb 0 -pif DriveAfniElectrodes -echo_edu -com surf_cont -view_object_cont y suma -npb 0 -pif DriveAfniElectrodes -echo_edu -DSUMA_AllowDsetReplacement=YES -i 3dclusters_r2_is1_thr2100.gii -sv /Volumes/SeagateBackupPlusDrive/local_tal/NIH102/tal/zloc/ALICE/CT/ct_implant.nii
**SUMA_niml_call: Contacting on tcp:127.0.0.1:1032 (6), maximum wait 300.000 sec ** (You can change max. wait time with env. SUMA_DriveSumaMaxWait) ................................................................................................
^ This "....." just extends forever. I let it run overnight once just to see if it would eventually load but it crashed my computer. NOTE: this happens whether or not I run it through MATLAB or directly in the terminal.
I think this is the terminal output of the script you are running, just reformatted for posting using backticks as described here for ease of reading code with monospacing (I had to delete some double-asterisks, and I hope that didn't change any code within it):
set ind_label = `sed "${li}q;d" temp_labels.txt`
sed 252q;d temp_labels.txt
set rgb = `sed "${li}q;d" roi256.1D`
sed 252q;d roi256.1D
echo 239 roi239 0.85 0.02 0.46 1
end
set ind_label = `sed "${li}q;d" temp_labels.txt`
sed 253q;d temp_labels.txt
set rgb = `sed "${li}q;d" roi256.1D`
sed 253q;d roi256.1D
echo 241 roi241 0.47 0.96 0.15 1
end
ConvertDset -overwrite -input 3dclusters_r2_is1_thr2100.niml.dset -dset_labels R -o temp_marked_clusters.1D
MakeColorMap -usercolutfile tempcmap.txt -suma_cmap tempcmap -overwrite
if ( 3dclusters_r2_is1_thr2100.nii == ) then
[1] 61449
sleep 1
afni -npb 0 -pif DriveAfniElectrodes -echo_edu -niml -yesplugouts -dset /Volumes/SeagateBackupPlusDrive/local_tal/NIH102/tal/zloc/ALICE/CT/ct_implant.nii 3dclusters_r2_is1_thr2100.nii
if -e surf_xyz.1D then
setenv AFNI_OUTPLUG surf_xyz.1D
setenv SUMA_OUTPLUG lastsurfout.txt
[2] 61456
DriveSuma -npb 0 -pif DriveAfniElectrodes -echo_edu -com surf_cont -view_object_cont y
suma -npb 0 -pif DriveAfniElectrodes -echo_edu -DSUMA_AllowDsetReplacement=YES -i 3dclusters_r2_is1_thr2100.gii -sv /Volumes/SeagateBackupPlusDrive/local_tal/NIH102/tal/zloc/ALICE/CT/ct_implant.nii
+++ Command Echo:
DriveSuma -npb 0 -pif DriveAfniElectrodes -com surf_cont -view_object_cont y
SUMA_niml_call: Contacting on tcp:127.0.0.1:1032 (6), maximum wait 300.000 sec
(You can change max. wait time with env. SUMA_DriveSumaMaxWait)
................................................................................................
I notice some apparent process IDs (lines 16 and 22) and quotes that don't appear (line 15); it might be easier to see the script/code itself more directly, without output text.
To your actual question, I'm a little surprised to see DriveSuma ... occurring before suma .... should that order be different? Also, I think you will want a & at the end of your suma ... command, to allow other commands to take place.
Also, that version of AFNI is extremely old---4 years old now. I think it would be highly preferable for you to update, to take advantage of fixes and updates that have happened in the intervening times.
This mainly is done on macOS by building locally; I'm guess based on that AFNI version number that you have an Intel chip, so these would be the instructions for it.; ARM/Silicon build instructions are here, though.
My AFNI version is old but this has also happened on another computer that just had AFNI installed a few months ago. In that case, we are not sure what "fixed" it, it just seemed to resolve itself after a few days. On my computer, however, restarting AFNI/MATLAB/the computer has not helped. I can try to updateAFNI but am hesitant because we have a lot of very specific interactions and dependencies in our MATLAB pipeline.
I had the same thought about the output showing DriveSuma first, but the script has it the other way around. I was having trouble matching the script to the output line-by-line. The call to suma has "&" at the end of it (see below in the 2nd set of code for open_afni_suma.csh, line 106)
Here is the original MATLAB output with proper formatting:
set ind_label = `sed "${li}q;d" temp_labels.txt`
sed 360q;d temp_labels.txt
set rgb = `sed "${li}q;d" roi256.1D`
sed 360q;d roi256.1D
echo 354 roi354 1
end
set ind_label = `sed "${li}q;d" temp_labels.txt`
sed 361q;d temp_labels.txt
set rgb = `sed "${li}q;d" roi256.1D`
sed 361q;d roi256.1D
echo 360 roi360 1
end
ConvertDset -overwrite -input 3dclusters_r3_is1_thr2200.niml.dset -dset_labels R -o temp_marked_clusters.1D
MakeColorMap -usercolutfile tempcmap.txt -suma_cmap tempcmap -overwrite
if ( 3dclusters_r3_is1_thr2200.nii == ) then
[1] 68533
sleep 1
afni -npb 0 -pif DriveAfniElectrodes -echo_edu -niml -yesplugouts -dset /Volumes/SeagateBackupPlusDrive/local_tal/NIH113/tal/zloc/ALICE/CT/ct_implant.nii 3dclusters_r3_is1_thr2200.nii
if -e surf_xyz.1D then
setenv AFNI_OUTPLUG surf_xyz.1D
setenv SUMA_OUTPLUG lastsurfout.txt
[2] 68538
DriveSuma -npb 0 -pif DriveAfniElectrodes -echo_edu -com surf_cont -view_object_cont y
suma -npb 0 -pif DriveAfniElectrodes -echo_edu -DSUMA_AllowDsetReplacement=YES -i 3dclusters_r3_is1_thr2200.gii -sv /Volumes/SeagateBackupPlusDrive/local_tal/NIH113/tal/zloc/ALICE/CT/ct_implant.nii
+++ Command Echo:
DriveSuma -npb 0 -pif DriveAfniElectrodes -com surf_cont -view_object_cont y
SUMA_niml_call: Contacting on tcp:127.0.0.1:1032 (6), maximum wait 300.000 sec
(You can change max. wait time with env. SUMA_DriveSumaMaxWait)
..........................................................
Here is the complete script I was running (open_afni_suma.csh):
#!/bin/tcsh
# script to write out electrode positions
# assumes one has previously run this previous script and created the roi surfaces for all the electrodes
# with these commands
# tcsh @3dclustering -CT_path CT.nii -radius 4 -interelectrode_space 3 -clip_value 2999
# IsoSurface -isorois+dsets -mergerois+dset -autocrop -o_gii 3dclusters.gii -input 3dclusters_r?_is?.nii
set PIF = DriveAfniElectrodes #A string identifying programs launched by this script
@Quiet_Talkers -pif $PIF #Quiet previously launched programs
#Get a free line and tag programs from this script
set NPB = "-npb `afni -available_npb_quiet` -pif $PIF -echo_edu"
echo $NPB > ecognpb.txt
set surfcoords = "surf_xyz.1D" # record the electrode positions in a text file - this one gets the position at the surface
#set surfcoords_i = "surf_ixyz.1D" # record the electrode positions in a text file - this one gets the position at surface with index
set sumasurf = lastsurfout.txt
set ct = "CT+orig"
set clust_surf = "3dclusters.gii"
set clustset = ''
set cnt = 1
while ($cnt < $#argv)
if (("$argv[$cnt]" == "-help") || ("$argv[$cnt]" == "-h") || ("$argv[$cnt]" == "--help")) then
goto HELP
endif
if ("$argv[$cnt]" == "-CT_path") then
@ cnt ++
set ct = "$argv[$cnt]"
else if ("$argv[$cnt]" == "-clust_set") then
@ cnt ++
set clustset = "$argv[$cnt]"
else if ("$argv[$cnt]" == "-clust_surf") then
@ cnt ++
set clust_surf = "$argv[$cnt]"
else goto HELP
endif
@ cnt ++
end
####### START new code for el cluster shading v2.0 (MPBranco 300617)###########################
set clust_surf_base = `basename -s .gii $clust_surf`
set clust_niml_set = ${clust_surf_base}.niml.dset
rm lastsurfout.txt temproilist.txt
# make a temporary copy of the coloring dataset to recolor as we go
set nlabels = `3dinfo -labeltable $clust_niml_set | grep ni_dimen | awk -F\" '{print $2}'`
@ nlabels ++
# copy just the labels from the niml dset
3dinfo -labeltable $clust_niml_set | tail -$nlabels | grep -v VALUE_LABEL_DTABLE \
| tr -d \" > temp_labels.txt
MakeColorMap -std ROI_i256 |tail -256 > roi256.1D
# now create a proper SUMA compatible colormap by combining the two files
# index label RGBA
@ nlabels --
rm tempcmap.txt
foreach li (`count -digits 1 1 $nlabels`)
set ind_label = `sed "${li}q;d" temp_labels.txt`
set rgb = `sed "${li}q;d" roi256.1D`
# put them all together (RGB are fractional values, Alpha=1)
# index label R G B A
# 1 electrode_1 0.1 0.4 0.02 1
echo $ind_label $rgb 1 >> tempcmap.txt
end
# create a non-colored copy of the dataset - just nodes and cluster indices
ConvertDset -overwrite -input $clust_niml_set -dset_labels 'R' -o temp_marked_clusters.1D
# make color map used below and updated too
MakeColorMap -usercolutfile tempcmap.txt \
-suma_cmap tempcmap -overwrite >& /dev/null
# -sdset temp_marked_clusters.niml.dset \
####### END of new code for el cluster shading v2.0###########################
# if cluster dataset was not specified, try to find one
if ($clustset == '') then
set clustsets = (3dclusters_r?_is?.nii)
set clustset = $clustsets[0]
endif
afni $NPB -niml -yesplugouts -dset $ct $clustset >& ./afniout.log &
sleep 1
# delete copy of previous surface coordinates and region if it exists
if -e $surfcoords then
mv $surfcoords $surfcoords.old
# mv $surfcoords_i $surfcoords_i.old
endif
# coordinates sent to text file by AFNI with plugout xyz
setenv AFNI_OUTPLUG $surfcoords
# text output from suma driven command with cluster index with surface name
setenv SUMA_OUTPLUG $sumasurf
suma $NPB -DSUMA_AllowDsetReplacement=YES -i $clust_surf -sv $ct >& ./sumaout.log & #####edited for v2.0
DriveSuma $NPB -com surf_cont -view_object_cont y
# We need a way to click on the electrodes in the clinical order and
# find the correspondent center of mass coordinates in clst.1D file.
# The optimal output would be a txt file with four columns, namely:
# Number_of_the_cluster_in_clinical_order coord_x coord_y coord_z
plugout_drive $NPB \
-com 'SWITCH_SESSION A.afni' \
-com 'OPEN_WINDOW A.axialimage geom=600x600+416+44 \
ifrac=0.8 opacity=5' \
-com 'OPEN_WINDOW A.sagittalimage geom=+45+430 \
ifrac=0.8 opacity=5' \
-com "SWITCH_UNDERLAY $ct" \
-com "SWITCH_OVERLAY $clustset" \
-com 'SEE_OVERLAY +' \
-com "SET_OUTPLUG $surfcoords" \
-quit
# suma sends surface object output to a particular file
# and start talking to afni
DriveSuma $NPB \
-com viewer_cont -key t
# set l = `prompt_user -pause
####### START new code for el cluster shading v2.0 (MPBranco 300617)###########################
sleep 2
# update coloring to ROI_i256 instead of IsoSurface coloring (which might be the same anyway)
# and use copy of cluster niml dset for colors that gets updated below
DriveSuma $NPB -com surf_cont -load_dset temp_marked_clusters.1D.dset \
-surf_label $clust_surf
DriveSuma $NPB -com surf_cont -switch_dset temp_marked_clusters.1D.dset
DriveSuma $NPB -com surf_cont -load_cmap tempcmap.niml.cmap
DriveSuma $NPB -com surf_cont -switch_cmap tempcmap -Dim 0.6 \
-switch_cmode Dir -1_only Y
####### END new code for el cluster shading v2.0 (MPBranco 300617)###########################
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.