Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
surface_scripts/level3_flame.sh
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
executable file
62 lines (54 sloc)
1.67 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
result_dir=$1 | |
out_dir=$2 | |
subjects_file=$3 | |
task=$4 | |
subjects=`cat $subjects_file | tr "\n" " "` | |
subjects=($subjects) | |
n_contrasts=`ls -d ${result_dir}/sub-${subjects[0]}/MNINonLinear/Results/level2_${task}/cope*.feat|wc -l` | |
# for every second level cope | |
for cope in `seq $n_contrasts`; do | |
rm -r ${out_dir}/cope${cope} | |
mkdir -p ${out_dir}/cope${cope}/tmp | |
cd $out_dir/cope${cope}/tmp | |
#merge input files | |
for fname in varcope1 cope1 tdof_t1 mask; do | |
cmd="fslmerge -t ${fname} " | |
for s in ${subjects[@]}; do | |
cmd="$cmd ${result_dir}/sub-${s}/MNINonLinear/Results/level2_${task}/cope${cope}.feat/${fname}.nii.gz" | |
done | |
echo $cmd | |
`$cmd` | |
done | |
# create mask | |
fslmaths mask -Tmin -bin group_mask | |
#design | |
for i in "${!subjects[@]}"; do | |
echo "1" >> design.txt | |
echo "1" >> group.txt | |
done | |
echo "1" > contrast.txt | |
echo "-1" >> contrast.txt | |
Text2Vest design.txt design.mat | |
Text2Vest contrast.txt design.con | |
Text2Vest group.txt design.grp | |
# estimate | |
flameo --cope=cope1 \ | |
--vc=varcope1 \ | |
--dvc=tdof_t1 \ | |
--mask=group_mask \ | |
--ld=../../cope${cope}.gfeat \ | |
--dm=design.mat \ | |
--cs=design.grp \ | |
--tc=design.con \ | |
--runmode=flame1 | |
# CIFTI | |
cd ../../cope${cope}.gfeat | |
CIFTItemplate=${result_dir}/sub-${subjects[0]}/MNINonLinear/Results/level2_${task}/cope${cope}.feat/pe1.dtseries.nii | |
for f in *.nii.gz; do | |
wb_command -cifti-convert -from-nifti $f $CIFTItemplate ${f%.nii.gz}.dtseries.nii -reset-timepoints 1 1 | |
done | |
# cleanup | |
rm *.nii.gz | |
rm -r ${out_dir}/cope${cope} | |
done |