# ------------------------------------------------------------ # generate sine curves to show slice timing and correction # (it is probably nice to run this in an empty directory) # # - 4 cycles across 20 time points -> 5 TRs per cycle # - simultaneous timing: -expr 'sin(2*pi*(4*l/20))' # - sequential timing: -expr 'sin(2*pi*(4*(l+k/6)/20))' # ------------------------------------------------------------ # create an empty 20x20x6 slice float image with 21 time points nifti_tool \ -infiles MAKE_IM \ -prefix d0.zero.nii -new_dims 5 20 20 6 1 21 0 0 \ -new_datatype 16 \ -mod_hdr \ -mod_field descrip 'for slice timing' # -------------------------------------------------- # simultaneous timing 3dcalc -a d0.zero.nii -expr 'sin(2*pi*(4*l/20))' -prefix d1.simult.nii # -------------------------------------------------- # interleaved timing (but slice n-1 needs to be fixed later) # first: almost correct, but slice n-1 needs to be fixed 3dcalc -a d0.zero.nii -expr 'sin(2*pi*4*(l+mod(3*k,5)/6)/20)' -prefix d2.a.nii # second: just for slice n-1 3dcalc -a d0.zero.nii -expr 'sin(2*pi*4*(l+5 /6)/20)' -prefix d2.b.nii # combine: grab slice n-1 from the second dset, else from the first 3dcalc -a d2.a.nii -b d2.b.nii \ -expr 'a*step(5-k)+b*equals(k,5)' \ -prefix d3.inter.nii # -------------------------------------------------- # add slice timing information to header 3dTcat -TR 2 -tpattern alt+z -prefix d4.as_acquired.nii d3.inter.nii nifti_tool -rm_ext ALL -overwrite -infiles d4.as_acquired.nii # -------------------------------------------------- # "correct" for the slice timing - to the start of the TR 3dTshift -quintic -tzero 0 -prefix d5.quintic.nii d4.as_acquired.nii 3dTshift -fourier -tzero 0 -prefix d5.fourier.nii d4.as_acquired.nii ### Apparently, 3dTcat can make a proper NIFTI header, but with a bad # AFNI header, and has the same problem directly making an AFNI dataset. # They differ in the 5th TAXIS_FLOATS entry, dz_sl. So delete the AFNI # extension. # 3dTcat.c: see if..TCAT_tpattern, or in general, set # dz_sl to dz (whyyyyy would they be different?) # -------------------------------------------------- # make plots of: (xhairs at k=2, to leave k=0 at the bottom) # (2 double plots means 2 controllers) # - orig EPI: d4.as_acquired.nii # - orig+corrected: d4.as_acquired.nii + d5.quintic.nii # - simult+corrected: d1.simult.nii + d5.quintic.nii