convert .Nii to AFNI dataset

I have few English skill but I try harder.
Please help me.

I want to convert .Nii Files to AFNI dataset.
I received .nii files from my boss, then the file has number 1~200.nii (perhaps it applies Slice Number).
I want to integrate all 1~200.nii, and analyze data in AFNI dataset format.
However, all .nii convert AFNI dataset one by one, so I could not analyze them.
If inetgrating .nii and converting AFNI dataset are possible, I want to know methods.


Hi Masaki,

Would you please be very precise about the names?
What is the output of this, for example?

ls -1 *.nii | head -n 20

  • rick

Hi Nick,

Thank you for your reply.

output "ls -1 | *.nii | head -n 20 is…


like this.

In another folder, I have a file “anat_01.nii”; it’s maybe t1_mprage, and “field_map.nii”.

Do you have any ideas?
If you need other information to solve the problems, I present it.

Hi Masaki,
That looks like it should be extremely easy, with the
key point being that the alphabetical listing of the file
names seems to match the time ordering. The numbers
in the names are zero-padded. Without zero-padding,
the order would not be alphabetical.

Since this is a time series dataset, you can specify the
TR and any known slice order. Assuming TR=2s, for
example, you should be able to run something like:

3dTcat -tr 2 -prefix concat.illusion01_func01.nii    illusion01_func01_*.nii

If there is a known slice order like alt+z, you could add
that as well (-tpattern alt+z).

Or you could remove the trailing .nii from the -prefix to
make AFNI format (though NIFTI is fine).

Does that seem reasonable?

  • rick

Hi Rick,

Thank you very much!

I completely solved my problem, and will be able to proceed with the analysis.

AFNI is difficult to use for me because of low English skills, and no explanation or manual in Japan (there is if the manual SPM).
However, it is very powerful and suitable software to analysis, so that I want to become skilled.

Anyway, thank you again. You’ve been very helpful.


Hi Masaki,

There is a lot of AFNI documentation, it is just not set up as
a complete manual. If you post some specific operations
that you are trying to perform, we can reference appropriate

  • rick

Hi, rick,

i see it yes, thank you very much.
I will ask you help if I stuck, with no hesitation.

I’ll try.
Thank you for your kindly advice.