Skip to content

Instantly share code, notes, and snippets.

@njvack
Created May 23, 2014 20:07
Show Gist options
  • Save njvack/1064d4d67ced55adb943 to your computer and use it in GitHub Desktop.
Save njvack/1064d4d67ced55adb943 to your computer and use it in GitHub Desktop.
Upload gating files from a GE MRI scanner
#!/bin/bash
GATING_DIR=${GATING_DIR:-/usr/g/service/log/gating}
DEST_BASE=${DEST_BASE:-/mri-upload/ge_physio}
MAX_AGE_MINUTES=${3:-120}
study=$1
ppt=$2
if [[ "${study}" == "" ]] || [[ "${ppt}" == "" ]] || [[ "${study}" == "-h" ]]; then
cat <<EOF
Usage: upload_gating_files <study> <participant> (<max_age_minutes>)
Moves files up to max_age_minutes old (default: 120) from
${GATING_DIR} into ${DEST_BASE}.
From there, they'll be put in /study/raw-data/<study>/<participant>/ge_physio.
EOF
exit 1
fi
if [[ ! -d "${TARGET_DIR}" ]]; then
mount /mri-upload
fi
matches=$(find "${GATING_DIR}" -type f -mmin -${MAX_AGE_MINUTES})
if [[ "${matches}" == "" ]]; then
echo "No matching files found!"
exit 2
fi
ppt_dir="ge_physio^${study}^${ppt}/"
mkdir -p "${DEST_BASE}/.${ppt_dir}"
for f in ${matches}; do
echo "Moving ${f}"
mv "${f}" "${DEST_BASE}/.${ppt_dir}"
done
mv "${DEST_BASE}/.${ppt_dir}" "${DEST_BASE}/${ppt_dir}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment