Skip to content

Commit

Permalink
optimized structure
Browse files Browse the repository at this point in the history
  • Loading branch information
haililihai committed Jan 18, 2017
1 parent 7124ce0 commit a8b1b85
Show file tree
Hide file tree
Showing 10 changed files with 878 additions and 846 deletions.
4 changes: 2 additions & 2 deletions 1_ROI_registration_spm.sh
Expand Up @@ -26,11 +26,11 @@ ${COMMAND_MATLAB} -nodisplay -nosplash -r "addpath('${PIPELINE}');addpath('${SPM

for sub in `cat ${SUB_LIST}`
do
if [ "${LEFT}" == "1" ]; then
if [ "${LEFT}" = "1" ]; then
mv ${WD}/${sub}/w${ROI}_L.nii ${WD}/${sub}/${sub}_${ROI}_L_DTI.nii
gzip ${WD}/${sub}/${sub}_${ROI}_L_DTI.nii
fi
if [ "${RIGHT}" == "1" ]; then
if [ "${RIGHT}" = "1" ]; then
mv ${WD}/${sub}/w${ROI}_R.nii ${WD}/${sub}/${sub}_${ROI}_R_DTI.nii
gzip ${WD}/${sub}/${sub}_${ROI}_R_DTI.nii
fi
Expand Down
64 changes: 47 additions & 17 deletions 3_ROI_probtrackx.sh
Expand Up @@ -24,57 +24,87 @@ shift
RIGHT=$1

# create a directory to check the status
if [ -d ${WD}/qsub_jobdone ]
if [ -d ${WD}/probtrackx_jobdone ]
then
rm -rf ${WD}/qsub_jobdone
mkdir -p ${WD}/qsub_jobdone
rm -rf ${WD}/probtrackx_jobdone
mkdir -p ${WD}/probtrackx_jobdone
else
mkdir -p ${WD}/qsub_jobdone
mkdir -p ${WD}/probtrackx_jobdone
fi

# path correction options
if [ "${DIS_COR}" = "1" ];then
DIS_COR=--pd
else
DIS_COR=
fi

# grid engine using qsub or fsl_sub
if [ "${GE}" = 1 ]; then

