BigBrotherBot v1.8.0
System Development Information for the BigBrotherBot project.

b3::lib::statlib::io Namespace Reference

Functions

def wrap
def cd
def pwd
def ls
def rename
def get
def getstrings
def put
def isstring
def aget
def aput
def bget
def CORget
def mincget
def brikget
def mghbget
def braw
def glget
def mget
def mput
def bput
def mrget
def quickload
def writedelimited
def writecc
def writefc
def load
def find_dirs
def binget
def binput
def array2afni

Variables

 N = numpy
float __version__ = 0.5
tuple pwd = wrap(pwd)
 save = aput
 f

Function Documentation

def b3::lib::statlib::io::aget (   namepattern,
  verbose = 1 
)
Loads an array from 2D text files (specified by a UNIX-style wildcard
filename pattern).  ONLY 'GET' FILES WITH EQUAL NUMBERS OF COLUMNS
ON EVERY ROW (otherwise returned array will be zero-dimensional).

Usage:   aget (namepattern)
Returns: an array of integers, floats or objects (type='O'), depending on the
     contents of the files specified by namepattern
def b3::lib::statlib::io::aput (   outarray,
  fname,
  writetype = 'w',
  delimit = ' ' 
)
Sends passed 1D or 2D array to an output file and closes the file.

Usage:   aput (outarray,fname,writetype='w',delimit=' ')
Returns: None
def b3::lib::statlib::io::array2afni (   d,
  brikprefix,
  voltype = None,
  TR = 2.0,
  sliceorder = 'seqplus',
  geomparent = None,
  view = None 
)
Converts an array 'd' to an AFNI BRIK/HEAD combo via putbin and to3d. Tries to
guess the AFNI volume type

voltype = {'-anat','-epan','-fim'}
geomparent = filename of the afni BRIK file with the same geometry
view = {'tlrc', 'acpc' or 'orig'}

Usage:   array2afni(d,brikprefix,voltype=None,TR=2.0,
                sliceorder='seqplus',geomparent=None,view=None)
Returns: None
def b3::lib::statlib::io::bget (   imfile,
  shp = None,
  unpackstr = N.int16,
  bytesperpixel = 2.0,
  sliceinit = 0 
)
Reads in a binary file, typically with a .bshort or .bfloat extension.
If so, the last 3 parameters are set appropriately.  If not, the last 3
parameters default to reading .bshort files (2-byte integers in big-endian
binary format).

Usage:   bget(imfile,shp=None,unpackstr=N.int16,bytesperpixel=2.0,sliceinit=0)
def b3::lib::statlib::io::binget (   fname,
  btype = None 
)
Loads a binary file from disk. Assumes associated hdr file is in same
location. You can force an unpacking type, or else it tries to figure
it out from the filename (4th-to-last character). Hence, readable file
formats are ...

1bin=Int8, sbin=int16, ibin=Int32, fbin=Float32, dbin=Float64, etc.

Usage:   binget(fname,btype=None)
Returns: data in file fname of type btype
def b3::lib::statlib::io::binput (   outarray,
  fname,
  packtype = None,
  writetype = 'wb' 
)
Unravels outarray and writes the data to a file, always in LittleEndian
format, along with a header file containing the original data shape. Default
is overwrite the destination file. Tries to figure out packtype from
4th-to-last character in filename. Thus, the routine understands these
file formats ...

1bin=Int8, sbin=int16, ibin=Int32, fbin=Float32, dbin=Float64, etc.

Usage:  binput(outarray,filename,packtype=None,writetype='wb')
def b3::lib::statlib::io::bput (   outarray,
  fname,
  writeheader = 0,
  packtype = N.int16,
  writetype = 'wb' 
)
Writes the passed array to a binary output file, and then closes
the file.  Default is overwrite the destination file.

Usage:   bput (outarray,filename,writeheader=0,packtype=N.int16,writetype='wb')
def b3::lib::statlib::io::braw (   fname,
  btype,
  shp = None 
)
Opens a binary file, unpacks it, and returns a flat array of the
type specified.  Use Numeric types ... N.Float32, N.Int64, etc.

Usage:   braw(fname,btype,shp=None)
Returns: flat array of floats, or ints (if btype=N.int16)
def b3::lib::statlib::io::brikget (   imfile,
  unpackstr = N.int16,
  shp = None 
)
Gets an AFNI BRIK file.

Usage:  brikget(imfile,unpackstr=N.int16,shp=None)  default shp: (-1,48,61,51)
def b3::lib::statlib::io::cd (   directory)
Changes the working python directory for the interpreter.

Usage:   cd(directory)      where 'directory' is a string
def b3::lib::statlib::io::CORget (   infile)
Reads a binary COR-nnn file (flattening file).

Usage:   CORget(imfile)
Returns: 2D array of 16-bit ints
def b3::lib::statlib::io::find_dirs (   sourcedir)
Finds and returns all directories in sourcedir

Usage:   find_dirs(sourcedir)
Returns: list of directory names (potentially empty)
def b3::lib::statlib::io::get (   namepatterns,
  verbose = 1 
)
Loads a list of lists from text files (specified by a UNIX-style
wildcard filename pattern) and converts all numeric values to floats.
Uses the glob module for filename pattern conversion.  Loaded filename
is printed if verbose=1.

