#!/bin/tcsh # ---------------------------------------------------------------------- # partition subjects with respect to ave (uncensored) motion # given: motion file with (after header line): # SUBJ #TRs #censor ave_mot ave_censor ave_TSNR # # create: # 1. sorted motion file # 2. group.big.txt # 3. group.small.txt # 4. a motion covariates file, with just subject and motion, mot_covary.txt # ---------------------------------------------------------------------- # set up and basic tests set top_dir = `pwd` set misc_dir = $top_dir/misc_dir set motion_file = motion_info_all.txt set sorted_file = sorted_1.txt set covary_file = covary_gcor.txt # check that we have results and the motion info file scripts/check.subj.results if ( $status ) exit # ---------------------------------------------------------------------- # additions to script... cd $misc_dir if ( ! -f $sorted_file ) then echo "** partition_motion: missing motion info file, $misc_dir/$sorted_file" exit endif echo "-- making big/small motion group and covariate files..." # get group size, might not have an even number of subjects set nsubj = `cat $sorted_file | wc -l` set gsize = `ccalc -f $nsubj/2` # and extract groups @ g2 = $gsize * 2 tail -n $g2 $sorted_file | head -n $gsize | awk '{print $4}' > group.1.big.txt tail -n $gsize $sorted_file | awk '{print $4}' > group.1.small.txt # make a GCOR covariates file mot_covary.txt awk '{print $1, $4, $3}' $motion_file | sort -n | awk '{print $2, $3}' \ > $misc_dir/$covary_file echo " created group.1.{big,small}.txt, $covary_file"