To use to3d for reading in text files, consider this example where we dump some numbers as text into a file from a dataset and then read them back in with to3d.
# resample the dataset to a very coarse dataset just for an example here
3dresample -prefix TT_N27_junk_8.nii.gz -dxyz 8 8 8 -input TT_N27+tlrc
# dump the values of the dataset out to a text file
3dmaskdump -noijk TT_N27_junk_8.nii.gz > TT_N27_junk_8_ascii.txt
# get the number of rows, columns and slices to use for to3d
3dinfo TT_N27_junk_8.nii.gz
# read the data back in. The geomparent gives the orientation and origin of the data
to3d -prefix TT_N27_junk_copy.nii.gz -geomparent TT_N27_junk_8.nii.gz "3As:20:24:19:TT_N27_junk_8_ascii.txt"
Also consider using 3dUndump to do this (with data in the form of "x y z value" or "i j k value"). See this recent post for more information:
[
afni.nimh.nih.gov]