Inconsistent sub bricks for runs in deconvolve command

AFNI version info (afni -ver): Precompiled binary linux_ubuntu_16_64: Oct 17 2023 (Version AFNI_23.3.02 'Septimius Severus')

code text  # or delete if not needed

deconvolve command #1

## This is getting contrast between tape (run 1) - odor (run 3)
	echo "Running contrast tape - odor"
	3dDeconvolve -input pb05.${sub}.r01.detrend+orig \
	pb05.${sub}.r03.detrend+orig[2..$] \
	-polort 2 -num_stimts 9 \
	-mask ~/Volumes/Coutanche/Shared/Projects/Craving/AnatomicalData/${sub}/brain_mask_${sub}_re+orig \
	-stim_times_IM 1 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_tape.1D 'BLOCK(30,1)' -stim_label 1 tape \
	-stim_times_IM 2 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_tape-odor_odor.1D 'BLOCK(30,1)' -stim_label 2 odor \
	-stim_times_IM 3 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_question_tape-odor.1D 'BLOCK(24,1)' -stim_label 3 question \
	-stim_file 4 'dfile.r0103.1D[0]' -stim_base 4 -stim_label 4 roll  \
	-stim_file 5 'dfile.r0103.1D[1]' -stim_base 5 -stim_label 5 pitch \
	-stim_file 6 'dfile.r0103.1D[2]' -stim_base 6 -stim_label 6 yaw   \
	-stim_file 7 'dfile.r0103.1D[3]' -stim_base 7 -stim_label 7 dS    \
	-stim_file 8 'dfile.r0103.1D[4]' -stim_base 8 -stim_label 8 dL    \
	-stim_file 9 'dfile.r0103.1D[5]' -stim_base 9 -stim_label 9 dP    \
	-gltsym 'SYM: tape - odor' -glt_label 1 tape-odor \
    -fout -tout -full_first -x1D ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/Xmat_tape-odor.${sub}.x1D \
    -fitts ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/fitts_r_tape-odor.${sub} \
    -bucket ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/stats_tape-odor.${sub}



deconvolve command #2

## This is getting contrast between odor (run 3) - tape (run 1)
	echo "Running contrast odor - tape" 
	3dDeconvolve -input pb05.${sub}.r03.detrend+orig[2..$] \
	pb05.${sub}.r01.detrend+orig  \
	-polort 2 -num_stimts 9 \
	-mask ~/Volumes/Coutanche/Shared/Projects/Craving/AnatomicalData/${sub}/brain_mask_${sub}_re+orig \
	-stim_times_IM 1 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_odor.1D 'BLOCK(30,1)' -stim_label 1 odor \
	-stim_times_IM 2 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_odor-tape_tape.1D 'BLOCK(30,1)' -stim_label 2 tape \
	-stim_times_IM 3 ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/timing_files/timing_question_odor-tape.1D 'BLOCK(24,1)' -stim_label 3 question \
	-stim_file 4 'dfile.r0301.1D[0]' -stim_base 4 -stim_label 4 roll  \
	-stim_file 5 'dfile.r0301.1D[1]' -stim_base 5 -stim_label 5 pitch \
	-stim_file 6 'dfile.r0301.1D[2]' -stim_base 6 -stim_label 6 yaw   \
	-stim_file 7 'dfile.r0301.1D[3]' -stim_base 7 -stim_label 7 dS    \
	-stim_file 8 'dfile.r0301.1D[4]' -stim_base 8 -stim_label 8 dL    \
	-stim_file 9 'dfile.r0301.1D[5]' -stim_base 9 -stim_label 9 dP    \
	-gltsym 'SYM: odor - tape' -glt_label 1 odor-tape \
    -fout -tout -full_first -x1D ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/Xmat_odor-tape.${sub}.x1D \
    -fitts ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/fitts_r_odor-tape.${sub} \
    -bucket ~/Volumes/Coutanche/Shared/Projects/Craving/Analysis/BetaWeights/stats/stats_odor-tape.${sub}

Hello!