for sub in $(cat ${SUB_LIST})
do
# single voxel probtrackx
if [ "${LEFT}" == "1" ]; then
if [ "${LEFT}" = "1" ]; then
job_id=$(${COMMAND_FSLSUB} -l ${WD}/log ${COMMAND_PROBTRACKX} --mode=simple --seedref=${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask -o ${ROI}_L -x ${WD}/${sub}/${sub}_${ROI}_L_coord.txt -l ${DIS_COR} -c ${CUR_THRES} -S ${N_STEPS} --steplength=${LEN_STEP} -P ${N_SAMPLES} --forcedir --opd -s ${DATA_DIR}/${sub}/DTI.bedpostX/merged -m ${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask --dir=${WD}/${sub}/${sub}_${ROI}_L_probtrackx &)
echo "${sub}_L probtrackx is running...! job_ID is ${job_id}"
mute=$(${COMMAND_FSLSUB} -j ${job_id} -N running... -l ${WD}/log touch ${WD}/qsub_jobdone/${sub}_L.jobdone)
mute=$(${COMMAND_FSLSUB} -j ${job_id} -N running... -l ${WD}/log touch ${WD}/probtrackx_jobdone/${sub}_L.jobdone)
fi

if [ "${RIGHT}" == "1" ]; then
if [ "${RIGHT}" = "1" ]; then
job_id=$(${COMMAND_FSLSUB} -l ${WD}/log ${COMMAND_PROBTRACKX} --mode=simple --seedref=${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask -o ${ROI}_R -x ${WD}/${sub}/${sub}_${ROI}_R_coord.txt -l ${DIS_COR} -c ${CUR_THRES} -S ${N_STEPS} --steplength=${LEN_STEP} -P ${N_SAMPLES} --forcedir --opd -s ${DATA_DIR}/${sub}/DTI.bedpostX/merged -m ${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask --dir=${WD}/${sub}/${sub}_${ROI}_R_probtrackx &)
echo "${sub}_R probtrackx is running...! job_ID is ${job_id}"
mute=$(${COMMAND_FSLSUB} -j ${job_id} -N running... -l ${WD}/log touch ${WD}/qsub_jobdone/${sub}_R.jobdone)
mute=$(${COMMAND_FSLSUB} -j ${job_id} -N running... -l ${WD}/log touch ${WD}/probtrackx_jobdone/${sub}_R.jobdone)
fi

done # end of GE=1
else
idx=0
for sub in $(cat ${SUB_LIST})
do
if [ "${LEFT}" = "1" ]; then
idx=$((idx+1))
( ${COMMAND_PROBTRACKX} --mode=simple --seedref=${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask -o ${ROI}_L -x ${WD}/${sub}/${sub}_${ROI}_L_coord.txt -l ${DIS_COR} -c ${CUR_THRES} -S ${N_STEPS} --steplength=${LEN_STEP} -P ${N_SAMPLES} --forcedir --opd -s ${DATA_DIR}/${sub}/DTI.bedpostX/merged -m ${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask --dir=${WD}/${sub}/${sub}_${ROI}_L_probtrackx && touch ${WD}/probtrackx_jobdone/${sub}_L.jobdone && echo ">> ${sub}_L probtrackx is Done!" )& echo ">> ${sub}_L probtrackx is running...! PID is $!"
if [ $(($idx%${POOLSIZE})) = "0" ];then
wait
fi
fi

if [ "${RIGHT}" = "1" ]; then
idx=$((idx+1))
( ${COMMAND_PROBTRACKX} --mode=simple --seedref=${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask -o ${ROI}_R -x ${WD}/${sub}/${sub}_${ROI}_R_coord.txt -l ${DIS_COR} -c ${CUR_THRES} -S ${N_STEPS} --steplength=${LEN_STEP} -P ${N_SAMPLES} --forcedir --opd -s ${DATA_DIR}/${sub}/DTI.bedpostX/merged -m ${DATA_DIR}/${sub}/DTI.bedpostX/nodif_brain_mask --dir=${WD}/${sub}/${sub}_${ROI}_R_probtrackx && touch ${WD}/probtrackx_jobdone/${sub}_R.jobdone && echo ">> ${sub}_R probtrackx is Done!" )& echo ">> ${sub}_R probtrackx is running...! PID is $!"
if [ $(($idx%${POOLSIZE})) = "0" ];then
wait
fi
fi

done
wait
fi # end of GE


# check whether the tasks are finished or not
N=$(cat ${SUB_LIST}|wc -l)
if [ "${LEFT}" == "1" -a "${RIGHT}" == "0" ]
if [ "${LEFT}" = "1" -a "${RIGHT}" = "0" ]
then
while [ "$(ls ${WD}/qsub_jobdone|wc -l)" != "${N}" ]
while [ "$(ls ${WD}/probtrackx_jobdone|wc -l)" != "${N}" ]
do
sleep 30s
done
fi

if [ "${LEFT}" == "0" -a "${RIGHT}" == "1" ]
if [ "${LEFT}" = "0" -a "${RIGHT}" = "1" ]
then
while [ "$(ls ${WD}/qsub_jobdone|wc -l)" != "${N}" ]
while [ "$(ls ${WD}/probtrackx_jobdone|wc -l)" != "${N}" ]
do
sleep 30s
done
fi

if [ "${LEFT}" == "1" -a "${RIGHT}" == "1" ]
if [ "${LEFT}" = "1" -a "${RIGHT}" = "1" ]
then
while [ "$(ls ${WD}/qsub_jobdone|wc -l)" != "$((${N}*2))" ]
while [ "$(ls ${WD}/probtrackx_jobdone|wc -l)" != "$((${N}*2))" ]
do
sleep 30s
done
fi

echo "=========== Finally Probtrackx All Done!! ==========="
echo "====== Finally Probtrackx All Done!! ======"
4 changes: 2 additions & 2 deletions 6_ROI_toMNI_spm.sh
Expand Up @@ -34,12 +34,12 @@ do
mkdir -p ${WD}/${sub}/${sub}_${ROI}_R_${METHOD}/${VOX_SIZE}mm
for num in $(seq 2 ${MAX_CL_NUM})
do
if [ "${LEFT}" == "1" ]; then
if [ "${LEFT}" = "1" ]; then

mv ${WD}/${sub}/${sub}_${ROI}_L_${METHOD}/w${ROI}_L_${num}.nii ${WD}/${sub}/${sub}_${ROI}_L_${METHOD}/${VOX_SIZE}mm/${VOX_SIZE}mm_${ROI}_L_${num}_MNI.nii
gzip ${WD}/${sub}/${sub}_${ROI}_L_${METHOD}/${VOX_SIZE}mm/${VOX_SIZE}mm_${ROI}_L_${num}_MNI.nii
fi
if [ "${RIGHT}" == "1" ]; then
if [ "${RIGHT}" = "1" ]; then
mv ${WD}/${sub}/${sub}_${ROI}_R_${METHOD}/w${ROI}_R_${num}.nii ${WD}/${sub}/${sub}_${ROI}_R_${METHOD}/${VOX_SIZE}mm/${VOX_SIZE}mm_${ROI}_R_${num}_MNI.nii
gzip ${WD}/${sub}/${sub}_${ROI}_R_${METHOD}/${VOX_SIZE}mm/${VOX_SIZE}mm_${ROI}_R_${num}_MNI.nii
fi
Expand Down
6 changes: 3 additions & 3 deletions 7_group_refer.sh
Expand Up @@ -24,15 +24,15 @@ shift
RIGHT=$1


if [ "${LEFT}" == "1" ] && [ "${RIGHT}" == "0" ]
if [ "${LEFT}" = "1" ] && [ "${RIGHT}" = "0" ]
then
${COMMAND_MATLAB} -nodisplay -nosplash -r "addpath('${PIPELINE}');addpath('${NIFTI}');group_refer_xmm('${WD}','${ROI}','${SUB_LIST}',${MAX_CL_NUM},'${METHOD}',${VOX_SIZE},${GROUP_THRES},1);exit" &
wait
elif [ "${LEFT}" == "0" ] && [ "${RIGHT}" == "1" ]
elif [ "${LEFT}" = "0" ] && [ "${RIGHT}" = "1" ]
then
${COMMAND_MATLAB} -nodisplay -nosplash -r "addpath('${PIPELINE}');addpath('${NIFTI}');group_refer_xmm('${WD}','${ROI}','${SUB_LIST}',${MAX_CL_NUM},'${METHOD}',${VOX_SIZE},${GROUP_THRES},0);exit" &
wait
elif [ "${LEFT}" == "1" ] && [ "${RIGHT}" == "1" ]
elif [ "${LEFT}" = "1" ] && [ "${RIGHT}" = "1" ]
then
${COMMAND_MATLAB} -nodisplay -nosplash -r "addpath('${PIPELINE}');addpath('${NIFTI}');group_refer_xmm('${WD}','${ROI}','${SUB_LIST}',${MAX_CL_NUM},'${METHOD}',${VOX_SIZE},${GROUP_THRES},1);exit" &
${COMMAND_MATLAB} -nodisplay -nosplash -r "addpath('${PIPELINE}');addpath('${NIFTI}');group_refer_xmm('${WD}','${ROI}','${SUB_LIST}',${MAX_CL_NUM},'${METHOD}',${VOX_SIZE},${GROUP_THRES},0);exit" &
Expand Down

0 comments on commit a8b1b85

Please sign in to comment.