Scroll to navigation

GIFTI_TOOL(1) User Commands GIFTI_TOOL(1)

NAME

gifti_tool - gifti_tool - create, display, modify or compare GIFTI datasets

DESCRIPTION

------------------------------------------------------------ gifti_tool - create, display, modify or compare GIFTI datasets

general examples:
1. read in a GIFTI dataset (set verbose level?
show GIFTI dataset?)
gifti_tool -infile dset.gii gifti_tool -infile dset.gii -verb 3 gifti_tool -infile dset.gii -show_gifti
2. copy a GIFTI dataset
a. create a simple copy, and check for differences
gifti_tool -infile dset.gii -write_gifti copy.gii diff dset.gii copy.gii
b. copy only 3 DataArray indices: 4, 0, 5
\
-read_DAs 4 0 5
OR
\
-write_gifti ts3.gii
3. write datasets in other formats
a. FreeSurfer-style .asc surface dataset
gifti_tool -infile pial.gii -write_asc pial.asc
b. .1D time series surface dataset
gifti_tool -infile time_series.gii -write_1D ts.1D
4. create a new gifti dataset from nothing, where
a. - the dataset has 3 DataArray elements
- the data will be of type 'short' (NIFTI_TYPE_INT16) - the intent codes will reflect a t-test - the data will be 2-dimensional (per DataArray), 5 by 2 shorts - memory will be allocated for the data (a modification option) - the result will be written to created.gii
\
-new_intent NIFTI_INTENT_TTEST \ -new_ndim 2 -new_dims 5 2 0 0 0 0 \ -mod_add_data -write_gifti created.gii
b. - the dataset has 12 DataArray elements (40 floats each)
- the data is partitioned over 2 files (so 6*40 floats in each)
** Note: since dataset creation does not add data (without
-mod_add_data), this operation will not create or try to overwrite the external datafiles.
\
\
\
-write_gifti points_to_extern.gii
5. modify a gifti dataset
a. apply various modifications at the GIFTI level and to all DAs
- set the Version attribute at the GIFTI level - set 'Date' as GIFTI MetaData, with value of today's date - set 'Description' as GIFTI MetaData, with some value - set all DA Intent attributes to be an F-test - set 'Name' as an attribute of all DAs, with some value - read created.gii, and write to first_mod.gii
\
\
\
\
\
-infile created.gii -write_gifti first_mod.gii
b. modify the 'Name' attribute is DA index #42 only
\
\
-infile stats.gii -write_gifti mod_stats.gii
c. set the data to point to a single external data file, without
overwriting the external file on write (so use -no_data), and where the DataArrays will point to sequential partitions of the file
\
\
-write_gifti extern.gii
d. convert a POINTSET/TRIANGLE Base64 format dataset to one where
to one where the data is external (raw binary):
\
-write_gifti inflated.external.gii
e. convert a 5 run time series dataset from internal Base64 format
to one where the data is external (raw binary):
as one external file:
\
\
-write_gifti epi.ext.5runs.gii
as 5 external files (1 per run):
\
-set_extern_filelist data.5runs.r{1,2,3,4,5}.bin \ -write_gifti epi.ext.5runs.gii
f. convert the previous external dataset back to internal form
(i.e. it should be the same as epi.5runs.gii)
\
\
-write_gifti epi.int.5runs.gii
6. compare 2 gifti datasets
a. compare GIFTI structures, compare data, and report all diffs
-infiles created.gii first_mod.gii
b. report approximate comparison: focusing on data, but allowing
for small, fractional differences varying per datatype
-infiles created.gii first_mod.gii
7. copy MetaData from one dataset to another
(any old Value will be replaced if the Name already exists)
- copy every (ALL) MetaData element at the GIFTI level - copy MetaData named 'Label' per DataArray element - only apply DataArray copies to indices 0, 3 and 6 - first input file is the source, second is the destination - write the modified 'destination.gii' dataset to meta_copy.gii
\
\
\
\
-write_gifti meta_copy.gii

----------------------------------------------------------------------

(all warranties are void in Montana, and after 4 pm on Tuesdays)

----------------------------------------------------------------------

informational options:
: display this help
: display the modification history of gifti_tool
: display the gifti_tool version
: display thd modification history of gifticlib
: display gifticlib version
: display the gifti DTD URL
: display whether the zlib is linked in library

----------------------------------------

general/input options
TYPE : set method for checking base64 errors
e.g. -b64_check COUNT
This option sets the preference for how to deal with errors in Base64 encoded data (whether compressed or not). The default is SKIPnCOUNT, which skips any illegal characters, and reports a count of the number found.
: no checks - assume all is well
: report whether errors were found
: count the number of bad chars
: ignore any bad characters
TYPE = SKIPnCOUNT : ignore but count bad characters
This default adds perhaps 10% to the reading time.
SIZE : set the buffer size (given to expat library)
e.g. -buf_size 1024

