First, can spm only perform motion correction on multiple 3D nii files? Can’t SPM12 perform motion correction on 4D nifit files directly?
Second, why can’t multiple 3D nii be correctly converted into a 4D file after motion correction? Also need to manually enter the TR value?
Third, the mean file after motion correction should be the average value of the original fMRI calculated, is my understanding correct? Should 3dStats be used in AFNI?
SPM should give you the same “format” that it got as input: 4D files in → 4D files out. 3D files in → 3D files out. If you want to convert to 3Ds to 4Ds then you should indeed use the “3D to 4D File Conversion” utility (batch → SPM → Util → 3D to 4D File Conversion) and indeed this step requires you to input the TR value.
Though making the 3D to 4D conversion might be better done at the very beginning of your pipeline.
SPM will provide you a single mean image across all the runs you provided as input for the realign step.
It will not provide you with one mean image per run.
If you want to get a mean image per run on top of the mean image across runs, you can then use your favorite tool to do that. Both AFNI and SPM have tooling to do that.