QSIprep一键脚本

详见细节,尚不完善,如有需求会更新更自动化的版本

# 设定基本参数
# 均为bids上级目录
or_dir=/data/disk1/zhangyi/Prep_LGStroke/Control
root_dir=/data/disk1/zhangyi/LGStroke/prep/Control

# 转移数据
mkdir -p $root_dir
cd $root_dir
cp -r ${or_dir}/bids ${root_dir}/bids

# 生成脚本
mkdir -p shell
mkdir -p log
mkdir -p prep_result

# 注意,此处sh文件内最好只有qsiprep这个命令,否则rm这样的命令会导致qsiprep以root权限执行,出现权限错误
rm -rf log/* prep_result/*
for SubName in `ls bids|grep sub`
do \
    rm -rf ${root_dir}/prep_result/$SubName
    rm -rf ${root_dir}/log/${SubName}.log
    BidsDir=${root_dir}/bids
    OutPutDir=${root_dir}/prep_result/$SubName
    WorkDir=${OutPutDir}/workdir
    mkdir -p $WorkDir
    mkdir -p ${OutPutDir}/qsiprep
    fs_license=/opt/software/freesurfer/license.txt
    echo "qsiprep-docker $BidsDir \
               $OutPutDir \
               --participant_label $SubName \
               --user $(id -u):$(id -g) \
               --use-syn-sdc \
               --force-syn \
               --output-resolution 2 \
               -w $WorkDir \
               --longitudinal \
               --fs-license-file $fs_license > ${root_dir}/log/${SubName}.log 2>&1" > shell/${SubName}.sh 
done

# 提交脚本
# qsiprep我试验提交无效,所以用下面的方法手动运行
# -o -e 选项无效
# -o ${root_dir}/log/qsub_o_${SubName}.log -o ${root_dir}/qsub_e_${SubName}.log 
for SubName in `ls shell`
do qsub -q long -l nodes=1:ppn=7 shell/$SubName 
done

# 由于莫名问题手动运行sh文件
rm screen.sh
for SubName in `ls bids|grep sub`
do \
    echo "SubName=${SubName}" >> screen.sh
    echo "screen -dmS \$SubName" >> screen.sh
    echo "screen -x -S \$SubName -p 0 -X stuff 'bash $root_dir/shell/${SubName}.sh\n'" >> screen.sh
done
for SubName in `ls bids|grep sub`
do \
echo "screen -S ${SubName} -X quit" >> screen.sh
done
cat screen.sh

# 检查运行结果
# 目前没有更好的运行结果检测方式
for sublog in `ls log`
do \
    wce=`cat log/${sublog}|grep -e error -e Error|wc -l`
    wct=`cat log/${sublog}|grep -e Trace|wc -l`
    echo $sublog $wce $wct
done  |grep -v "0 0"

find prep_result/|grep html|grep qsiprep|grep -v workdir|wc

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注