-DA_index_list I0 I1 ... : specify a list of DataArray indices

e.g. -DA_index_list 0 e.g. -DA_index_list 0 17 19
This option is used to specify a list of DataArray indices for use via some other option (such as -copy_DA_meta).
Each DataArray element corresponding to one of the given indices will have the appropriate action applied, such as copying a given MetaData element from the source dataset to the destination dataset.
Note that this differs from -read_DAs, which specifies which DataArray elements to even read in. Both options could be used in the same command, such as if one wanted to copy the 'Name' MetaData from index 17 of a source dataset into the MetaData of the first DataArray in a dataset with only two DataArray elements.
\
\
\
\
-DA_index_list 0
Note that DA_index_list applies to the indices _after_ the datasets are read in.
: test whether each gifti dataset is valid
This performs a consistency check on each input GIFTI dataset. Lists and dimensions must be consistent.
INPUT : specify one or more GIFTI datasets as input
e.g. -input pial.gii e.g. -input run1.gii run2.gii e.g. -input MAKE_IM (create a new image) e.g. -input run1.gii'[3,4,5]' (read DAs 3,4,5 ) e.g. -input run1.gii'[0..16(2)]' (read evens from 0 to 16) e.g. -input run1.gii'[4..$]' (read all but 0..3)
One is via the
That 'input' filename tell gifti_tool to
create a new dataset, applying any '-new_*' options to it.
(refer to options: -new_*)
The other special way is to specify which DataArray elements should be read in, using AFNI-style syntax within '[]'. The quotes prevent the shell from interpreting the brackets.
DataArray indices are zero-based.
The list of DAs can be comma-delimited, and can use '..' or '-' to specify a range, and a value in parentheses to be used as a step. The '$' character means the last index (numDA-1).
: do not read in data
This option means not to read in the Data element in any DataArray, akin to reading only the header.
: do not allow the library to modify metadata
By default, the library may update some metadata fields, such as 'gifticlib-version'. The -no_updates option will prevent that operation.
: read DataArray list indices s0,... from input
e.g. -read_DAs 0 4 3 3 8 e.g. -input run1.gii -read_DAs 0 2 4 6 8 e.g. -input run1.gii'[0..8(2)]' (same effect)
This is a
simplified form of using brackets '[]' with -input names.
: show final gifti image
Display all of the dataset information on the screen (sans data). This includes meta data and all DataArray elements.
VERB : set verbose level (default: 1)
e.g. -verb 2
The VERB level can
be from 0 to 8, currently.
Level 0 is considered 'quiet' mode, and should only report serious errors. Level 1 is the default.

----------------------------------------

output options
TYPE : set the data encoding for any output file
e.g. -encoding BASE64GZIP
: ASCII encoding
: base64 binary
TYPE = BASE64GZIP : base64 compressed binary
This operation can also be performed via -mod_DA_atr: e.g. -mod_DA_atr Encoding BASE64GZIP

-set_extern_filelist F1 F2 ... : store data in external files

e.g. -set_extern_filelist run.1.data run.2.data run.3.data e.g. -set_extern_filelist runs.all.data e.g. -set_extern_filelist points.data triangles.data
Data is normally stored within the XML file as numerical text or Base64 encoded raw or compressed data.
With use of this option, users can set to have data stored in external binary files (neither encoded nor compressed) upon a write operation.
External file storage is subject to a couple of restrictions:
- GIFTI requires that they are in the same directory
- the library allows multiple DataArrays per file, but each
DataArray within the same file must have the same size (this is a gifticlib limit, not a GIFTI limit)
OK : equal data in 1 file OK : equal data in k files, numDA is multiple of k BAD: equal data in k files, numDA is NOT multiple of k OK : points/triangles in 2 files BAD: points/triangles in 1 file (sizes differ)
The most basic use of this option is to convert data from internal to external. See examples 5d and 5e.
Note that one can also create a GIFTI dataset out of nothing and use this option to point to existing external data files. This would help conversion from other dataset formats. See example 5c.
Note that one can convert from an external data format to internal just by modifying the -encoding. See example 5f.
DSET : write out data to AFNI style 1D file
e.g. -write_1D stats.1D
This
restriction could be lifted if there is interest.
DSET : write out geometry to FreeSurfer style ASC file
e.g. -write_asc pial.asc
To write a surface file in FreeSurfer asc format, it must contain DataArray elements of intent NIFTI_INTENT_POINTSET and NIFTI_INTENT_TRIANGLE. The POINTSET data is written as node coordinates and the TRIANGLE data as triangles (node index triplets).

-write_gifti DSET : write out dataset as gifti image

e.g. -write_gifti new.pial.gii
LEVEL : set compression level (-1 or 0..9)
Some
LEVEL values are noteworthy:
-1
: specify to use the default of zlib (currently 6)
0
: no compression (but still needs a few extra bytes)
1
: fastest but weakest compression
6
: default (good speed/compression trade-off)
9
: slowest but strongest compression

----------------------------------------

modification options
These modification options will affect every DataArray element specified by the -mod_DAs option. If the option is not used, then ALL DataArray elements will be affected.
: add data to empty DataArray elements
Datasets can be
This will allocate data
and fill it with zeros of the given type.
NAME VALUE : set the NAME=VALUE attribute pair
e.g. -mod_DA_atr Intent NIFTI_INTENT_ZSCORE
This option will set the DataArray attribute corresponding to NAME to the value, VALUE. Attribute name=value pairs are specified in the gifti DTD (see -gifti_dtd_url).
One NAME=VALUE pair can be specified per -mod_DA_atr option. Multiple -mod_DA_atr options can be used.

-mod_DA_meta NAME VALUE : set the NAME=VALUE pair in DA's MetaData

e.g. -mod_DA_meta Description 'the best dataset, ever'
Add a MetaData entry to each DataArray element for this NAME and VALUE. If 'NAME' already exists, the old value is replaced by VALUE.
: specify the set of DataArrays to modify
e.g. -mod_DAs 0 4 5
All the
If
no -mod_DAs option is used, the operations apply to ALL DataArray elements.
Note that the indices are zero-based, 0 .. numDA-1.
NAME VALUE : set the GIFTI NAME=VALUE attribute pair
e.g. -mod_gim_atr Version 3.141592
Set the GIFTI element attribute corresponding to NAME to the value, VALUE.
Given that numDA is computed and version will rarely change, this option will probably not feel much love.

-mod_gim_meta NAME VALUE : add this pair to the GIFTI MetaData

e.g. -mod_gim_meta date "`date`"
Add a MetaData entry to each DataArray element for this NAME and VALUE pair. If NAME exists, VALUE will replace the old value.
: change all DataArray data to float
Convert all DataArray elements of all datasets to datatype NIFTI_TYPE_FLOAT32 (4-byte floats). If the data does not actually exist, only the attribute will be set. Otherwise all of the data will be converted. There are some types for which this operation may not be appropriate.

----------------------------------------

creation (new dataset) options
: create a new GIFTI dataset
NUMDA : new dataset will have NUMDA DataArray elements e.g. -new_numDA 3
e.g. -new_intent NIFTI_INTENT_FTEST
TYPE : set datatype to TYPE e.g. -new_dtype NIFTI_TYPE_FLOAT32

-new_ndim NUMDIMS : set Dimensionality to NUMDIMS (see -new_dims)

e.g. -new_ndim 2 -new_dims 7 2 0 0 0 0
: allocate space for data in created dataset

----------------------------------------

comparison options
: approximate comparison of GIFTI dsets
This compares all data elements of the two GIFTI structures. The attributes, MetaData, etc. are ignored if they do not pertain directly to the data.
The comparisons allow for small, fractional differences, which depend on the datatype.
: specifies to compare two GIFTI datasets
This compares all elements of the two GIFTI structures. The attributes, LabelTabels, MetaData are compared, and then each of the included DataArray elements. All sub-structures of the DataArrays are compared, except for the actual 'data', which requires the '-compare_data' flag.
There must be exactly 2 input datasets to use this option. See example #7 for sample usage.
: flag to request comparison of the data
Data comparison is done per DataArray element.
Comparing data is a separate operation from comparing GIFTI. Neither implies the other.
: set the verbose level of comparisons
Setting the
verb level will have the following effect:
0 : quiet, only return whether there was a difference 1 : show whether there was a difference 2 : show whether there was a difference per DataArray 3 : show all differences

----------------------------------------

MetaData copy options
: copy MetaData with name MD_NAME
e.g. -copy_gifti_meta AFNI_History
Copy the MetaData with the given name from the first input dataset to the second (last). This applies to MetaData at the GIFTI level (not in the DataArray elements).
: copy MetaData with name MD_NAME
e.g. -copy_DA_meta intent_p1
Copy the MetaData with the given name from the first input dataset to the second (last). This applies to MetaData at DataArray level.
This will apply to all DataArray elements, unless the -DA_index_list option is used to specify a zero-based index list.
see also -DA_index_list

------------------------------------------------------------ see the GIfTI community web site at:

http://www.nitrc.org/projects/gifti

R Reynolds, National Institutes of Health ------------------------------------------------------------

SEE ALSO

The full documentation for gifti_tool is maintained as a Texinfo manual. If the info and gifti_tool programs are properly installed at your site, the command

info gifti_tool

should give you access to the complete manual.

June 2022 gifti_tool version 1.3, 24 December 2009