Usage:   get (namepatterns,verbose=1)
Returns: a 1D or 2D list of lists from whitespace delimited text files
     specified by namepatterns; numbers that can be converted to floats
     are so converted
def b3::lib::statlib::io::getstrings (   namepattern,
  verbose = 1 
)
Loads a (set of) text file(s), with all elements left as string type.
Uses UNIX-style wildcards (i.e., function uses glob).  Loaded filename
is printed if verbose=1.

Usage:   getstrings (namepattern, verbose=1)
Returns: a list of strings, one per line in each text file specified by
     namepattern
def b3::lib::statlib::io::glget (   fname,
  btype 
)
Load in a file containing pixels from glReadPixels dump.

Usage:   glget(fname,btype)
Returns: array of 'btype elements with shape 'shape', suitable for im.ashow()
def b3::lib::statlib::io::isstring (   x)
def b3::lib::statlib::io::load (   fname,
  lines_to_ignore = 4,
  type = 'i' 
)
Load in huge, flat, 2D text files.  Can handle differing line-lengths AND
can strip #/% on UNIX (or with a better NT grep).  Requires wc, grep, and
mmapfile.lib/.pyd. Type can be 'i', 'f' or 'd', for ints, floats or doubles,
respectively.  Lines_to_ignore determines how many lines at the start of the
file to ignore (required for non-working grep).

Usage:   load(fname,lines_to_ignore=4,type='i')
Returns: numpy array of specified type
def b3::lib::statlib::io::ls (   d = '.')
Produces a directory listing.  Default is the current directory.

Usage:   ls(d='.')
def b3::lib::statlib::io::mget (   fname,
  btype 
)
Load in a file that was saved from matlab

Usage:   mget(fname,btype)
def b3::lib::statlib::io::mghbget (   imfile,
  numslices = -1,
  xsize = 64,
  ysize = 64,
  unpackstr = N.int16,
  bytesperpixel = 2.0,
  sliceinit = 0 
)
Reads in a binary file, typically with a .bshort or .bfloat extension.
If so, the last 3 parameters are set appropriately.  If not, the last 3
parameters default to reading .bshort files (2-byte integers in big-endian
binary format).

Usage:   mghbget(imfile, numslices=-1, xsize=64, ysize=64,
            unpackstr=N.int16, bytesperpixel=2.0, sliceinit=0)
def b3::lib::statlib::io::mincget (   imfile,
  unpackstr = N.int16,
  shp = None 
)
Loads in a .MNC file.

Usage:  mincget(imfile,unpackstr=N.int16,shp=None)  default shp = -1,20,64,64
def b3::lib::statlib::io::mput (   outarray,
  fname,
  writeheader = 0,
  btype = N.int16 
)
Save a file for use in matlab.
def b3::lib::statlib::io::mrget (   fname,
  datatype = N.int16 
)
Opens a binary .MR file and clips off the tail data portion of it, returning
the result as an array.

Usage:   mrget(fname,datatype=N.int16)
def b3::lib::statlib::io::put (   outlist,
  fname,
  writetype = 'w',
  oneperline = 0,
  delimit = ' ' 
)
Writes a passed mixed-type list (str and/or numbers) to an output
file, and then closes the file.  Default is overwrite the destination
file.

Usage:   put (outlist,fname,writetype='w',oneperline=0,delimit=' ')
Returns: None
Changes the working python directory for the interpreter.

Usage:   pwd       (no parens needed)
def b3::lib::statlib::io::quickload (   fname,
  linestocut = 4 
)
Quickly loads in a long text file, chopping off first n 'linestocut'.

Usage:   quickload(fname,linestocut=4)
Returns: array filled with data in fname
def b3::lib::statlib::io::rename (   source,
  dest 
)
Renames files specified by UNIX inpattern to those specified by UNIX
outpattern.  Can only handle a single '*' in the two patterns!!!

Usage:   rename (source, dest)     e.g., rename('*.txt', '*.c')
def b3::lib::statlib::io::wrap (   f)
Wraps a function so that if it's entered *by itself*
in the interpreter without ()'s, it gets called anyway
def b3::lib::statlib::io::writecc (   listoflists,
  file,
  writetype = 'w',
  extra = 2 
)
Writes a list of lists to a file in columns, customized by the max
size of items within the columns (max size of items in col, +2 characters)
to specified file.  File-overwrite is the default.

Usage:   writecc (listoflists,file,writetype='w',extra=2)
Returns: None
def b3::lib::statlib::io::writedelimited (   listoflists,
  delimiter,
  file,
  writetype = 'w' 
)
Writes a list of lists in columns, separated by character(s) delimiter
to specified file.  File-overwrite is the default.

Usage:   writedelimited (listoflists,delimiter,filename,writetype='w')
Returns: None
def b3::lib::statlib::io::writefc (   listoflists,
  colsize,
  file,
  writetype = 'w' 
)
Writes a list of lists to a file in columns of fixed size.  File-overwrite
is the default.

Usage:   writefc (listoflists,colsize,file,writetype='w')
Returns: None

Variable Documentation

 All Classes Namespaces Files Functions Variables Properties