Import AFNI contrast files to NeuroVault

Hi

how can I import AFNI (.brik .head) contrast files to Neurovault?

thanks!

There’s a 3dAFNItoNIFTI command that might help !

https://afni.nimh.nih.gov/pub/dist/doc/program_help/3dAFNItoNIFTI.html

2 Likes

Hi-
Replying to this a bit late, but some things to note:

AFNI can both read and write NIFTI; in many programs, to write NIFTI you just have your “-prefix …” filename end with “.nii” or “.nii.gz”.

In addition to the program noted by @emdupre, there are also the following options:

3dcopy DSET*.HEAD NEW_DSET.nii.gz

Since AFNI allows having 4D volumes (that is, like a time axis of data sets, or just stacking volumes together in sequence), we also have functionality to select subsets of volumes (like “slicing” in Python).

Let’s say a dset MY_DSET has 30 volumes; AFNI uses zerobased counting for indexes (again, like Python, but different than say Matlab), so the index range goes from [0, 29]. You can use a 3dcalc command to “copy” either the full dset or a subset to NIFTI. The rules for indexes are fairly straightforward:

  • you use “…” to specify an (inclusive) interval between two values, so
    “[A…B]” gets volumes A to B, inclusively.
  • you use “,” to separate items in a list, which can be either individual values or ranges:
    “[A…B,F,H,M…P]”.
  • the dollar sign “$” is a special character meaning “the last index”
  • different shells treat the square brackets differently, so it is simplest to just put either single or double quotes around the index brackets.

Some examples of using 3dcalc to copy datasets:

full copy

3dcalc -a MY_DSET -expr “a” -prefix NEW_DSET.nii.gz

select just the “first” volume in the dset to copy

3dcalc -a MY_DSET"[0]" -expr “a” -prefix NEW_DSET_firstvol.nii.gz

select just the first 14 volumes and the 18th vol in the dset to copy

3dcalc -a MY_DSET"[0…13,17]" -expr “a” -prefix NEW_DSET_firstvol.nii.gz

select just the vols from index 15 to The End of the dset in the dset to copy

3dcalc -a MY_DSET"[15…$]" -expr “a” -prefix NEW_DSET_firstvol.nii.gz

–pt

1 Like