copy header info using afni tools

AFNI version info (afni -ver):

Hi All,

I used mri_synthstrip to skull strip PET image and want to copy the header information of the original image onto the skull-striped image using afni tools.

Can you let me know how it should be done ?



hi Rito-

assuming it is appropriate to do so, you can try 3drefit with options such as
-atrcopy or -copyaux or -duporigin


Hi, Rito-

Copying the header is doable, but comes with caveats. For example, you have to make sure the correct datatype is specified (byte, short, float)---it will be simplest if the before and after datasets have the same type, and you could use 3dcalc to pre-prepare one dset, if necessary to be a certain type and to not have any scaling:

3dcalc -a DSET -expr 'a' -prefix DSET_NEWTYPE -datum {byte|short|float} -nscale

You should also hope that the dataset orientations are the same (eek, if they aren't!), as well as the same grid. It would be even simply if that tool output a dataset with correct header information on its own (it really doesn't??).

You can do this most easily with using the BRIK/HEAD format as an intermediary, since the data and header area, by definition separated. I'll call the dsets DSET_BEFORE and DSET_AFTER.

First, get BRIK/HEAD format of each. NB: do this even if your dsets are already in BRIK/HEAD format, because we are going to overwrite a HEAD file

# copy dsets to BRIK/HEAD format
3dcopy DSET_BEFORE tmp_before
3dcopy DSET_AFTER tmp_after
# ... after which, you should have 2 dsets: 
#     tmp_before+orig.{BRIK,HEAD},
#     tmp_after+orig.{BRIK,HEAD} 

Then, you can copy the *.HEAD file from DSET_BEFORE to overwrite that of DSET_AFTER:

cp tmp_before+orig.HEAD tmp_after+orig.HEAD

Then, you should purge as much extraneous header info as possible from the newly created dset, because some might not be applicable (like stats, min/max, history, etc.):

3drefit -denote -clear_bstat tmp_after+orig.HEAD

Then I would regenerate stat info:

3drefit -redo_bstat tmp_after+orig.HEAD

... and then I would check the new dataset that everything seems OK---overlaying/underlaying, for example, esp. if you expect them to have voxelwise correspondence in places.

It is possible I am overlooking something here, but that is what I would try to start.


1 Like