We have been trying to get contrast and beta weights between two different runs, where the conditions are called tape and odor. Both of these runs are block design. For the odor condition we are discarding the first 4 seconds of the block, and the TR is 2 seconds so essentially first two sub-bricks of the odor run (which is run 3). We are also merging the motion files for these particular runs separately hence the name dfile.r0301.1D which is the concatenated motion file for run3 and run1. For this merged motion file as well we have removed the first two rows of the dfile.r03.1D file. The number of sub bricks in tape run (run 1) are 41 and number of sub bricks in odor run (run 3) are 38. So the total concatenated sub-bricks after removing the first two should be 77.

Initially we used the first deconvolve command with odor run (run 3) as the second input. When we ran the command it gave us these warnings:

++ Number of time points: 75 (no censoring)

  • Number of parameters: 16 [12 baseline ; 4 signal]

*+ WARNING: -stim_file 4: file length is 77, longer than expected 75 (from dataset)

*+ WARNING: -stim_file 5: file length is 77, longer than expected 75 (from dataset)

*+ WARNING: -stim_file 6: file length is 77, longer than expected 75 (from dataset)

*+ WARNING: -stim_file 7: file length is 77, longer than expected 75 (from dataset)

*+ WARNING: -stim_file 8: file length is 77, longer than expected 75 (from dataset)

*+ WARNING: -stim_file 9: file length is 77, longer than expected 75 (from dataset)

But when I switched the input order of the runs as shown in the deconvolve command #2 the warnings went away. Another thing that I noticed was warnings went away when input pb05.{sub}.r03.detrend+orig\[1..] for the deconvolve command #1 as well. So, inputting this as the second input was removing 2 sub-bricks.

I am not sure why pb05.{sub}.r03.detrend+orig\[2..] is removing 2 sub-bricks when its the first input but 4 sub-bricks when it's the second input. I thought that switching up the order would have not affected the number of sub-bricks getting considered for the deconvolution. Let me know if you need any more information and have any idea what is happening with it. What would you recommend to do? Thank you!

Regards,

Medha Sharma

Hi Medha,

Your description of what is happening is correct, and it is intentional.

But this is a subtle point about input datasets that I did not realize 3dDeconvolve was doing under the hood. It is putting the datasets together as if you had enter them as:

-input "D1 D2[2..$]"

And *that* is a special case of auto-catenation of input datasets buried in afni -help under "CATENATED AND WILDCARD DATASET NAMES". Essentially, if inputs are given (as a single argument, as in with quotes) like "D1 D2 D3 D4 D5[a..b]", then the "[a..b]" applies to all of the inputs, as if it followed each one. It is a convenience operation so that the selector does not need to be written for every input.

But if [a..b] is not at the very end, they will apply individually, as with "D1[a..b] D2 D3[c..d] D4". Here a..b and c..d only apply to D1 and D3, respectively.

Anyway, so you should either provide an additional sub-brick selection:

-input pb05.${sub}.r01.detrend+orig[0..$] \
	      pb05.${sub}.r03.detrend+orig[2..$] \

or use 3dTcat to remove the initial volumes of the odor run.

Does that seem reasonable?

-rick

Hey Rick!

Thank you for letting me know. This makes so much more sense! I have changed the script and taken run 3 as the first input, basically the deconvolve command #2 in the code section. Which like you said will only apply sub-brick selection to that run. Do you think that is reasonable to do? Or else I will take your suggestion and give individual sub-brick selection to both the runs. But I will keep this in mind for future commands.

Thank you so much!

Regards,

Medha

Hi Medha,

Great, any of those options would do.

As a tiny point, I would lean towards removing the unwanted time points before running 3dDeconvolve, it seems cleaner. But just to be sure, are those pre-steady state volumes, or is there some other reason to remove them? That isn't a lot of time points for doing a regression, but I guess you are just getting the magnitude of a single (long) event response.

Thanks,

-rick

Hello Rick,

Yeah, it makes sense to remove the TRs before running the deconvolve command. Those TRs are steady state timepoints. We are removing those time points to be consistent with the block times across runs (run 1 and run 2 are 30 seconds long and run 3 was 34 seconds long). Another reason was because for the third run, the stimulus is sent manually. So, we are hoping that removing first few seconds might also remove any noise generated because of any human error. Yeah, for now the aim is to get the contrasts and magnitude of activations for these different conditions and compare them with each other.

Thank you so much for your help!

Regards,

Medha