AFNI Message Board

Dear AFNI users-

We are very pleased to announce that the new AFNI Message Board framework is up! Please join us at:

https://discuss.afni.nimh.nih.gov

Existing user accounts have been migrated, so returning users can login by requesting a password reset. New users can create accounts, as well, through a standard account creation process. Please note that these setup emails might initially go to spam folders (esp. for NIH users!), so please check those locations in the beginning.

The current Message Board discussion threads have been migrated to the new framework. The current Message Board will remain visible, but read-only, for a little while.

Sincerely, AFNI HQ

History of AFNI updates  

|
April 13, 2021 03:44PM
Hi everyone,

I'm hoping you can help me with what I thought would be a simple tcsh script to loop through my subjects and run 3dmasksave and 3dROIstats on each. Here's my script:

#!/bin/tcsh
module load pkgsrc/2018Q3
module load pkgsrc/gcc-base
module load /directoryofafniprogram/07.17.2019

set datapath = /abunchofdirectories/
set output = /abunchofdirectories/outputdirectory 
set sublist = (`cat subslist.txt`)

foreach sub ($sublist)
	echo "You are on sub $sub"
	3dmaskave -mask dACC_sigmask.nii ${datapath}/BETA_Subject${sub}_Condition001_Measure002_Component001.nii > ${output}/sub${sub}_day1_dACC_beta.txt
	3dmaskave -mask dACC_sigmask.nii ${datapath}/BETA_Subject${sub}_Condition003_Measure002_Component001.nii > ${output}/sub${sub}_6mo_dACC_beta.txt
	3dROIstats -mask dACC_sigmask.nii 'final_PCLReexp_LME.nii[8]' > ${output}/sub${sub}_ROIstat.1D
	echo "sub $sub text file saved"
end


I am getting errors trying to set and loop through the sublist text file. For reference, the text file contents looks like this:

001
002
003
...


From the above script, the (`cat subslist.txt`) gives me the error:

>set: variable name must begin with a letter.

I have also tried loading the subslist.txt with the path name like this without changing the rest of the script and get the following error:

set sublist = abunchofdirectories/subslist.txt
>foreach: Words not parenthesized.

These are the main two errors I am getting, and I have tried just about every combination of parentheses, double quotes, single quotes, back quotes, etc. that I can think of and none of them seem to work. I have looked on other forum posts and the AFNI Unix guide and can't tell what I'm doing differently that is causing the issue. I'm hoping there's just something super simple that I'm not noticing, but any answers would be helpful!!

Thanks,

Kyrie Amara



Edited 1 time(s). Last edit at 04/13/2021 04:25PM by ptaylor.
Subject Author Posted

foreach loop errors

kyrieamara April 13, 2021 03:44PM

Re: foreach loop errors

ptaylor April 13, 2021 04:38PM

Re: foreach loop errors

kyrieamara April 13, 2021 05:15PM

Re: foreach loop errors

ptaylor April 14, 2021 09:05AM

Re: foreach loop errors

kyrieamara April 14, 2021 02:37PM

Re: foreach loop errors

kyrieamara April 14, 2021 05:23PM

Re: foreach loop errors

ptaylor April 14, 2021 05:39PM

Re: foreach loop errors

ptaylor April 14, 2021 05:37PM

Re: foreach loop errors

kyrieamara April 14, 2021 05:45PM

Re: foreach loop errors

Pawel April 14, 2021 11:54AM

Re: foreach loop errors

kyrieamara April 14, 2021 02:40PM