PYME.IO.tabular module¶
import filters for localisation microscopy results. These masquerade as dictionaries which can be looked up to yield the desired data. The visualisation routines expect at least ‘x’ and ‘y’ to be defined as keys, and may also understand additional values, e.g. ‘error_x’
- class PYME.IO.tabular.AnndataSource(filename)¶
Bases:
TabularBase
Interfaces with anndata/scanpy/squidpy packages for spatialomics.
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.BaseHDFSource(h5fFile, tablename='FitResults')¶
Bases:
FitResultsSource
Data source for use with h5r files as saved by the PYME analysis component. Takes either an open h5r file or a string filename to be opened.
- close()¶
- class PYME.IO.tabular.CachingResultsFilter(resultsSource, **kwargs)¶
Bases:
TabularBase
Class to permit filtering of fit results - masquarades as a dictionary. Takes item ranges as keyword arguments, eg: f = resultsFliter(source, x=[0,10], error_x=[0,5]) will return an object that behaves like source, but with only those points with an x value in the range [0, 10] and a x error in the range [0, 5].
The filter class does not have any explicit knowledge of the keys supported by the underlying data source.
- keys()¶
- property mdh¶
- class PYME.IO.tabular.CloneSource(resultsSource, keys=None)¶
Bases:
TabularBase
Creates an in memory copy of a (filtered) data source
- keys()¶
- class PYME.IO.tabular.ColourFilter(resultsSource, currentColour=None)¶
Bases:
TabularBase
Class to permit filtering by colour
- getColourChans()¶
- get_channel_column(chan, keys)¶
- get_channel_ds(chan)¶
- classmethod get_colour_chans(resultsSource)¶
- property index¶
- keys()¶
- setColour(colour)¶
- class PYME.IO.tabular.ColumnSource(**kwargs)¶
Bases:
DictSource
Create a datasource from columns specified by kwargs. Each column should be a numpy array.
- Parameters
- kwargs
- class PYME.IO.tabular.ConcatenateFilter(source0, source1, *args, concatKey='concatSource')¶
Bases:
TabularBase
Class which concatenates two (or more) tabular data sources. The data sources should have the same keys.
The filter class does not have any explicit knowledge of the keys supported by the underlying data source.
- keys()¶
- class PYME.IO.tabular.DictSource(source)¶
Bases:
TabularBase
Create a data source from a dictionary of numpy arrays, where each entry is a column.
- Parameters
- source
- addColumn(name, values)¶
- keys()¶
- class PYME.IO.tabular.FitResultsSource(fitResults, sort=True)¶
Bases:
TabularBase
- getInfo()¶
- keys()¶
- setResults(fitResults, sort=True)¶
- class PYME.IO.tabular.H5RDSource(h5fFile)¶
Bases:
H5RSource
Data source for use with h5r files as saved by the PYME analysis component
- getInfo()¶
- class PYME.IO.tabular.H5RSource(h5fFile, tablename='FitResults')¶
Bases:
BaseHDFSource
Data source for use with h5r files as saved by the PYME analysis component. Takes either an open h5r file or a string filename to be opened.
- getInfo()¶
- class PYME.IO.tabular.HDFSource(h5fFile, tablename='FitResults')¶
Bases:
H5RSource
Data source for use with h5r files as saved by the PYME analysis component. Takes either an open h5r file or a string filename to be opened.
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.IdFilter(resultsSource, id_column, valid_ids)¶
Bases:
SelectionFilter
Class to permit filtering of fit results - masquarades as a dictionary. Takes item ranges as keyword arguments, eg: f = resultsFliter(source, x=[0,10], error_x=[0,5]) will return an object that behaves like source, but with only those points with an x value in the range [0, 10] and a x error in the range [0, 5].
The filter class does not have any explicit knowledge of the keys supported by the underlying data source.
- class PYME.IO.tabular.MappingFilter(resultsSource, **kwargs)¶
Bases:
TabularBase
Class to permit transformations (e.g. drift correction) of fit results - masquarades as a dictionary. Takes mappings as keyword arguments, eg: f = resultsFliter(source, xp=’x + a*tIndex’, yp=compile(‘y + b*tIndex’, ‘/tmp/test1’, ‘eval’), a=1, b=2) will return an object that behaves like source, but has additional members xp and yp.
the mappings should either be code objects, strings (which will be compiled into code objects), or something else (which will be turned into a local variable - eg constants in above example)
- addColumn(name, values)¶
Adds a column of values to the mapping.
- Parameters
- namestr
The new column name
- valuesarray-like
The values. This should be the same length as the existing columns.
- addVariable(name, value)¶
Adds a scalar variable to the mapping object. This will be accessible from mappings. An example usage might be to define a scaling parameter for one of our column variables.
- Parameters
- namestring
The name we want to be able to access the variable by
- valuefloat (or something which can be cast to a float)
The value
- getMappedResults(key, sl)¶
- keys()¶
- setMapping(key, mapping)¶
- set_variables(**kwargs)¶
- class PYME.IO.tabular.MatfileColumnSource(filename)¶
Bases:
TabularBase
Input filter for use with matlab data where the each column is in a separate variable. Relies on variables having suitable column names - columns named x, y, z, t, and probe (if multi-colour) should be present.
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.MatfileMultiColumnSource(filename)¶
Bases:
MatfileColumnSource
Input filter for use with matlab data where the each column is in a separate variable. Relies on variables having suitable column names - columns named x, y, z, t, and probe (if multi-colour) should be present.
- class PYME.IO.tabular.MatfileSource(filename, columnnames, varName='Orte')¶
Bases:
TabularBase
Input filter for use with matlab data where all variables are in in one 2D array (variable). Need to provide a variable name within the matfile to and a list of column names in the order that they appear in the file. Using ‘x’, ‘y’ and ‘error_x’ for the position data and it’s error should ensure that this functions with the visualisation backends
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.RandomSelectionFilter(resultsSource, num_Samples)¶
Bases:
SelectionFilter
Class to permit filtering of fit results - masquarades as a dictionary. Takes item ranges as keyword arguments, eg: f = resultsFliter(source, x=[0,10], error_x=[0,5]) will return an object that behaves like source, but with only those points with an x value in the range [0, 10] and a x error in the range [0, 5].
The filter class does not have any explicit knowledge of the keys supported by the underlying data source.
- class PYME.IO.tabular.RandomSource(xmax, ymax, nsamps)¶
Bases:
TabularBase
Uniform random source, for testing and as an example
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.RecArraySource(recordArray)¶
Bases:
TabularBase
- getInfo()¶
- keys()¶
- class PYME.IO.tabular.ResultsFilter(resultsSource, **kwargs)¶
Bases:
SelectionFilter
Class to permit filtering of fit results - masquarades as a dictionary. Takes item ranges as keyword arguments, eg: f = resultsFliter(source, x=[0,10], error_x=[0,5]) will return an object that behaves like source, but with only those points with an x value in the range [0, 10] and a x error in the range [0, 5].
The filter class does not have any explicit knowledge of the keys supported by the underlying data source.
- class PYME.IO.tabular.SelectionFilter(resultsSource, index)¶
Bases:
TabularBase
A filter which relies on a supplied index (either integer or boolean)
- keys()¶
- class PYME.IO.tabular.TabularBase¶
Bases:
object
- keys()¶
- toDataFrame(keys=None)¶
- to_JSON(keys=None, return_slice=slice(None, None, None))¶
- to_csv(outFile, keys=None)¶
- to_hdf(filename, tablename='Data', keys=None, metadata=None, keep_alive_timeout=0)¶
Writes data to a table in an HDF5 file
- Parameters
- filename: string
the name of the file to save to
- tablename: string [optional]
the name of the table within the file to save to. Defaults to “Data”
- keys: list [optional]
a list of column names to save (if keys == None, all columns are saved)
- metadata: a MetaDataHandler instance [optional]
associated metadata to write to the file
- keep_alive_timeout: float
a timeout in seconds. If non-zero, the file is held open after we have finished writing to it until the timeout elapses. Useful as a performance optimisation when making multiple writes to a single file, potentially across multiple threads. NOTE: the keep_alive_timeout is not garuanteed to be observed - it gets set by the first open call of a given session, so if the file is already open due to a previous openH5R call, the timeout requested by that call will be used.
- to_recarray(keys=None)¶
Converts tabular data types into record arrays, which is useful for e.g. saving as an hdf table. In order to be converted, the tabular data source must be able to be flattened.
- Parameters
- keyslist of fields to be copied into output. Defaults to all existing keys.
- Returns
- numpy recarray version of self
- class PYME.IO.tabular.TextfileSource(filename, columnnames, delimiter=None, skiprows=0, skip_footer=0, invalid_raise=True, comments='#')¶
Bases:
TabularBase
Input filter for use with delimited text data. Defaults to whitespace delimiter. Need to provide a list of variable names in the order that they appear in the file. Using ‘x’, ‘y’ and ‘error_x’ for the position data and it’s error should ensure that this functions with the visualisation backends
- getInfo()¶
- keys()¶
- PYME.IO.tabular.cachingResultsFilter(*args, **kwargs)¶
- PYME.IO.tabular.cloneSource(*args, **kwargs)¶
- PYME.IO.tabular.colourFilter(*args, **kwargs)¶
- PYME.IO.tabular.concatenateFilter(*args, **kwargs)¶
- PYME.IO.tabular.deprecated_name(name)¶
- PYME.IO.tabular.fitResultsSource(*args, **kwargs)¶
- PYME.IO.tabular.h5rDSource(*args, **kwargs)¶
- PYME.IO.tabular.h5rSource(*args, **kwargs)¶
- PYME.IO.tabular.hdfSource(*args, **kwargs)¶
- PYME.IO.tabular.idFilter(*args, **kwargs)¶
- PYME.IO.tabular.mappingFilter(*args, **kwargs)¶
- PYME.IO.tabular.matfileColumnSource(*args, **kwargs)¶
- PYME.IO.tabular.matfileSource(*args, **kwargs)¶
- PYME.IO.tabular.randomSelectionFilter(*args, **kwargs)¶
- PYME.IO.tabular.randomSource(*args, **kwargs)¶
- PYME.IO.tabular.recArrayInput(*args, **kwargs)¶
- PYME.IO.tabular.resultsFilter(*args, **kwargs)¶
- PYME.IO.tabular.scalar_column_source(**kwargs)¶
Creates a tabular data source of length 1 from a scalar data
- PYME.IO.tabular.scalar_dict_source(d)¶
Creates a tabular data source of length 1 from a scalar data
- PYME.IO.tabular.textfileSource(*args, **kwargs)¶
- PYME.IO.tabular.unNestDtype(descr, parent='')¶
- PYME.IO.tabular.unNestNames(nameList, parent='')¶
- PYME.IO.tabular.unnest_dtype(dtype, parent='')¶