-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added option for auto checking and updating of project downloads
- Loading branch information
Showing
3 changed files
with
296 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,202 @@ | ||
proj=$1 | ||
subid=$2 | ||
|
||
if [[ $proj == "ABCD_NDAR" ]]; then | ||
tmp_label=$subid | ||
if [[ $tmp_label == "1" ]]; then | ||
sub="YCW83AC7" | ||
sess="S1" | ||
elif [[ $tmp_label == "S1" ]]; then | ||
sub="INV6F1LPHLT" | ||
sess="S1" | ||
elif [[ $tmp_label == "S_1" ]]; then | ||
sub="FDM0PRRA" | ||
sess="S1" | ||
else | ||
sub=$subid | ||
if [[ $sub == *_S* ]]; then | ||
sess=S${sub##*_S} | ||
sub=${sub%_S*} | ||
elif [[ $sub == *-S* ]]; then | ||
sess=S${sub##*-S} | ||
sub=${sub%-S*} | ||
else | ||
sess="S1" | ||
fi | ||
fi | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Parra_MMMM" ]]; then | ||
sub=${subid#$proj-} | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Pettit_tDCS" ]]; then | ||
sub=${subid#$proj-} | ||
sess=${sub##*_} | ||
sub=${sub%_*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Sibley_Teen" ]]; then | ||
if [[ $subid == *Sibley_TEEN* ]]; then | ||
sub=${subid#Sibley_TEEN-} | ||
else | ||
sub=${subid#$proj-} | ||
fi | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Sutherland_MIP" ]]; then | ||
sub=${subid#$proj-} | ||
sess=S${sub##*S} | ||
if [[ $sub == *-S* ]]; then | ||
sub=${sub%-*} | ||
else | ||
sub=${sub%S*} | ||
fi | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Sutherland_ACE" ]]; then | ||
sub=${subid#$proj-} | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Soto_GRT" ]]; then | ||
sub=${subid#$proj-} | ||
if [[ $sub == *0003S1-S1 ]]; then | ||
sub=${sub%-*} | ||
sess="S1" | ||
elif [[ $sub == *0003S1-S2 ]]; then | ||
sub=${sub%-*} | ||
sess="S2" | ||
elif [[ $sub == *0003S2-S2 ]]; then | ||
sub=${sub%-*} | ||
sess="S3" | ||
elif [[ $sub == *0003-S1-S1 ]]; then | ||
sub=${sub%-*} | ||
sub=${sub%-*} | ||
sess="S4" | ||
elif [[ $sub == *0003-S2-S2 ]]; then | ||
sub=${sub%-*} | ||
sub=${sub%-*} | ||
sess="S5" | ||
elif [[ $sub == *0003S3-S3 ]]; then | ||
sub=${sub%-*} | ||
sess="S6" | ||
elif [[ $sub == *0003S4-S4 ]]; then | ||
sub=${sub%-*} | ||
sess="S7" | ||
else | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
if [[ $sub == *-S* ]]; then | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
elif [[ $sub == *S* ]]; then | ||
sub=${sub%S*} | ||
fi | ||
fi | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Dick_AHEAD" ]]; then | ||
sub=${subid##*$proj-} | ||
if [[ $sub == *_S1 ]]; then | ||
if [[ $sub == *-2_S1 ]]; then | ||
sess="S2" | ||
sub=${sub%-2_S1*} | ||
else | ||
sess="S1" | ||
sub=${sub%-_*} | ||
fi | ||
elif [[ $sub == *_1 ]]; then | ||
echo $subid >> $data_qc/qc-processed/$proj-processed | ||
proj_data=$(cat $data_qc/qc-processed/$proj-processed) | ||
continue | ||
else | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
if [[ $sub == *-S* ]]; then | ||
if [[ $sub != *-ST* ]]; then | ||
sub=${sub%-*} | ||
fi | ||
fi | ||
fi | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Dick_TRAIN" ]]; then | ||
sub=${subid#$proj-} | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "Mattfeld_RTV" ]]; then | ||
sub=${subid#$proj-} | ||
sess=${sub##*-} | ||
if [[ $sess != S* ]]; then | ||
sub=$sub-S1 | ||
sess=${sub##*-} | ||
fi | ||
sub=${sub%-*} | ||
sub=$(echo ${sub//[-_]/}) | ||
elif [[ $proj == "McMakin_EMU" ]]; then | ||
tmp_label=$subid | ||
if [[ $tmp_label == "McMakin_EMU_R01_PT-S1-S1" ]]; then | ||
sub="R01_PT" | ||
sess="S1" | ||
elif [[ $tmp_label == "1" ]]; then | ||
sub="000-1001" | ||
sess="S1" | ||
elif [[ $tmp_label == "2" ]]; then | ||
sub="000-1005" | ||
sess="S2" | ||
elif [[ $tmp_label == "S_1" ]]; then | ||
sub="000-1004" | ||
sess="S1" | ||
elif [[ $tmp_label == "S_2" ]]; then | ||
sub="000-1004" | ||
sess="S2" | ||
else | ||
if [[ $tmp_label == MCMAKIN_EMU* ]]; then | ||
sub=${subid#MCMAKIN_EMU-} | ||
else | ||
sub=${subid#$proj-} | ||
fi | ||
if [[ $sub == *_Day2* ]]; then | ||
sess="S2" | ||
sub=${sub%_*} | ||
elif [[ $sub == *_1-S1 ]]; then | ||
sess="S1" | ||
sub=${sub%_*} | ||
elif [[ $sub == *_2-S2 ]]; then | ||
sess="S2" | ||
sub=${sub%_*} | ||
elif [[ $sub == *_1 ]]; then | ||
sess="S1" | ||
sub=${sub%_*} | ||
if [[ $sub == *_* ]]; then | ||
sub=${sub%_*} | ||
fi | ||
elif [[ $sub == *_2 ]]; then | ||
sess="S2" | ||
sub=${sub%_*} | ||
if [[ $sub == *_* ]]; then | ||
sub=${sub%_*} | ||
fi | ||
elif [[ $sub == *_S1 ]]; then | ||
sess="S1" | ||
sub=${sub%_*} | ||
elif [[ $sub == *_S2 ]]; then | ||
sess="S2" | ||
sub=${sub%_*} | ||
else | ||
sess=${sub##*-} | ||
sub=${sub%-*} | ||
if [[ $sub == *-S* ]]; then | ||
sub=${sub%-*} | ||
elif [[ $sub == *S* ]]; then | ||
sub=${sub%S*} | ||
fi | ||
fi | ||
fi | ||
sub=$(echo ${sub//[-_]/}) | ||
if [[ $sub == "000" ]]; then | ||
sub="0001002" | ||
sess="S3" | ||
fi | ||
fi | ||
|
||
echo $sub $sess |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,95 @@ | ||
if [ ! -e ~/xnatpassfile ]; then | ||
if [ ! -e ~/xnatpassfile ] & [ ! -e ~/xnatconfigfile ]; then | ||
read -p 'Username: ' uservar | ||
read -sp 'Password: ' passvar | ||
printf "{\"password\": \"$passvar\", \"user\": \"$uservar\", \"server\": \"http://xnat.fiu.edu\"}" > ~/xnatpassfile | ||
printf "{\"password\": \"$passvar\", \"user\": \"$uservar\", \"server\": \"http://xnat.fiu.edu\"}" > ~/xnatconfigfile | ||
printf "+$uservar@http://xnat.fiu.edu:8080/xnat=$passvar" > ~/xnatpassfile | ||
fi | ||
|
||
|
||
while [[ $# -gt 0 ]]; do | ||
case $1 in | ||
-a|--auto) autocheck="$2"; shift;; | ||
-p|--project) proj="$2" ; shift;; | ||
-c|--credentials) passfile="$2" ; shift;; | ||
-o|--outputdir) outdir="$2" ; shift;; | ||
-s|--session) sess="$2" ; shift;; | ||
-s|--session) expsess="$2" ; shift;; | ||
(--) shift; break;; | ||
(-*) echo "$0: error - unrecognized option $1. Try $0 -h" 1>&2; exit 1;; | ||
(*) break;; | ||
esac | ||
shift | ||
done | ||
|
||
if [ -e ~/xnatpassfile ]; then | ||
/xget-public/xget -passfile $passfile -s $sess -o $outdir -proj $proj | ||
function download_experiment { | ||
|
||
# create a temporary directory with the subject filters | ||
# if the temporary directory exists (it should not), create it | ||
if [ ! -d $outdir/$proj ]; then | ||
mkdir -p $outdir/$proj | ||
fi | ||
|
||
# download the subject file into the temporary directory | ||
/xget-public/xget -passfile ~/xnatpassfile -s ${exps[i]} -o $outdir/$proj -proj $proj | ||
unzip $outdir/$proj/${exps[i]}_acq.zip -d $outdir/$proj/ | ||
rm $outdir/$proj/${exps[i]}_acq.zip | ||
tar -C $outdir/$proj/${labels[i]} -cf $outdir/$proj/sub-"$sub"_ses-${sess}.tar scans/ | ||
rm -r $outdir/$proj/${labels[i]} | ||
printf "sub-%s_ses-%s.tar\n" $sub $sess >> ~/XNAT-data-transfer/$proj-processed | ||
|
||
# get date and time | ||
date_time= | ||
date_time=$(date) | ||
# append the email message | ||
echo "Data transferred from XNAT to FIU-HPC for Project: $proj Subject: $sub Session: $sess on $date_time" >> ~/XNAT-data-transfer/$proj-processed-message | ||
|
||
} | ||
|
||
# call a python script to get a list of experiments in the XNAT project | ||
exps=($(python /scripts/xnat_list.py ~/xnatconfigfile $proj 'experiments')) | ||
labels=($(python /scripts/xnat_list.py ~/xnatconfigfile $proj 'labels')) | ||
|
||
#for each subject identified | ||
for ((i=0;i<${#exps[@]};i++)); do | ||
labelinfo=($(bash /scripts/sub_sess_id.sh $proj ${labels[i]})) | ||
sub=${labelinfo[0]} | ||
sess=${labelinfo[1]} | ||
if [[ $autocheck == "y" ]] | [[ $autocheck == "yes" ]]; then | ||
|
||
if [ -e ~/XNAT-data-transfer/$proj-processed ]; then | ||
proj_data=`cat ~/XNAT-data-transfer/$proj-processed` | ||
# if the subject has not previously been processed | ||
if [[ $proj_data != *sub-"$sub"_ses-"$sess".tar* ]]; then | ||
download_experiment | ||
fi | ||
else | ||
mkdir ~/XNAT-data-transfer | ||
download_experiment | ||
fi | ||
|
||
else | ||
if [[ $expsess == XNAT_* ]]; then | ||
if [[ ${exps[i]} == $expsess ]]; then | ||
if [ ! -e ~/XNAT-data-transfer/$proj-processed ]; then | ||
mkdir ~/XNAT-data-transfer | ||
else | ||
proj_data=`cat ~/XNAT-data-transfer/$proj-processed` | ||
if [[ $proj_data != *sub-"$sub"_ses-"$sess".tar* ]]; then | ||
download_experiment | ||
else | ||
echo "Experiment session has already been downloaded!" | ||
exit | ||
fi | ||
fi | ||
else | ||
echo "Experiment session '$expsess' is not in project '$proj'!" | ||
exit | ||
fi | ||
else | ||
echo "Experiment session should start with 'XNAT_*'!" | ||
exit | ||
fi | ||
fi | ||
done | ||
|
||
if [ -e ~/XNAT-data-transfer/$proj-processed-message ]; then | ||
mail -s 'FIU XNAT-HPC Data Transfer Update Project $proj' $USER@fiu.edu < ~/XNAT-data-transfer/$proj-processed-message | ||
rm ~/XNAT-data-transfer/$proj-processed-message | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env python | ||
from pyxnat import Interface | ||
import sys | ||
|
||
config_file = sys.argv[1] | ||
project = sys.argv[2] | ||
ref = sys.argv[3] | ||
|
||
central = Interface(config=config_file) | ||
select_exp = '/projects/' + project +'/experiments' | ||
exps = central.select(select_exp).get() | ||
if ref == 'experiments': | ||
print " ".join([str(x) for x in exps]) | ||
elif ref == 'labels': | ||
print " ".join([central.select(select_exp + '/' + x).label() for x in exps]) |