dcmtonii.sh将磁共振数据DCM格式转为NIFT
2023-02-17 本文已影响0人
养猪场小老板
第一步:新建shell
vi dcmtonii.sh
里面的内容如下
#!/bin/bash
#dcm目录
dcm_path="/home/mcbrain/sharefolder/dti_dcm"
#nii目录
nii_path="/home/mcbrain/sharefolder/dti_nii"
ls $dcm_path |while read line;do
mkdir -p ${nii_path}/$line/Dwi
#mv ${dcm_path}/$line/x*.nii.gz ${nii_path}/$line/
dcm2nii -z y -o "${nii_path}/$line/Dwi/" "${dcm_path}/$line/Dwi/"
target_file=`ls ${nii_path}/$line/Dwi/x*.nii.gz|head -n 1`
mv ${target_file} ${nii_path}/$line/Dwi/$line.nii.gz
done
第二步:给新建的shell加上权限
chmod +x dcmtonii.sh
第三步:运行
bash dcmtonii.sh