Manual realignment

Dear all,

I am preprocessing a large batch of subjects and with some subjects the registration is significantly off. I am looking into manually reorienting the images (setting origin, possible rotating…etc) in a similar way that can be done in SPM. I am not sure if this option is available in AFNI. I tried to do it in SPM and have AFNI read the image but it doesn’t seem it is reading the header file correctly.



Stepping back a pace, what kinds of images are you aligning, and what AFNI functions are you using for this?

There is AFNI functionality for doing manual adjustment (the "nudge"ing plug-in: open AFNI → click “Define Datamode”, a button in the middle, then click “Plugins” in the lower right of the panel that opens, and select “Nudge Dataset” in then menu that opens), as well as 3drotate on the commandline, which might be useful.

However, it might be better (both for the current alignments and in the longer term) to sort out alignment on the command line.


Thank you pt. I am using to preprocess resting state images. I am essentially registering the anatomical to the EPI and using non-linear warping for standardization. Some of the images turn out fine but quite a few of them are far off. I was looking for something similar to SPM’s function to reset the origin or tilt/rotate the image; this essentially just changes the origin without doing anything to the image. I was reading the afni_proc file and apparently there are a couple of setting that may help (-giant move) when specifying alignment options, but I think doing it manually first before running through the command may be more reliable.


Hi, George-

Well, indeed some of those options like -giant_move might help. Skullstripping your brain before using might also help (for example, how does your skullstripped brain look in the output of If there is lots of extraneous stuff or parts missing, that could be bad for alignment). If your EPI and anatomical dsets don’t have a lot of overlap initially, as well, then putting the center of mass would be a good start, even without the full giant_move.

Adjusting the cost function to include some others might help, for example use the option:
-align_opts_aea -cost lpc+ZZ -giant_move


I suggest using the script @SSwarper to skull strip and nonlinearly warp the anat to the MNI template.
Then use the outputs from that script in to bypass the skull stripping and warping options.

I once had a lot of bad registration cases. Until I found I was saying “-anat_has_skull no” in my script (since I copied the script from something else), and in fact the anat DID have skull. This simple mistake cost me about a day.

Thank you pt and RWCox.
I “deobliqued” my EPI and then used @Align_Centers to center the EPI and the skull stripped anatomical at the center of mass before running and this seems to have solved the issue. I don’t think I need -giant_move or use another cost function just yet.

Are there any concerns for aligning the EPI and the anatomical before running the other preprocessing steps? I think this was suggested somewhere on the forum prior.

I am also encountering a warning message from 3dTStat : “Input dataset is not 3D+time; assuming TR=1.0”. Should I be concerned? The registration and the alignment seem pretty good now.


I am just going through more data now and even though what I mentioned before corrected many of the issues: one issue with some subjects is that EPI data does not seem very well skullstripped which is throwing off the alignment with the anatomical (skull of EPI data on brain of anatomical). Any way to address this issue?

Thanks a lot,

thank you for your helpful subject , but I have a question.

I have a dataset which the writers of paper said for normalization wh did this step

Structural images were normalized (spatially warped) to a standard
template brain (the MNI avg152T1.img) using SPM2 software (Wellcome Department of
Cognitive Neurology, UCL) using default options (7 x 8 x 7 nonlinear basis functions), and the
warping parameters were applied to functional images for each subject.

my question is: how can I do this in SPM? I should normalize structural image to MNIavg152T1, but in spm12 , normalization (estimate), there is no chois for MNI template!!!
Kind regards,Bestia

We are totally unable to answer questions about SPM usage details – our mental energy is bent towards AFNI. You might try emailing the authors of the paper you mention, or joining the SPM email list and asking your questions about SPM in that forum.