3DDeconvolve with too many (240) stimuli conditions/regressors?

Hi, is there an efficient way to pass to 3dDeconvolve the stimulus timing files and labels when I have a very large amount (240)? I get a series of errors when I try to run my afni_proc file where various commands are not found. I have tried to find an errant space or something in the preceding lines but can't find the source of my issue. Is there a limit to the number of stimuli timing files/labels that can be used? Or perhaps is there a more efficient and less error-prone way of passing then in the form of 1D or text files? Thank you for the help!


It would probably help if you copy+pasted:

  • your afni_proc.py command
  • the exact errors you are getting (or emailing the output.proc.${subj} file that you typically get when you run afni_proc.py in the default way).

There are different things than can be happening. For example, if you have 240 regressors and only 100 time points, you are running out of degrees of freedom in the model.


I have 12 runs, each of 320 seconds. I have experimented with various things and have worked out (in my case) that it works if I include up to and including 20 stimulus types, but any more than that I get errors. An example of the error I am getting:
-regress_basis: Command not found.
Which I typically get when I include a space after an \ or some other mistyped thing. However, when I cut the -regress_stim_times and -regress_stim_labels down to 20 my afni_proc script works fine.

My afni_proc command with a subset of conditions (24) which does not work is:

afni_proc.py -subj_id sub-2_task-Ident4 \
        -blocks mask scale regress  \
	-copy_files /home/20240111-ST002-S2_ORE_LV_t1_mp2rage_sag_p3_0_denoised.75mm_20240111120621_61.nii\
	-regress_stim_times \
            /home/reg_try/identity_all/bf02S_0.4b.txt \
            /home/reg_try/identity_all/bf06S_0.4b.txt \
            /home/reg_try/identity_all/bf12S_0.4b.txt \
            /home/reg_try/identity_all/bf15S_0.4b.txt \
            /home/reg_try/identity_all/bf17S_0.4b.txt \
            /home/reg_try/identity_all/bf18S_0.4b.txt \
            /home/reg_try/identity_all/bm04S_0.4b.txt \
            /home/reg_try/identity_all/bm05S_0.4b.txt \
            /home/reg_try/identity_all/bm06S_0.4b.txt \
            /home/reg_try/identity_all/bm07S_0.4b.txt \
            /home/reg_try/identity_all/bm13S_0.4b.txt \
            /home/reg_try/identity_all/bm14S_0.4b.txt \
            /home/reg_try/identity_all/wf01S_0.4b.txt \
            /home/reg_try/identity_all/wf02S_0.4b.txt \
            /home/reg_try/identity_all/wf05S_0.4b.txt \
            /home/reg_try/identity_all/wf06S_0.4b.txt \
            /home/reg_try/identity_all/wf07S_0.4b.txt \
            /home/reg_try/identity_all/wf08S_0.4b.txt \
            /home/reg_try/identity_all/wm03S_0.4b.txt \
            /home/reg_try/identity_all/wm04S_0.4b.txt \
            /home/reg_try/identity_all/wm06S_0.4b.txt \
            /home/reg_try/identity_all/wm07S_0.4b.txt \
            /home/reg_try/identity_all/wm09S_0.4b.txt \
            /home/reg_try/identity_all/wm11S_0.4b.txt \
        -dsets  \
        -regress_stim_labels \
            1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 \
        -regress_basis 'SPMG1(2)' \
        -regress_opts_3dD  -jobs 12 -num_glt 1 \
        -gltsym 'SYM: 1 -2' \
		-glt_label 1 B4vW4 \
        -regress_reml_exec \
        -regress_est_blur_epits \
        -regress_est_blur_errts \
        -regress_run_clustsim no \
        -regress_compute_fitts \
 	-regress_make_cbucket yes

Seeing the full terminal output of this would be helpful. You could email myself (and cc Rick Reynolds, since he will have more detailed advice than me!).

One question is: does /home/reg_try/identity_all/bf02S_0.4b.txt go with stim label "2"? Because your -regress_stim_times .. list doesn't look ordered with your stim labels. (But important followup on stim labels in next paragraph.)

Also, I would have through your -regress_stim_labels .. would have to start with a letter in each case, so that any -gltsym .. symbolic reconstructions would not be confused for just numbers. For example, to the given 1 -2 GLT in line 46 looks like just literally "1-2"---I don't think the program could detect that "1" is a label and not a number. That is similar to trying to use "1" as a variable in Python or in a shell script---that would lead to an error.

I don't think -copy_files ... is what you want to bring in the anatomical---shouldn't that be -copy_anat ..?

Also, what is perhaps a sidenote, is there a reason this is split out from what appears to be prior afni_proc.py procressing? That will make the QC HTML in each case less informative.

You might be interested in adding:

-regress_make_ideal_sum   sum_ideal.1D \

to see the idealized sum response, too.

And are you not including any motion/outlier censoring regressors?


HI, thanks for the suggestions and the help. I will email the terminal output, it contains lists of everything in my various directories when the script assesses the input files, making it very long.
At this point I am setting up the pipeline of processing, the goal is to ultimately have afni_proc process all of it, but I am troubleshooting some things (and learning along the way) so for the sake of timing I broke it into sections so I could run and re-run the regress steps.

I had created the labels 1:24 to correspond to the stim timing so bf02S_0.4b.txt would be number 1, bf06S_0.4b.txt would be 2, etc.
I have now changed the labels to be a letter number mix (a1, a2, etc), and I can see that the error starts at this section:

? -regress_stim_labels
? a1 a2 a3
-- including default: -find_var_line_blocks tcat
-- tcat: reps is now 320
++ updating polort to 3, from run len 320.0 s
-- have 1 ROI dict entries ...
** cmd_regress: have 24 stims but 3 labels
** script creation failure for block 'regress'

And this varies, sometimes it will read up to 7 labels and then do the same thing. There is nothing in the formating that would cause it that I can see.
I had used the copy_files as a generic command, I had previously used it to copy other files in and reused it for the anat.
3ddeconvolve has been automatically making the sum_ideal.1D file for me, I think it made a correct assumption about my ignorance!
And I am going to include the motion files, I have just been trying to get afni_proc to generate the script first so I can check that it is working correctly, so I have been limiting what I have been feeding into it to decrease the amount of things I can mess up at once.
Thanks again for the help!

Thanks to Rick and Paul for helping me with this. My issue was stemming from the fact that I was running my script by pasting it into the terminal rather than running it from a file. Pretty simple fix!

Thanks again for the help.