Skip to content

Instantly share code, notes, and snippets.

@dgfitch
Last active May 23, 2016 14:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgfitch/4b5ed9af4f65ed0d9a35 to your computer and use it in GitHub Desktop.
Save dgfitch/4b5ed9af4f65ed0d9a35 to your computer and use it in GitHub Desktop.
Level 1 QC script converted to bash with some functions and features
#!/bin/bash
#
# Script that combines all run images into one
# html file for quality assurance.
#
# Assess plots for unusually bad motion or extreme
# amounts of censoring
#
# Examples of functions and redirecting output
#
#---------------------------------
# Created by: Jeanette Mumford
# 10/30/2014
# Bash version: Dan Fitch
#----------------------------------
data="/home/dan/fsl_course/Data"
outfile="$data/level1.html"
rm -f $outfile
echo "Writing to $outfile"
# Save stdout in handle 6
exec 6>&1
# Send all stdout to $outfile
exec > $outfile
# Display an image. Arguments: Feat dir, image title, image path in dir
image()
{
echo "<hr/><p>$1 $2<br><img border=0 src='$1/$3' width=100%></p>";
}
runs=`find $data -name "run*.feat"`
echo "<h1>Level 1 QC report</h1>"
# Table of contents
counter=1
echo "<ul>"
for f in $runs; do
echo "<a href='#f$counter'>$f</a>"
counter=$counter+1
done
echo "</ul>"
# Actual stuff
counter=1
for f in $runs; do
# Send a message to original terminal, not real important in a fast script like this, but as an example
echo "Processing $f" >&6
echo "<h2><a id='f$counter'/>$f</h2>"
echo "<h4>Got `ls $f/stats/cope* | wc -l` cope images</h4>"
echo "<h4>Got `ls $f/stats/zstat* | wc -l` zstat images</h4>"
echo "<pre>fslview -m ortho $f/example_func $f/stats/zstat1 -l Red -b 1.9,6</pre>"
image $f "Design matrix" "design.png"
image $f "Design correlations" "design_cov.png"
image $f "Motion params: rotations" "mc/rot.png"
image $f "Motion params: translations" "mc/trans.png"
image $f "BOLD 2 MNI registration" "reg/example_func2standard.png"
image $f "BOLD 2 Stuctural" "reg/example_func2highres.png"
image $f "Structural 2 MNI" "reg/highres2standard.png"
counter=$counter+1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment