gifti
¶
GIfTI format IO
giftiio |
|
gifti |
Module: gifti.gifti
¶
GiftiCoordSystem ([dataspace, xformspace, xform]) |
|
GiftiDataArray ([data]) |
|
GiftiImage ([meta, labeltable, darrays, version]) |
|
GiftiLabel ([key, label, red, green, blue, alpha]) |
|
GiftiLabelTable () |
|
GiftiMetaData ([nvpair]) |
A list of GiftiNVPairs in stored in |
GiftiNVPairs ([name, value]) |
|
data_tag (dataarray, encoding, datatype, ordering) |
Creates the data tag depending on the required encoding |
Module: gifti.giftiio
¶
read (filename) |
Load a Gifti image from a file |
write (image, filename) |
Save the current image to a new file |
Module: gifti.parse_gifti_fast
¶
Outputter () |
|
parse_gifti_file (fname[, buffer_size]) |
Parse gifti file named fname, return image |
read_data_block (encoding, endian, ordering, ...) |
Tries to unzip, decode, parse the funny string data |
Module: gifti.util
¶
GiftiDataArray
¶
-
class
nibabel.gifti.gifti.
GiftiDataArray
(data=None)¶ Bases:
object
-
__init__
(data=None)¶
-
coordsys
¶ alias of
GiftiCoordSystem
-
data
¶ alias of
ndarray
-
datatype
¶ alias of
int
-
dims
¶ alias of
list
-
encoding
¶ alias of
int
-
endian
¶ alias of
int
-
ext_fname
¶ alias of
str
-
ext_offset
¶ alias of
str
-
classmethod
from_array
(klass, darray, intent, datatype=None, encoding='GIFTI_ENCODING_B64GZ', endian='little', coordsys=None, ordering='C', meta=None)¶ Creates a new Gifti data array
Parameters: darray : ndarray
NumPy data array
intent : string
NIFTI intent code, see nifti1.intent_codes
datatype : None or string, optional
NIFTI data type codes, see nifti1.data_type_codes If None, the datatype of the NumPy array is taken.
encoding : string, optionaal
Encoding of the data, see util.gifti_encoding_codes; default: GIFTI_ENCODING_B64GZ
endian : string, optional
The Endianness to store the data array. Should correspond to the machine endianness. default: system byteorder
coordsys : GiftiCoordSystem, optional
If None, a identity transformation is taken.
ordering : string, optional
The ordering of the array. see util.array_index_order_codes; default: RowMajorOrder - C ordering
meta : None or dict, optional
A dictionary for metadata information. If None, gives empty dict.
Returns: da : instance of our own class
-
get_metadata
()¶ Returns metadata as dictionary
-
ind_ord
¶ alias of
int
-
intent
¶ alias of
int
-
meta
¶ alias of
GiftiMetaData
-
num_dim
¶ alias of
int
-
print_summary
()¶
-
to_xml
()¶
-
to_xml_close
()¶
-
to_xml_open
()¶
-
GiftiImage
¶
-
class
nibabel.gifti.gifti.
GiftiImage
(meta=None, labeltable=None, darrays=None, version='1.0')¶ Bases:
object
-
__init__
(meta=None, labeltable=None, darrays=None, version='1.0')¶
-
add_gifti_data_array
(dataarr)¶ Adds a data array to the GiftiImage
Parameters: dataarr : GiftiDataArray
-
filename
¶ alias of
str
-
getArraysFromIntent
(intent)¶ Returns a a list of GiftiDataArray elements matching the given intent
-
get_labeltable
()¶
-
get_metadata
()¶
-
numDA
¶ alias of
int
-
print_summary
()¶
-
remove_gifti_data_array
(ith)¶ Removes the ith data array element from the GiftiImage
-
remove_gifti_data_array_by_intent
(intent)¶ Removes all the data arrays with the given intent type
-
set_labeltable
(labeltable)¶ Set the labeltable for this GiftiImage
Parameters: labeltable : GiftiLabelTable
-
set_metadata
(meta)¶ Set the metadata for this GiftiImage
Parameters: meta : GiftiMetaData Returns: None :
-
to_xml
()¶ Return XML corresponding to image content
-
version
¶ alias of
str
-
GiftiLabel
¶
-
class
nibabel.gifti.gifti.
GiftiLabel
(key=0, label='', red=None, green=None, blue=None, alpha=None)¶ Bases:
object
-
__init__
(key=0, label='', red=None, green=None, blue=None, alpha=None)¶
-
alpha
¶ alias of
float
-
blue
¶ alias of
float
-
get_rgba
()¶ Returns RGBA as tuple
-
green
¶ alias of
float
-
key
¶ alias of
int
-
label
¶ alias of
str
-
red
¶ alias of
float
-
data_tag¶
-
nibabel.gifti.gifti.
data_tag
(dataarray, encoding, datatype, ordering)¶ Creates the data tag depending on the required encoding
read¶
-
nibabel.gifti.giftiio.
read
(filename)¶ Load a Gifti image from a file
Parameters: filename : string
The Gifti file to open, it has usually ending .gii
Returns: img : GiftiImage
Returns a GiftiImage
write¶
-
nibabel.gifti.giftiio.
write
(image, filename)¶ Save the current image to a new file
Parameters: image : GiftiImage
A GiftiImage instance to store
filename : string
Filename to store the Gifti file to
Returns: None :
Notes
We write all files with utf-8 encoding, and specify this at the top of the XML file with the
encoding
attribute.The Gifti spec suggests using the following suffixes to your filename when saving each specific type of data:
- .gii
- Generic GIFTI File
- .coord.gii
- Coordinates
- .func.gii
- Functional
- .label.gii
- Labels
- .rgba.gii
- RGB or RGBA
- .shape.gii
- Shape
- .surf.gii
- Surface
- .tensor.gii
- Tensors
- .time.gii
- Time Series
- .topo.gii
- Topology
The Gifti file is stored in endian convention of the current machine.
Outputter
¶
-
class
nibabel.gifti.parse_gifti_fast.
Outputter
¶ Bases:
object
-
__init__
()¶
-
CharacterDataHandler
(data)¶ Collect character data chunks pending collation
The parser breaks the data up into chunks of size depending on the buffer_size of the parser. A large bit of character data, with standard parser buffer_size (such as 8K) can easily span many calls to this function. We thus collect the chunks and process them when we hit start or end tags.
-
EndElementHandler
(name)¶
-
StartElementHandler
(name, attrs)¶
-
flush_chardata
()¶ Collate and process collected character data
-
initialize
()¶ Initialize outputter
-
pending_data
¶ True if there is character data pending for processing
-
parse_gifti_file¶
-
nibabel.gifti.parse_gifti_fast.
parse_gifti_file
(fname, buffer_size=None)¶ Parse gifti file named fname, return image
Parameters: fname : str
filename of gifti file
buffer_size: None or int, optional :
size of read buffer. None gives default of 35000000 unless on python < 2.6, in which case it is read only in the parser. In that case values other than None cause a ValueError on execution
Returns: img : gifti image