neurotools.util.tools module
- neurotools.util.tools.debug(*a, **kw)
- neurotools.util.tools.matlab(commands)[source]
Runs Matlab commands through the shell TODO: make matlabpath configurable
- neurotools.util.tools.p2c(p)[source]
Convert a point in terms of a length-2 iterable into a complex number
- class neurotools.util.tools.emitter(operation=None)[source]
Bases:
object
This is a toy example test of a concept used in the piper dectorator below. It extends callables so that using them with the logical or operator “|” will apply the callable as a side effect before returning the original value of the expression. The default side effect is printing the object value.
Example
>>> emit = emitter() >>> emit | cos(10)
- class neurotools.util.tools.piper(operation)[source]
Bases:
object
Piper extends callables such that they can be called by using infix operators. This is just for fun and you should probably not use it.
Example
>>> def foo(x): >>> return x+1 >>> pip = piper(foo) >>> 1 + 1 | pip >>> @piper >>> def zscore(x): >>> return (x-mean(x,0))/std(x,0) >>> zscore < rand(10)
- neurotools.util.tools.globalize(function, *args, **krgs)[source]
globalize allows the positional argument list of a python to be truncated.
Missing arguments will be filled in by name from the globals dictionary.
- neurotools.util.tools.exists(varname)
- neurotools.util.tools.metaloadmat(path)[source]
Loads a matfile from the provided path, caching it in the global dict “matfilecache” using path as the lookup key.
- Parameters:
path (string) – unique absolute path to matfile to be loaded
- neurotools.util.tools.find_all_extension(d, ext='png')[source]
Locate all files with a given extension
- Parameters:
d (string) – String representing a path in the filesystem
ext (string) – extension to locate. search is not case-sensitive.
- Returns:
found – List of files with matching extension
- Return type:
string
- neurotools.util.tools.setinrange(data, a, b)
- neurotools.util.tools.mapdict(data, function)
- neurotools.util.tools.getdict(data, index)
- neurotools.util.tools.ensure_dir(dirname)[source]
Ensure that a named directory exists; if it does not, attempt to create it. http://stackoverflow.com/questions/944536/efficient-way-of-creating-recursive-paths-python
- Parameters:
dirname (str)
- neurotools.util.tools.getsize(obj)[source]
Recursively iterate to sum size of object & members. http://stackoverflow.com/questions/449560/how-do-i-determine-the-size-of-an-object-in-python
- neurotools.util.tools.clear()
- neurotools.util.tools.getVariable(path, var)[source]
Reads a variable from a .mat or .hdf5 file The read result is cached in ram for later access
- neurotools.util.tools.yank(argnames)[source]
Turns a string of whitespace-delimited variable names
'name1 name2 ...'
accessible in the local or global scope into a dictionary{'name1':name1, ...}
.- Parameters:
argnames (str) – A single string containing all variable identifiers to grab, delimited by whitespace.