NiBabel

Access a cacophony of neuro-imaging file formats

Table Of Contents

Previous topic

dft

Next topic

filename_parser

Reggie -- the one

fileholders

Fileholder class

FileHolder([filename, fileobj, pos]) class to contain filename, fileobj and file position
FileHolderError
copy_file_map(file_map) Copy mapping of fileholders given by file_map

FileHolder

class nibabel.fileholders.FileHolder(filename=None, fileobj=None, pos=0)

Bases: object

class to contain filename, fileobj and file position

Initialize FileHolder instance

Parameters:

filename : str, optional

filename. Default is None

fileobj : file-like object, optional

Should implement at least ‘seek’ (for the purposes for this class). Default is None

pos : int, optional

position in filename or fileobject at which to start reading or writing data; defaults to 0

__init__(filename=None, fileobj=None, pos=0)

Initialize FileHolder instance

Parameters:

filename : str, optional

filename. Default is None

fileobj : file-like object, optional

Should implement at least ‘seek’ (for the purposes for this class). Default is None

pos : int, optional

position in filename or fileobject at which to start reading or writing data; defaults to 0

get_prepare_fileobj(*args, **kwargs)

Return fileobj if present, or return fileobj from filename

Set position to that given in self.pos

Parameters:

*args : tuple

positional arguments to file open. Ignored if there is a defined self.fileobj. These might include the mode, such as ‘rb’

**kwargs : dict

named arguments to file open. Ignored if there is a defined self.fileobj

Returns:

fileobj : file-like object

object has position set (via fileobj.seek()) to self.pos

same_file_as(other)

Test if self refers to same files / fileobj as other

Parameters:

other : object

object with filename and fileobj attributes

Returns:

tf : bool

True if other has the same filename (or both have None) and the same fileobj (or both have None

FileHolderError

class nibabel.fileholders.FileHolderError

Bases: exceptions.Exception

__init__()

x.__init__(...) initializes x; see help(type(x)) for signature

copy_file_map

nibabel.fileholders.copy_file_map(file_map)

Copy mapping of fileholders given by file_map

Parameters:

file_map : mapping

mapping of FileHolder instances

Returns:

fm_copy : dict

Copy of file_map, using shallow copy of FileHolders