#!/bin/tcsh -xef echo "auto-generated by afni_proc.py, Tue Nov 3 09:47:43 2009" echo "(version 2.13, October 19, 2009)" # execute via : # tcsh -xef proc.sb23.blk |& tee output.proc.sb23.blk # ================================= setup ================================== # script setup # the user may specify a single subject to run with if ( $#argv > 0 ) then set subj = $argv[1] else set subj = sb23.blk endif # assign output directory name set output_dir = $subj.results # verify that the results directory does not yet exist if ( -d $output_dir ) then echo output dir "$subj.results" already exists exit endif # set list of runs set runs = (`count -digits 2 1 9`) # create results and stimuli directories mkdir $output_dir mkdir $output_dir/stimuli # copy stim files into stimulus directory cp sb23/stim_files/blk_times.01.tneg.1D sb23/stim_files/blk_times.02.tpos.1D \ sb23/stim_files/blk_times.03.tneu.1D sb23/stim_files/blk_times.04.eneg.1D \ sb23/stim_files/blk_times.05.epos.1D sb23/stim_files/blk_times.06.eneu.1D \ sb23/stim_files/blk_times.07.fneg.1D sb23/stim_files/blk_times.08.fpos.1D \ sb23/stim_files/blk_times.09.fneu.1D $output_dir/stimuli # copy anatomy to results dir 3dcopy sb23/sb23_mpra+orig $output_dir/sb23_mpra # ================================== tcat ================================== # apply 3dTcat to copy input dsets to results dir, while # removing the first 3 TRs 3dTcat -prefix $output_dir/pb00.$subj.r01.tcat sb23/epi_r03+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r02.tcat sb23/epi_r04+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r03.tcat sb23/epi_r05+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r04.tcat sb23/epi_r06+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r05.tcat sb23/epi_r07+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r06.tcat sb23/epi_r08+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r07.tcat sb23/epi_r09+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r08.tcat sb23/epi_r10+orig'[3..$]' 3dTcat -prefix $output_dir/pb00.$subj.r09.tcat sb23/epi_r11+orig'[3..$]' # and enter the results directory cd $output_dir # ================================= tshift ================================= # run 3dToutcount and 3dTshift for each run foreach run ( $runs ) 3dToutcount -automask pb00.$subj.r$run.tcat+orig > outcount_r$run.1D 3dTshift -tzero 0 -quintic -prefix pb01.$subj.r$run.tshift \ pb00.$subj.r$run.tcat+orig end # ================================= volreg ================================= # align each dset to base volume foreach run ( $runs ) # register each volume to the base 3dvolreg -verbose -zpad 1 -base pb01.$subj.r09.tshift+orig'[63]' \ -1Dfile dfile.r$run.1D -prefix pb02.$subj.r$run.volreg \ -cubic \ pb01.$subj.r$run.tshift+orig end # make a single file of registration params cat dfile.r??.1D > dfile.rall.1D # compute motion magnitude time series: the Euclidean norm # (sqrt(sum squares)) of the motion parameter derivatives 1d_tool.py -infile dfile.rall.1D -set_nruns 9 \ -derivative -collapse_cols euclidean_norm \ -write motion_${subj}_enorm.1D # ================================== blur ================================== # blur each volume of each run foreach run ( $runs ) 3dmerge -1blur_fwhm 4.0 -doall -prefix pb03.$subj.r$run.blur \ pb02.$subj.r$run.volreg+orig end # ================================== mask ================================== # create 'full_mask' dataset (union mask) foreach run ( $runs ) 3dAutomask -dilate 1 -prefix rm.mask_r$run pb03.$subj.r$run.blur+orig end # get mean and compare it to 0 for taking 'union' 3dMean -datum short -prefix rm.mean rm.mask*.HEAD 3dcalc -a rm.mean+orig -expr 'ispositive(a-0)' -prefix full_mask.$subj # ================================= scale ================================== # scale each voxel time series to have a mean of 100 # (be sure no negatives creep in) # (subject to maximum value of 200) foreach run ( $runs ) 3dTstat -prefix rm.mean_r$run pb03.$subj.r$run.blur+orig 3dcalc -a pb03.$subj.r$run.blur+orig -b rm.mean_r$run+orig \ -expr 'min(200, a/b*100)*step(a)' \ -prefix pb04.$subj.r$run.scale end # ================================ regress ================================= # run the regression analysis 3dDeconvolve -input pb04.$subj.r??.scale+orig.HEAD \ -polort 2 \ -num_stimts 15 \ -stim_times 1 stimuli/blk_times.01.tneg.1D 'BLOCK(30,1)' \ -stim_label 1 tneg \ -stim_times 2 stimuli/blk_times.02.tpos.1D 'BLOCK(30,1)' \ -stim_label 2 tpos \ -stim_times 3 stimuli/blk_times.03.tneu.1D 'BLOCK(30,1)' \ -stim_label 3 tneu \ -stim_times 4 stimuli/blk_times.04.eneg.1D 'BLOCK(30,1)' \ -stim_label 4 eneg \ -stim_times 5 stimuli/blk_times.05.epos.1D 'BLOCK(30,1)' \ -stim_label 5 epos \ -stim_times 6 stimuli/blk_times.06.eneu.1D 'BLOCK(30,1)' \ -stim_label 6 eneu \ -stim_times 7 stimuli/blk_times.07.fneg.1D 'BLOCK(30,1)' \ -stim_label 7 fneg \ -stim_times 8 stimuli/blk_times.08.fpos.1D 'BLOCK(30,1)' \ -stim_label 8 fpos \ -stim_times 9 stimuli/blk_times.09.fneu.1D 'BLOCK(30,1)' \ -stim_label 9 fneu \ -stim_file 10 dfile.rall.1D'[0]' -stim_base 10 -stim_label 10 roll \ -stim_file 11 dfile.rall.1D'[1]' -stim_base 11 -stim_label 11 pitch \ -stim_file 12 dfile.rall.1D'[2]' -stim_base 12 -stim_label 12 yaw \ -stim_file 13 dfile.rall.1D'[3]' -stim_base 13 -stim_label 13 dS \ -stim_file 14 dfile.rall.1D'[4]' -stim_base 14 -stim_label 14 dL \ -stim_file 15 dfile.rall.1D'[5]' -stim_base 15 -stim_label 15 dP \ -gltsym 'SYM: +eneg -fneg' \ -glt_label 1 eneg_vs_fneg \ -gltsym 'SYM: 0.5*fneg 0.5*fpos -1.0*fneu' \ -glt_label 2 face_contrast \ -gltsym 'SYM: tpos epos fpos -tneg -eneg -fneg' \ -glt_label 3 pos_vs_neg \ -fout -tout -x1D X.xmat.1D -xjpeg X.jpg \ -fitts fitts.$subj \ -errts errts.$subj \ -bucket stats.$subj # if 3dDeconvolve fails, terminate the script if ( $status != 0 ) then echo '---------------------------------------' echo '** 3dDeconvolve error, failing...' echo ' (consider the file 3dDeconvolve.err)' exit endif # create an all_runs dataset to match the fitts, errts, etc. 3dTcat -prefix all_runs.$subj pb04.$subj.r??.scale+orig.HEAD # create ideal files for each stim type 1dcat X.xmat.1D'[27]' > ideal_tneg.1D 1dcat X.xmat.1D'[28]' > ideal_tpos.1D 1dcat X.xmat.1D'[29]' > ideal_tneu.1D 1dcat X.xmat.1D'[30]' > ideal_eneg.1D 1dcat X.xmat.1D'[31]' > ideal_epos.1D 1dcat X.xmat.1D'[32]' > ideal_eneu.1D 1dcat X.xmat.1D'[33]' > ideal_fneg.1D 1dcat X.xmat.1D'[34]' > ideal_fpos.1D 1dcat X.xmat.1D'[35]' > ideal_fneu.1D # create ideal file by adding ideal regressors 3dTstat -sum -prefix sum_ideal.1D X.xmat.1D'[27..35]' # ============================ blur estimation ============================= # compute blur estimates touch blur_est.$subj.1D # start with empty file # -- estimate blur for each run in epits -- touch blur.epits.1D set b0 = 0 # first index for current run set b1 = -1 # will be last index for current run foreach reps ( 64 64 64 64 64 64 64 64 64 ) @ b1 += $reps # last index for current run 3dFWHMx -detrend -mask full_mask.$subj+orig \ all_runs.$subj+orig"[$b0..$b1]" >> blur.epits.1D @ b0 += $reps # first index for next run end # compute average blur and append set blurs = ( `3dTstat -mean -prefix - blur.epits.1D\'` ) echo average epits blurs: $blurs echo "$blurs # epits blur estimates" >> blur_est.$subj.1D # -- estimate blur for each run in errts -- touch blur.errts.1D set b0 = 0 # first index for current run set b1 = -1 # will be last index for current run foreach reps ( 64 64 64 64 64 64 64 64 64 ) @ b1 += $reps # last index for current run 3dFWHMx -detrend -mask full_mask.$subj+orig \ errts.$subj+orig"[$b0..$b1]" >> blur.errts.1D @ b0 += $reps # first index for next run end # compute average blur and append set blurs = ( `3dTstat -mean -prefix - blur.errts.1D\'` ) echo average errts blurs: $blurs echo "$blurs # errts blur estimates" >> blur_est.$subj.1D # =========================== gen_epi_review.py ============================ # generate a review script for the unprocessed EPI data gen_epi_review.py -script @epi_review.$subj \ -dsets pb00.$subj.r??.tcat+orig.HEAD # ================================ cleanup ================================= # remove temporary rm.* files \rm -f rm.* # return to parent directory cd .. # ========================================================================== # script generated by the command: # # afni_proc.py -subj_id sb23.blk -dsets sb23/epi_r03+orig.HEAD \ # sb23/epi_r04+orig.HEAD sb23/epi_r05+orig.HEAD sb23/epi_r06+orig.HEAD \ # sb23/epi_r07+orig.HEAD sb23/epi_r08+orig.HEAD sb23/epi_r09+orig.HEAD \ # sb23/epi_r10+orig.HEAD sb23/epi_r11+orig.HEAD -copy_anat \ # sb23/sb23_mpra+orig -tcat_remove_first_trs 3 -volreg_align_to last \ # -regress_make_ideal_sum sum_ideal.1D -regress_stim_times \ # sb23/stim_files/blk_times.01.tneg.1D \ # sb23/stim_files/blk_times.02.tpos.1D \ # sb23/stim_files/blk_times.03.tneu.1D \ # sb23/stim_files/blk_times.04.eneg.1D \ # sb23/stim_files/blk_times.05.epos.1D \ # sb23/stim_files/blk_times.06.eneu.1D \ # sb23/stim_files/blk_times.07.fneg.1D \ # sb23/stim_files/blk_times.08.fpos.1D \ # sb23/stim_files/blk_times.09.fneu.1D -regress_stim_labels tneg tpos \ # tneu eneg epos eneu fneg fpos fneu -regress_basis 'BLOCK(30,1)' \ # -regress_est_blur_epits -regress_est_blur_errts -regress_opts_3dD \ # -gltsym 'SYM: +eneg -fneg' -glt_label 1 eneg_vs_fneg -gltsym 'SYM: \ # 0.5*fneg 0.5*fpos -1.0*fneu' -glt_label 2 face_contrast -gltsym 'SYM: \ # tpos epos fpos -tneg -eneg -fneg' -glt_label 3 pos_vs_neg