Interpreting censor files

Hi all,

I’ve been using the script below to identify and censor TRs with signal and motion outliers in my data. However, I’ve noticed that the options reporting statistics from these censor files does not seem to match the file content. In the censor file, shouldn’t there be a zero for an omitted TR and a 1 for an included TR, and these should correspond to the TRs indicated by -show_trs_censored?

For example, when I use this script on one of my subjects (105), it says all 39 TRs will be censored but the censor file starts with three 1s (I plan to adjust my threshold up from 0.3 for the Euclidean norm). Also, the censor file combining the signal and motion outliers is the same as the censor file for just the motion outliers, even when there are signal outliers.

Please note there were 78 TRs total, and they were split into even and odd TRs (39 each). The script below is for the even TRs. Any thoughts are appreciated.

Cheers,
Alain

#!/bin/tcsh -xef

##########################################################################
#fMRI signal outliers

#Create a file that will allow us to censor TRs with outliers at more than 10% of brain voxels

1deval -a outcount.101.breathhold.E.1D -expr “1-step(a-0.1)” > out.censor.101.breathhold.E.1D

#Determine exactly how many TRs were censored and which TRs were censored, based on signal outliers

1d_tool.py -infile out.censor.101.breathhold.E.1D -quick_censor_count 0 -show_trs_censored comma

#Motion outliers

#Determine maximum motion displacement (mm) before censoring

1d_tool.py -infile dfile.breathhold.E.1D -show_max_displace

#Create a file that will allow us to censor TRs where the Euclidean norm of the motion parameter derivative is more than 0.3 (~mm/degrees). This is a good value for healthy adults, but I may need to increase this cut-off depending on the number of TRs that are being censored

1d_tool.py -infile dfile.breathhold.E.1D -set_nruns 1 -set_tr 4 -show_censor_count -censor_prev_TR -censor_motion 0.3 motion.101.breathhold.E

#Determine maximum motion displacement with censoring

1d_tool.py -infile dfile.breathhold.E.1D -show_max_displace -censor_infile motion.101.breathhold.E_censor.1D

#Display a list of the TRs censored based on motion, and the total number of censored TRs.

1d_tool.py -infile motion.101.breathhold.E_censor.1D -quick_censor_count 0 -show_trs_censored comma

#Create a “combined” censor file for use in 3dDeconvolve (i.e., that combines signal and motion outliers). This is when the censoring will actually take place. If a subject does not have any censored TRs, then I do not need to re-run 3dDeconvolve.

1deval -a motion.101.breathhold.E_censor.1D -b out.censor.101.breathhold.E.1D -expr “a*b” > censor.101.breathhold.E_combined.1D

#Display a list of the TRs censored based on motion and outliers combined and the total number of censored TRs (last line).

1d_tool.py -infile censor.101.breathhold.E_combined.1D -quick_censor_count 0 -show_trs_censored comma

Hi Alain,

There are many censor counts and show_trs here,
Exactly which command is showing results that
you think are incorrect, and what do the inputs
to it look like?

On a separate note, I take it you have started
with an afni_proc.py script for this, but are
not using afni_proc.py to regenerate it. Is
there something you want that afni_proc.py
cannot do? Just curious…

Thanks,

  • rick

Many thanks for the reply, Rick. I think I’ve managed to sort out the problem. I was working from a script provided to me by someone in my lab. The source of the issue was the censor counts, not the generated censor files.

1d_tool.py -infile out.censor.101.breathhold.E.1D -quick_censor_count 0 -show_trs_censored comma

For whatever reason, wherever the script used -quick_censor_count 0, it led 1d_tool to count the TRs on either side of a censored TR as also censored (for example, 3,4,5 rather than just 4). I replaced with -show_censor_count throughout the script and it appears to work properly now.

Another issue I identified was that the script was omitting the previous TR, which from what I understand makes some sense.

1d_tool.py -infile dfile.breathhold.E.1D -set_nruns 1 -set_tr 4 -show_censor_count -censor_prev_TR -censor_motion 0.3 motion.101.breathhold.E

But not when the TRs have been divided into even and odd, in which case I would be omitting the TR two back rather than the previous TR.

I confess my main reason for using this approach is that it was provided to me. During preprocessing, I used 3dToutcount to generate the outcount files and the -volreg_opts option in align_epi_anat to generate the dfiles (below).

#compute outlier fraction for each volume

3dToutcount -automask -fraction -polort 3 -legendre ./101.breathhold_E.nii.gz > ./outcount.101.breathhold.E.1D
3dToutcount -automask -fraction -polort 3 -legendre ./101.breathhold_O.nii.gz > ./outcount.101.breathhold.O.1D

#align epi to anatomical

3dcalc -a ./101.breathhold_E.nii.gz -prefix ./101.breathhold_E -expr a
3dcalc -a ./101.breathhold_O.nii.gz -prefix ./101.breathhold_O -expr a
3dcalc -a ./101.anat.nii.gz -prefix ./101.anat -expr a

align_epi_anat.py -epi2anat -anat ./101.anat+orig -epi ./101.breathhold_E+orig -epi_base 19 -suffix _mc_al -volreg on -volreg_opts ‘-1Dfile dfile.breathhold.E.1D’ -tshift off -deoblique on -anat_has_skull yes

align_epi_anat.py -epi2anat -anat ./101.anat+orig -epi ./101.breathhold_O+orig -epi_base 19 -suffix _mc_al -volreg on -volreg_opts ‘-1Dfile dfile.breathhold.O.1D’ -tshift off -deoblique on -anat_has_skull yes

Then, I will use the script in the first post (with the modifications discussed above) to call on these files to generate the combined censor file with motion and signal outliers. Finally, I will probably combine the resulting even and odd censor files manually, although I could likely use a script to interleave these files.

The -quick_censor_count option is supposed to work
on a motion file, not a censor file. If you just want to
count zeros in a file use “grep 0 FILE | wc -l” Or maybe
you want a censored TR list from a censor file:

1d_tool.py -infile CENSOR_FILE -show_trs_censored comma

It might be good to run afni_proc.py on some subject,
so you can see how it is doing such things.

  • rick

Good to know. Thanks!