Commit 6b2f5ec2 authored by Alberto Lazari's avatar Alberto Lazari
Browse files

added initial scripts

parent 1187a62c
#!/usr/bin/env bash
# definitions
workDir=/vols/Scratch/myelin/Mohamed/Merima_data_firstbatch_imported
scriptDir=/vols/Scratch/alazari/preclinicalMPM_scripts
mncDir=/vols/Scratch/myelin/Mohamed/Merima_data_firstbatch_imported/MNC
mkdir -p $mncDir
mkdir -p $mncDir/T2w
mkdir -p $mncDir/DWI
exportDir=/vols/Scratch/myelin/Mohamed/Merima_data_firstbatch_imported/Export
mkdir -p $exportDir
mkdir -p $exportDir/T2w
mkdir -p $exportDir/DWI
subjList="MS81_3_20200903"
#"MS81_3_20200903"
# "MS81_10_20200904
# MS82_3_20200914
# MS86_10_20200924
# MS81_1_20200901
# MS82_N_20200911
# MS86_1_20200921
# MS81_3_20200903
# MS84_10_20200918
# MS86_3_20200923
# MS81_N_20200907
# MS84_1_20200916
# MS86_N_20200925
# MS82_10_20200915
# MS84_3_20200917
# MS82_1_20200910
# MS84_N_20200909"
module add minc-toolkit-v1
for subj in $subjList; do
echo "conversion to mnc format for $subj"
# /vols/Data/postmort/dSSFP_process/bin/dSSFP_preprocess/unring $workDir/"$subj"/T2w/MS81_3_Merima_Doldcr_T2w_Diffusion_Part2_7_1_1.nii $workDir/"$subj"/T2w/"$subj"_T2w_anat_unringed
/vols/Data/postmort/dSSFP_process/bin/dSSFP_preprocess/unring $workDir/"$subj"/T2w/"$subj"_T2w_anat.nii $workDir/"$subj"/T2w/"$subj"_T2w_anat_unringed
cp $workDir/"$subj"/T2w/"$subj"_T2w_anat_unringed.nii.gz $exportDir/T2w/"$subj"_T2w_anat_unringed.nii.gz
# cp $workDir/"$subj"/dtifit/"$subj"_FA.nii.gz $exportDir/DWI/"$subj"_FA.nii.gz
# cp $workDir/"$subj"/dtifit/"$subj"_MD.nii.gz $exportDir/DWI/"$subj"_MD.nii.gz
# cp $workDir/"$subj"/DWI_all/b0_mean.nii.gz $exportDir/DWI/"$subj"_b0_mean.nii.gz
# nii2mnc -quiet -signed -float $workDir/"$subj"/T2w/"$subj"_T2w_anat.nii $mncDir/T2w/"$subj"_T2w_anat.mnc
#
# nii2mnc -quiet -signed -float $workDir/"$subj"/dtifit/"$subj"_FA.nii.gz $mncDir/DWI/"$subj"_FA.mnc
# nii2mnc -quiet -signed -float $workDir/"$subj"/dtifit/"$subj"_MD.nii.gz $mncDir/DWI/"$subj"_MD.mnc
# nii2mnc -quiet -signed -float $workDir/"$subj"/DWI_all/b0_mean.nii.gz $mncDir/DWI/"$subj"_b0_mean.mnc
echo "done"
done
#!/usr/bin/env bash
# definitions
workDir=/vols/Scratch/myelin/Mohamed/Merima_data_firstbatch_imported
scriptDir=/vols/Scratch/alazari/preclinicalMPM_scripts/
subjList="MS81_10_20200904"
# "MS81_10_20200904
# MS82_3_20200914
# MS86_10_20200924
# MS81_1_20200901
# MS82_N_20200911
# MS86_1_20200921
# MS81_3_20200903
# MS84_10_20200918
# MS86_3_20200923
# MS81_N_20200907
# MS84_1_20200916
# MS86_N_20200925
# MS82_10_20200915
# MS84_3_20200917
# MS82_1_20200910
# MS84_N_20200909"
for subj in $subjList; do
echo "preprocessing diffusion for $subj"
# merge all scans
for i in {1..32}; do
printf "$workDir/"$subj"/DWI2/*_1_${i}.nii " >> $workDir/"$subj"/DWI_filenames
done
for i in {1..32}; do
printf "$workDir/"$subj"/DWI3/*_1_${i}.nii " >> $workDir/"$subj"/DWI_filenames
done
filelist=`cat $workDir/"$subj"/DWI_filenames`
fslmerge -t $workDir/data_merged $filelist
# cp $workDir/"$subj"_Merima_Doldcr_T2w_Diffusion/"$numberT2w"/pdata/1/nifti/*.nii $outDir/"$subj"/T2w/"$subj"_T2w_anat.nii
#
# cp $workDir/"$subj"_Merima_Doldcr_T2w_Diffusion/"$numberQSM"/pdata/1/nifti/*.nii $outDir/"$subj"/QSM
#
#
# cp $workDir/"$subj"_Merima_Doldcr_T2w_Diffusion/"$numberDWI1"/pdata/1/nifti/*.nii $outDir/"$subj"/DWI1
#
# cp $workDir/"$subj"_Merima_Doldcr_T2w_Diffusion/"$numberDWI2"/pdata/1/nifti/*.nii $outDir/"$subj"/DWI2
#
#
# cp $workDir/"$subj"_Merima_Doldcr_T2w_Diffusion/"$numberDWI3"/pdata/1/nifti/*.nii $outDir/"$subj"/DWI3
echo "done"
done
#!/usr/bin/env bash
# definitions
workDir=/vols/Scratch/myelin/Mohamed/Merima_data_firstbatch_imported
scriptDir=/vols/Scratch/alazari/preclinicalMPM_scripts
subjList="MS81_10_20200904
MS82_3_20200914
MS86_10_20200924
MS81_1_20200901
MS82_N_20200911
MS86_1_20200921
MS81_3_20200903
MS84_10_20200918
MS86_3_20200923
MS81_N_20200907
MS84_1_20200916
MS86_N_20200925
MS82_10_20200915
MS84_3_20200917
MS82_1_20200910
MS84_N_20200909"
# "MS81_10_20200904
# MS82_3_20200914
# MS86_10_20200924
# MS81_1_20200901
# MS82_N_20200911
# MS86_1_20200921
# MS81_3_20200903
# MS84_10_20200918
# MS86_3_20200923
# MS81_N_20200907
# MS84_1_20200916
# MS86_N_20200925
# MS82_10_20200915
# MS84_3_20200917
# MS82_1_20200910
# MS84_N_20200909"
for subj in $subjList; do
echo "preprocessing diffusion for $subj"
# merge all scans
rm $workDir/"$subj"/DWI_filenames
for i in {1..32}; do
find "$workDir"/"$subj"/DWI2/*_1_${i}.nii >> $workDir/"$subj"/DWI_filenames
done
for i in {1..32}; do
find "$workDir"/"$subj"/DWI3/*_1_${i}.nii >> $workDir/"$subj"/DWI_filenames
done
filelist=`cat $workDir/"$subj"/DWI_filenames`
mkdir -p $workDir/"$subj"/DWI_all
fslmerge -t $workDir/"$subj"/DWI_all/data_merged_original $filelist
# extract bvals and bvecs
$scriptDir/extract_bvecs_bvals.sh $workDir/"$subj"/bvals_bvecs
echo "orientation correction and mask generation for $subj"
cp $workDir/"$subj"/DWI_all/data_merged_original.nii.gz $workDir/"$subj"/DWI_all/data.nii.gz
fslorient -deleteorient $workDir/"$subj"/DWI_all/data.nii.gz
fslswapdim $workDir/"$subj"/DWI_all/data.nii.gz z -y x $workDir/"$subj"/DWI_all/data.nii.gz
fslorient -setsform 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1 $workDir/"$subj"/DWI_all/data.nii.gz
fslorient -copysform2qform $workDir/"$subj"/DWI_all/data.nii.gz
fslorient -setsformcode 1 $workDir/"$subj"/DWI_all/data.nii.gz
fslorient -setqformcode 1 $workDir/"$subj"/DWI_all/data.nii.gz
mkdir $workDir/"$subj"/DWI_all/data_split
fslsplit $workDir/"$subj"/DWI_all/data.nii.gz $workDir/"$subj"/DWI_all/data_split/data -t
fslmerge -t $workDir/"$subj"/DWI_all/b0s_data $workDir/"$subj"/DWI_all/data_split/data0000.nii.gz $workDir/"$subj"/DWI_all/data_split/data0016.nii.gz $workDir/"$subj"/DWI_all/data_split/data0032.nii.gz $workDir/"$subj"/DWI_all/data_split/data0048.nii.gz
#mask generation
fslmaths $workDir/"$subj"/DWI_all/b0s_data -Tmean $workDir/"$subj"/DWI_all/b0_mean
fslmaths $workDir/"$subj"/DWI_all/b0_mean -thr 600 -dilM -ero -dilM -dilM -dilM -dilM -ero -ero -ero -bin $workDir/"$subj"/DWI_all/b0_mean_mask.nii.gz
echo "dtifits for $subj"
mkdir $workDir/"$subj"/dtifit
dtifit -k $workDir/"$subj"/DWI_all/data.nii.gz -m $workDir/"$subj"/DWI_all/b0_mean_mask.nii.gz -b $workDir/"$subj"/bvals_bvecs/bvals -r $workDir/"$subj"/bvals_bvecs/bvecs -o $workDir/"$subj"/dtifit/"$subj"
echo "done"
done
#!/usr/bin/env bash
# definitions
#workDir=/vols/Scratch/alazari/longitudinal_paTMS/resting_state
workDir=/home/fs0/ndcn0979/scratch/Adrianna/BET
scriptDir=/home/fs0/ndcn0979/scratch/Adrianna/Scripts
fixDir=/home/fs0/ndcn0979/scratch/Adrianna/Scripts/fix
module load fix
#Do 03-3185 manually because of 176 thresholds
for subj in 3185
#1070 1079 3178 3179 3180 3181 3182 3183 3184 3186 3187 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 ;
do
echo $subj
echo "FIX $subj"
for time in PRE POST FOLLOWUP;
do
echo $time
# specify the subjects
#subjList="
#1070 1079 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200"
# Change permission
echo change permission of folder
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/*
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/*/*
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/*/*/*
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/*/*/*/*
# chmod 777 $workDir/03-"$subj"/"$time"/RestingState/*/*/*/*/*
# prepare the .sh file to apply FIX classifier for each fix_reg
$workDir/03-"$subj"/"$time"/RestingState/fix_reg.ica
#Make sure you can find fix_reg.ica for each subj/time
#find $workDir/03-"$subj"/"$time"/RestingState/fix_reg.ica # comment out the rest before you run
# Execute FIX
$fixDir/training_file/Standard.RData 5
fsl_sub -q veryshort.q fix $workDir/03-"$subj"/"$time"/RestingState/fix_reg.ica /home/fs0/home/ndcn0979/scratch/Adrianna/Scripts/fix/training_file/Standard.RData 5 -m -h -0
# Apply fix clean up
# `fix_clean=` fsl_sub -q veryshort.q -j ${fix_classify} $fixDir/fix/fix -a $workDir/03-"$subj"/"$time"/RestingState/"$subj""$time"/"$subj"_"$time".ica/fix4melview_Rstandard_classifier_thr5.txt -m -h -0 done
#$workDir/03-"$subj"/"$time"/RestingState/"$subj""$time".fsf
#sed -i "s/XXX/"$subj"g" $workDir/03-"$subj"/"$time"/RestingState/"$subj""$time".fsf
#sed -i "s/YYY/"$time"g" $workDir/03-"$subj"/"$time"/RestingState/"$subj""$time".fsf
# run the .fsf design on feat
# fsl_sub -q short.q -s openmp,2 feat $workDir/"$subj"/"$subj"
#fsl_sub -q long.q -s openmp,2 feat $workDir/03-"$subj"/"$time"/RestingState/"$subj""$time"
echo "done"
done
done
#!/bin/bash
if [ $# -lt 4 ]
then
echo "Usage: $0 inputdir exp_no_shell1 exp_no_shell2 exp_no_blipdown outputdir "
exit 0
fi
orient_corr () {
fslorient -deleteorient $1
fslswapdim $1 z -y x $1
fslorient -setsform 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1 $1
fslorient -copysform2qform $1
fslorient -setsformcode 1 $1
fslorient -setqformcode 1 $1
}
inputdir=$1
shell1=$2
shell2=$3
blipDown=$4
outputdir=$5
if [ -d "${outputdir}" ];
then
echo "Output directory exists. Will work there."
else
mkdir $5
fi
foldername=$(echo `basename ${inputdir}`)
folderlength=`echo -n $foldername | wc -c`
((folderlength = folderlength - 4))
substring=$(echo `basename ${inputdir}` | cut -b 17-${folderlength})
nofiles_shell1=`ls ${inputdir}/${shell1}/pdata/1/nifti/ -1 | wc -l`
nofiles_shell2=`ls ${inputdir}/${shell2}/pdata/1/nifti/ -1 | wc -l`
((nofiles = $nofiles_shell1 + $nofiles_shell2))
echo merging all files
for i in `seq 1 $nofiles_shell1`
do
printf "$inputdir/${shell1}/pdata/1/nifti/${substring}_${shell1}_1_${i}.nii " >> $outputdir/filenames
done
for i in `seq 1 $nofiles_shell2`
do
printf "$inputdir/${shell2}/pdata/1/nifti/${substring}_${shell2}_1_${i}.nii " >> $outputdir/filenames
done
filelist=`cat $outputdir/filenames`
fslmerge -t ${outputdir}/data_merged_original $filelist
cp /vols/Data/km/cetisca/scripts/diffpostproc_masterfiles/acp.txt ${outputdir}/acp.txt
cp /vols/Data/km/cetisca/scripts/diffpostproc_masterfiles/index.txt ${outputdir}/index.txt
cp /vols/Data/km/cetisca/scripts/diffpostproc_masterfiles/topup_mouse.cnf ${outputdir}/topup_mouse.cnf
echo loading bvecs and bvals
cp ${inputdir}/${shell1}/method ${outputdir}/method_shell1
cp ${inputdir}/${shell2}/method ${outputdir}/method_shell2
cp ${inputdir}/${blipDown}/pdata/1/nifti/${substring}_${blipDown}_1_1.nii ${outputdir}/b0_blipDown.nii
/vols/Data/km/cetisca/functions/extract_bvecs_bvals.sh ${outputdir}
echo queuing orientation correction and mask generation
jid1=`fsl_sub -q veryshort.q -l ${outputdir}/logs1 /vols/Data/km/cetisca/scripts/diffpostproc_step1.sh ${outputdir}`
echo queuing gibbs correction
jid2=`/vols/Data/postmort/dSSFP_process/bin/dSSFP_preprocess/gibbs_correction_4D_clust ${outputdir}/data_gibbs.nii.gz -i ${outputdir}/data.nii.gz -l ${outputdir}/gibbslogs -j $jid1 -nc -nd 64`
echo queuing pretopup file processing
jid3=`fsl_sub -q veryshort.q -l ${outputdir}/logs3 -j $jid2 /vols/Data/km/cetisca/scripts/diffpostproc_step3.sh ${outputdir}`
echo queuing topup
jid4=`fsl_sub -q cuda.q -j $jid3 topup --imain=${outputdir}/b0_topup --datain=${outputdir}/acp.txt --config=${outputdir}/topup_mouse.cnf --out=${outputdir}/topup_mouse_output_2b0 --fout=${outputdir}/topup_mouse_field_2b0 --iout=${outputdir}/topup_mouse_unwarped_images_2b0 --logout=${outputdir}/topup_mouse_2b0.log --verbose`
echo queuing post-topup file orientations
jid5=`fsl_sub -q veryshort.q -l ${outputdir}/logs4 -j $jid4 /vols/Data/km/cetisca/scripts/diffpostproc_step4.sh ${outputdir}`
echo queuing applytopup
jid6=`fsl_sub -q veryshort.q -l ${outputdir}/logsapplytopup -j $jid5 applytopup --imain=${outputdir}/data_gibbs_cp --datain=${outputdir}/acp.txt --inindex=1 --topup=${outputdir}/topup_mouse_output_2b0 --method=jac --out=${outputdir}/data_gibbs_applytopup`
echo queuing eddy cuda
jid7=`fsl_sub -q cuda.q -j $jid5 eddy_cuda8.0 --imain=${outputdir}/data_gibbs_cp --mask=${outputdir}/b0_mean_mask_test.nii.gz --acqp=${outputdir}/acp.txt --index=${outputdir}/index.txt --bvecs=${outputdir}/bvecs_eddy --bvals=${outputdir}/bvals --topup=${outputdir}/topup_mouse_output_2b0 --out=${outputdir}/data_gibbs_eddy --verbose`
echo queuing final file manipulations/organisations
jid8=`fsl_sub -q short.q -l ${outputdir}/logs5 -j $jid7 /vols/Data/km/cetisca/scripts/diffpostproc_step5.sh ${outputdir}`
#!/bin/bash
inputfolder=$1
orient_corr () {
fslorient -deleteorient $1
fslswapdim $1 z -y x $1
fslorient -setsform 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1 $1
fslorient -copysform2qform $1
fslorient -setsformcode 1 $1
fslorient -setqformcode 1 $1
}
cp ${inputfolder}/data_merged_original.nii.gz ${inputfolder}/data.nii.gz
orient_corr ${inputfolder}/data.nii.gz
mkdir ${inputfolder}/data_split
fslsplit ${inputfolder}/data.nii.gz ${inputfolder}/data_split/data -t
fslmerge -t ${inputfolder}/b0s_data ${inputfolder}/data_split/data0000.nii.gz ${inputfolder}/data_split/data0016.nii.gz ${inputfolder}/data_split/data0032.nii.gz ${inputfolder}/data_split/data0048.nii.gz
#mask generation
fslmaths ${inputfolder}/b0s_data -Tmean ${inputfolder}/b0_mean
fslmaths ${inputfolder}/b0_mean -thr 600 -dilM -ero -dilM -dilM -dilM -dilM -ero -ero -ero -bin ${inputfolder}/b0_mean_mask.nii.gz
#!/bin/bash
inputfolder=$1
orient_corr () {
fslorient -deleteorient $1
fslswapdim $1 z -y x $1
fslorient -setsform 0.1 0 0 0 0 0.1 0 0 0 0 0.1 0 0 0 0 1 $1
fslorient -copysform2qform $1
fslorient -setsformcode 1 $1
fslorient -setqformcode 1 $1
}
cp ${inputfolder}/data_merged_original.nii.gz ${inputfolder}/data.nii.gz
orient_corr ${inputfolder}/data.nii.gz
mkdir ${inputfolder}/data_split
fslsplit ${inputfolder}/data.nii.gz ${inputfolder}/data_split/data -t
fslmerge -t ${inputfolder}/b0s_data ${inputfolder}/data_split/data0000.nii.gz ${inputfolder}/data_split/data0016.nii.gz ${inputfolder}/data_split/data0032.nii.gz ${inputfolder}/data_split/data0048.nii.gz
#mask generation
fslmaths ${inputfolder}/b0s_data -Tmean ${inputfolder}/b0_mean
fslmaths ${inputfolder}/b0_mean -thr 600 -dilM -ero -dilM -dilM -dilM -dilM -ero -ero -ero -bin ${inputfolder}/b0_mean_mask.nii.gz
#!/bin/bash
inputfolder=$1
fslswapdim ${inputfolder}/data_gibbs_applytopup x -z y ${inputfolder}/data_gibbs_applytopup
fslswapdim ${inputfolder}/data_gibbs_eddy x -z y ${inputfolder}/data_gibbs_eddy
#5th step: dtifit
#dtifit
mkdir ${inputfolder}/dtifit_gibbs_eddy
dtifit -k ${inputfolder}/data_gibbs_eddy.nii.gz -m ${inputfolder}/b0_mean_mask.nii.gz -b ${inputfolder}/bvals -r ${inputfolder}/bvecs_zminxy -o ${inputfolder}/dtifit_gibbs_eddy/dtifit_gibbs_eddy
mkdir ${inputfolder}/data_noddi_bpx
cp ${inputfolder}/data_gibbs_eddy.nii.gz ${inputfolder}/data_noddi_bpx/data.nii.gz
cp ${inputfolder}/b0_mean_mask.nii.gz ${inputfolder}/data_noddi_bpx/nodif_brain_mask.nii.gz
cp ${inputfolder}/bvals ${inputfolder}/data_noddi_bpx/bvals
cp ${inputfolder}/bvecs_zminxy ${inputfolder}/data_noddi_bpx/bvecs
#check data is okay
bedpostx_datacheck ${inputfolder}/data_noddi_bpx
#6th step: bedpostx
bedpostx ${inputfolder}/data_noddi_bpx
#6th step: noddi
#/home/fs0/amyh/func/run_NODDI.sh ${inputfolder}/data_noddi_bpx -m exvivo --dax 0.00056 --diso 0.001 --runMCMC
#!/bin/bash
inputfolder=$1
#5th step: dtifit
#dtifit
mkdir ${inputfolder}/dtifit
dtifit -k ${inputfolder}/data.nii.gz -m ${inputfolder}/b0_mean_mask.nii.gz -b ${inputfolder}/bvals -r ${inputfolder}/bvecs_zminxy -o ${inputfolder}/dtifit_gibbs_eddy/dtifit_gibbs_eddy
# fslswapdim ${inputfolder}/data_gibbs_applytopup x -z y ${inputfolder}/data_gibbs_applytopup
# fslswapdim ${inputfolder}/data_gibbs_eddy x -z y ${inputfolder}/data_gibbs_eddy
#
# #5th step: dtifit
#
# #dtifit
# mkdir ${inputfolder}/dtifit_gibbs_eddy
# dtifit -k ${inputfolder}/data_gibbs_eddy.nii.gz -m ${inputfolder}/b0_mean_mask.nii.gz -b ${inputfolder}/bvals -r ${inputfolder}/bvecs_zminxy -o ${inputfolder}/dtifit_gibbs_eddy/dtifit_gibbs_eddy
# mkdir ${inputfolder}/data_noddi_bpx
# cp ${inputfolder}/data_gibbs_eddy.nii.gz ${inputfolder}/data_noddi_bpx/data.nii.gz
# cp ${inputfolder}/b0_mean_mask.nii.gz ${inputfolder}/data_noddi_bpx/nodif_brain_mask.nii.gz
# cp ${inputfolder}/bvals ${inputfolder}/data_noddi_bpx/bvals
# cp ${inputfolder}/bvecs_zminxy ${inputfolder}/data_noddi_bpx/bvecs
# #check data is okay
# bedpostx_datacheck ${inputfolder}/data_noddi_bpx
#
# #6th step: bedpostx
# bedpostx ${inputfolder}/data_noddi_bpx
#6th step: noddi
#/home/fs0/amyh/func/run_NODDI.sh ${inputfolder}/data_noddi_bpx -m exvivo --dax 0.00056 --diso 0.001 --runMCMC
#### bvals
foldername=$1
grep -A8 PVM_DwEffBval= ${foldername}/method_shell1 | tail -n+2 | tr " " "\n" | sed '/^[[:space:]]*$/d' | sed -n '2{h; d}; 17{p; x;}; p' | tr -d " \t\r" > ${foldername}/bvals_b2.5k
sed -n '/PVM_DwEffBval/,/PVM_DwGradVec/{ /PVM_DwEffBval/d; /PVM_DwGradVec/d; p }' ${foldername}/method_shell1 | tr " " "\n" | sed '/^[[:space:]]*$/d' | sed -n '2{h; d}; 17{p; x;}; p' | tr -d " \t\r" > ${foldername}/bvals_b2.5k
grep -A8 PVM_DwEffBval= ${foldername}/method_shell2 | tail -n+2 | tr " " "\n" | sed '/^[[:space:]]*$/d' | sed -n '2{h; d}; 17{p; x;}; p' | tr -d " \t\r" > ${foldername}/bvals_b10k
sed -n '/PVM_DwEffBval/,/PVM_DwGradVec/{ /PVM_DwEffBval/d; /PVM_DwGradVec/d; p }' ${foldername}/method_shell2 | tr " " "\n" | sed '/^[[:space:]]*$/d' | sed -n '2{h; d}; 17{p; x;}; p' | tr -d " \t\r" > ${foldername}/bvals_b10k
#
###### extract text between two patterns with bash awk - patterns = "##$PVM_DwEffBval=( 32 )" and "##$PVM_DwGradVec=( 32, 3 )"
#
cat ${foldername}/bvals_b2.5k > ${foldername}/bvals2
cat ${foldername}/bvals_b10k >> ${foldername}/bvals2
cat ${foldername}/bvals2 | tr "\n" " " > ${foldername}/bvals
sed -n '/##$PVM_DwDir=(/,/##$PVM_DwDgSwitch/{ /PVM_DwDir/d; /##$PVM_DwDgSwitch/d; p }' ${foldername}/method_shell1 | tr " " "\n" | sed '/^[[:space:]]*$/d' | tr -d " \t\r" | tr -d " \t\r" | tr "\n" " " | sed -e "s/\([^\ ]*\ [^\ ]*\ [^\ ]*\)\ /\1\\`echo -e '\n\r'`/g" | tr "\r" "\n" | sed '/^[[:space:]]*$/d' > ${foldername}/bvecs2.5k
sed -i '1 i\0 0 0' ${foldername}/bvecs2.5k
sed -i '16 a\0 0 0' ${foldername}/bvecs2.5k
sed -n '/##$PVM_DwDir=(/,/##$PVM_DwDgSwitch/{ /PVM_DwDir/d; /##$PVM_DwDgSwitch/d; p }' ${foldername}/method_shell2 | tr " " "\n" | sed '/^[[:space:]]*$/d' | tr -d " \t\r" | tr -d " \t\r"| tr "\n" " " | sed -e "s/\([^\ ]*\ [^\ ]*\ [^\ ]*\)\ /\1\\`echo -e '\n\r'`/g" | tr "\r" "\n" | sed '/^[[:space:]]*$/d' > ${foldername}/bvecs10k
sed -i '1 i\0 0 0' ${foldername}/bvecs10k
sed -i '16 a\0 0 0' ${foldername}/bvecs10k
cat ${foldername}/bvecs2.5k > ${foldername}/bvecs_temp
cat ${foldername}/bvecs10k >> ${foldername}/bvecs_temp
/vols/Data/km/aurea/TDP_M323K/Analysis/transpose_bvecs.sh ${foldername}/bvecs_temp > ${foldername}/bvecs
rm ${foldername}/bvals_b2.5k ${foldername}/bvals_b10k ${foldername}/bvals2 ${foldername}/bvecs_temp ${foldername}/bvecs2.5k ${foldername}/bvecs10k
1 <1_Localizer (E1)>
2 <2_Localizer (E2)>
3 <3_Localizer_multi_slice (E3)>
4 <4_MGE_check_bubble (E4)>
5 <5_T2map_MSME_25TE_nx5ms_highres (E5)>
6 <6_Localizer_multi_slice_B0Map (E6)>
7 <7_T2w_anat_res0.06 (E7)>
8 <8_QSM_MGE_IES3ms_20TE (E8)>
9 <9_win_DtiEpi_01_BlipDown (E9)>
10 <10_win_DtiEpi_01_b2.5k (E10)>
11 <11_win_DtiEpi_01_b10k (E11)>
12 <1_Localizer (E12)>
13 <1_Localizer (E13)>
14 <1_Localizer (E14)>
15 <1_Localizer (E15)>
16 <1_Localizer (E16)>
17 <1_Localizer (E17)>
18 <6_Localizer_multi_slice_B0Map (E6)>
19
20
21
22
23
24
25
26
27
28
29
30
1 <1_Localizer (E1)>
2 <2_Localizer (E2)>
3 <3_Localizer_multi_slice (E3)>
4 <4_MGE_check_bubble (E4)>
5 <5_T2map_MSME_25TE_nx5ms_highres (E5)>
6 <6_Localizer_multi_slice_B0Map (E6)>
7 <7_T2w_anat_res0.06 (E7)>
8 <8_QSM_MGE_IES3ms_20TE (E8)>
9 <9_win_DtiEpi_01_BlipDown (E9)>
10 <10_win_DtiEpi_01_b2.5k (E10)>
11 <11_win_DtiEpi_01_b10k (E11)>
12 <1_Localizer (E12)>
13 <1_Localizer (E13)>
14 <1_Localizer (E14)>
15 <6_Localizer_multi_slice_B0Map (E6)>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1 <1_Localizer (E1)>
2
3
4
5
6
7 <7_T2w_anat_res0.06 (E7)>
8 <8_QSM_MGE_IES3ms_20TE (E8)>
9 <9_win_DtiEpi_01_BlipDown (E9)>
10 <10_win_DtiEpi_01_b2.5k (E10)>
11 <11_win_DtiEpi_01_b10k (E11)>
12 <3_Localizer_multi_slice_B0Map (E12)>
13 <3_Localizer_multi_slice (E13)>
14 <4_MGE_check_bubble (E14)>
15 <5_T2map_MSME_25TE_nx5ms_highres (E15)>
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1 <1_Localizer (E1)>
2
3
4
5
6
7 <7_T2w_anat_res0.06 (E7)>
8 <8_QSM_MGE_IES3ms_20TE (E8)>
9 <9_win_DtiEpi_01_BlipDown (E9)>
10 <10_win_DtiEpi_01_b2.5k (E10)>
11 <11_win_DtiEpi_01_b10k (E11)>
12 <3_Localizer_multi_slice_B0Map (E12)>