text:
tramway.analyzer package¶

class tramway.analyzer.RWAnalyzer

Bases: tramway.analyzer.attribute.WithLogger

A RWAnalyzer object gathers the parameters of all the processing steps of a standard processing chain, from SPT data loading/generation to inferring model parameters at microdomains.

The supported steps are defined in a declarative way with special attributes; these steps and corresponding attributes are as follows:

Most attributes are self-morphing, i.e. they first are initializers and exhibit from_… methods (for example from_dataframe() and from_ascii_file() for spt_data) and then, once any such initializer method is called, they specialize into a new attribute and exhibit specific attributes depending on the chosen initializer:

from tramway.analyzer import *
a = RWAnalyzer()
a.spt_data.from_ascii_files('my_data_repository/*.txt')

The more conventional assignment form is also available using functions of modules exported by the tramway.analyzer subpackage. These modules are named following the attribute they are dedicated to:

a = RWAnalyzer()
a.spt_data = spt_data.from_ascii_files('my_data_repository/*.txt')

In most cases, a third form is also available, with a class constructor:

a = RWAnalyzer()
a.spt_data = spt_data.SPTAsciiFiles('my_data_repository/*.txt')

Anyway, most of the attributes of an RWAnalyzer object are properties that perform various checks and may raise exceptions if misused.

Specialized attributes can also exhibit self-morphing attributes. For example, regions of interest can be defined globally using the main roi attribute, or on a per-SPT-datafile basis:

a = RWAnalyzer()
a.spt_data.from_ascii_files('my_data_repository/*.txt')
a.roi.from_squares(roi_centers, square_size)

or

a = RWAnalyzer()
a.spt_data.from_ascii_files('my_data_repository/*.txt')
for spt_file in a.spt_data:
spt_file.roi.from_squares(roi_centers, square_size)

In the above example, per-dataset ROI definition is useful when multiple datasets are loaded and the ROI may differ between datasets. The main roi attribute is still convenient as it allows to iterate over all the defined ROI, omitting the spt_data loop (continues any of the code blocks above):

for r in a.roi:
roi_spt_data = r.crop()

The ROI object is denoted r here. Name roi already exists if the analyzer module is imported with from tramway.analyzer import *. In this case, roi points to the roi module.

Note there exists multiple iterators for the collections of ROI. In the further examples of iterated ROI, the preferred iterator is made explicit. See the documentation for the roi attribute for more information about the available iterators.

While the spt_data and roi attributes act as data providers, the time, tesseller, sampler and mapper attributes do not feature direct access to the data and require the SPT data to be passed as input argument to their main processing methods. For example:

a.tesseller.from_plugin('kmeans')
for r in a.roi.as_support_regions():
roi_spt_data = r.crop()
tessellation = a.tesseller.tessellate(roi_spt_data)

Similarly, the images attribute defines data location, while the localizer and tracker attributes define processing steps on these data.

Other attributes drive the execution of the processing chain. The run() method launches the processing chain, which is operated by the pipeline attribute.

Various parallelization schemes are available, and the platform-specific implementation of these schemes are provided by the env attribute.

Last but not least, the RWAnalyzer features plotting utilities. Some of them are available through the mpl sub-attribute of some main RWAnalyzer attributes or items, for example images.mpl (Mpl), spt_data.mpl (Mpl), tesseller.mpl (Mpl), mapper.mpl (Mpl). In addition, the browser attribute can plot the inferred parameter maps from a Jupyter notebook, or calling the bokeh serve command:

from tramway.analyzer import *

a = RWAnalyzer()

# load the rwa files available in the current directory:
a.spt_data.from_rwa_files('*.rwa')

# help the analyzer locate this piece of code:
try:
a.script = __file__
except NameError: # in a notebook
a.script = 'MyNotebook.ipynb' # this notebook's name (please adapt)

a.browser.show_maps()

See also Browser for additional information on how to export data and figures while browsing the inferred parameter maps.

spt_data

SPT data accessor.

roi

ROI accessor.

time

Time segmentation procedure.

tesseller

Tessellation procedure.

sampler

Sampling procedure.

mapper

Inference procedure.

images

Microscopy image stacks.

localizer

Single molecule localization procedure.

tracker

Single particle tracking procedure.

env

Environment backend for operating the pipeline.

If not set, the pipeline will run locally in the current interpreter.

pipeline

Parallelization scheme.

run()

Launches the pipeline.

Alias for pipeline run().

add_collectible(collectible)

Designates a file generated on the worker side to be transferred back to the submit side.

browser

Data visualization and export.

script

Path to the __main__ file in which the analyzer is defined.

Designating a script is required for parallelizing computations, or visualizing maps without explicitly calling the bokeh serve command (e.g. from a Jupyter notebook).

Alias for env script.

exception tramway.analyzer.SideEffectWarning

Bases: UserWarning

tramway.analyzer.attribute package¶

class tramway.analyzer.attribute.InitializerMethod(method, attrname=None)

Bases: object

Useful for explicit typing.

tramway.analyzer.attribute.initializer_method(method, attrname=None)

Properly set the docstring for the wrapped method.

tramway.analyzer.images package¶

class tramway.analyzer.images.Images

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the images attribute of an RWAnalyzer object.

as_frames(index=None, return_time=False)

Generator function; yields frames as arrays.

See for example as_frames().

crop_frames(bounding_box, index=None, return_time=False)

Generator function similar to as_frames(), with ROI cropping.

See for example crop_frames().

class tramway.analyzer.images.Image

Bases: object

Abstract base class for single image stacks an Images object contains.

class tramway.analyzer.images.ImagesInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initial value for the RWAnalyzer images attribute.

from_… methods alters the parent attribute which specializes into an initialized Images object.

from_tiff_file(filepath)

Defines the raw single molecule imaging file.

Loading is not performed while calling this method.

from_tiff_files(filepattern)

Defines the raw single molecule imaging files.

Loading is not performed while calling this method.

class tramway.analyzer.images.RawImages(stacks, **kwargs)

Bases: tramway.analyzer.images.ImageIterator

class tramway.analyzer.images.ImageFiles(filepattern, **kwargs)

Bases: tramway.analyzer.images.ImageIterator

class tramway.analyzer.images.TiffFiles(filepattern, **kwargs)

tramway.analyzer.images.mpl module¶

class tramway.analyzer.images.mpl.Mpl(parent=None)

Bases: tramway.analyzer.attribute.AnalyzerNode

Matplotlib plotting utilities for 2D data; no time support.

plot(x, *args, origin=None, frame=None, **kwargs)

Converts localization data from micrometers to pixels and plots them.

Can overlay locations onto a frame image as plotted with imshow and default parameters (origin='upper').

roi(frame, origin, *args, axes=None, colormap='gray', **kwargs)

Plots a frame corresponding to a region of interest.

origin should be provided by cropping_bounds(), if frame is given by crop_frames().

Extra input arguments are passed to the imshow() function.

This method works in combination with spt_data.mpl.Mpl.plot().

tramway.analyzer.localizer package¶

class tramway.analyzer.localizer.UNetLocalizer(**kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Loads the weights of a U-Net network for image deconvolution.

Not implemented yet, as long as the UNet package is broken.

weights_locator

Uniform resource locator for the U-Net weights

Type: str
localize(stack)

Not implemented yet, as long as the UNet package is broken.

class tramway.analyzer.localizer.LocalizerInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initializer class for the RWAnalyzer localizer main attribute.

The localizer attribute self-modifies on calling any of the from_… methods.

from_UNet()

Loads a trained U-Net network for image deconvolution.

See also UNetLocalizer.

from_unet()

Alias for from_UNet().

class tramway.analyzer.localizer.Localizer

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the localizer attribute of an RWAnalyzer object.

tramway.analyzer.tracker package¶

class tramway.analyzer.tracker.NonTrackingTracker(**kwargs)

Bases: tramway.analyzer.tracker.BaseTracker

Non-tracking tracker.

class tramway.analyzer.tracker.Tracker

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the tracker attribute of an RWAnalyzer object.

class tramway.analyzer.tracker.TrackerInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initializer class for the RWAnalyzer tracker main attribute.

The tracker attribute self-modifies on calling any of the from_… methods.

from_single_particle()

Considers every single molecule localization datablocks as single trajectories.

See also SingleParticleTracker.

from_non_tracking()

Non-tracking tracker.

See also NonTrackingTracker.

tramway.analyzer.spt_data package¶

class tramway.analyzer.spt_data.SPTData

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the spt_data attribute of an RWAnalyzer object.

as_dataframes(source=None)

Generator function; yields pandas.DataFrame objects.

source can be a source name (filepath) or a boolean function that takes a source string as input argument.

bounds

Lower (index min) and upper (index max) bounds for the SPT data

Type: pandas.DataFrame
columns

Data column names

Type: list of str
discard_static_trajectories(dataframe=None, min_msd=None)

The minimum mean-square-displacement is set to the localization error per default.

If an input dataframe is given, then discard_static_trajectories() returns the processed dataframe and self does not maintain any copy of it.

Otherwise, discard_static_trajectories() applies inplace to the internal dataframe and does not return any dataframe. Note that it may set a flag instead of actually processing the internal dataframe, for the parcimonious processing in regions of interest only.

frame_interval

Time interval between successive frames, in seconds

Type: float
localization_error

Localization error in $$\mu m^2$$

Type: float
reset_origin(columns=None, same_origin=False)

Translates the lower bound of the spatial data to zero.

class tramway.analyzer.spt_data.SPTDataItem

Bases: object

Abstract base class for SPT data blocks an SPTData object contains.

analyses

Analysis tree

Type: Analyses
bounds

Lower (index min) and upper (index max) bounds for the SPT data

Type: pandas.DataFrame
columns

Data column names

Type: list of str
dataframe

Raw SPT data

Type: pandas.DataFrame
frame_interval

Time interval between successive frames, in seconds

Type: float
localization_error

Localization error in $$\mu m^2$$

Type: float
source

File path or identifier

Type: str
class tramway.analyzer.spt_data.SPTParameters(localization_precision=None, localization_error=None)

Bases: object

Mixin class for storing common experimental parameters, including the localization error, time interval and temperature.

Children classes should define the _frame_interval, _localization_error and _temperature attributes, or overload the frame_interval, localization_error and temperature properties.

Default values should be None.

discard_static_trajectories(dataframe, min_msd=None, **kwargs)

The minimum mean-square-displacement is set to the localization error per default.

If an input dataframe is given, then discard_static_trajectories() returns the processed dataframe and self does not maintain any copy of it.

Otherwise, discard_static_trajectories() applies inplace to the internal dataframe and does not return any dataframe. Note that it may set a flag instead of actually processing the internal dataframe, for the parcimonious processing in regions of interest only.

dt

Alias for the frame_interval property

Type: float
frame_interval

Time interval between successive frames, in seconds

Type: float
localization_error

Localization error in $$\mu m^2$$

Type: float
localization_precision

Localization precision in $$\mu m$$; localization_error $$\sigma^2$$ is affected by localization_precision $$\sigma$$ and vice versa

Type: float
set_precision(precision)

Sets the numerical precision of the raw data.

Parameters: precision (dict or str) – any of 'half', 'single', 'double', or a dictionnary of dtypes with column names as keys, as admitted by pandas.DataFrame.astype().
temperature

Temperature in K; can be set as a value-unit pair, with unit any of 'K', 'C' and 'F'

Type: float
time_step

Alias for the frame_interval property

Type: float
class tramway.analyzer.spt_data.StandaloneDataItem

Bases: object

Partial implementation for single data item SPTData attribute.

class tramway.analyzer.spt_data.SPTDataIterator(**kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode, tramway.analyzer.spt_data.SPTParameters

Partial implementation for multi-item SPTData.

Children classes must implement the __iter__() method.

as_dataframes(source=None, return_index=False)

Generator function; yields pandas.DataFrame objects.

source can be a source name (filepath) or a boolean function that takes a source string as input argument.

bounds

Lower (index min) and upper (index max) bounds for the SPT data

Type: pandas.DataFrame
discard_static_trajectories(dataframe=None, min_msd=None, **kwargs)

The minimum mean-square-displacement is set to the localization error per default.

If an input dataframe is given, then discard_static_trajectories() returns the processed dataframe and self does not maintain any copy of it.

Otherwise, discard_static_trajectories() applies inplace to the internal dataframe and does not return any dataframe. Note that it may set a flag instead of actually processing the internal dataframe, for the parcimonious processing in regions of interest only.

dt

Alias for the frame_interval property

Type: float
filter_by_source(source_filter, return_index=False)

Generator function; similar to __iter__(); yields SPTDataItem objects.

source can be a single str value, or a set of str values, or a sequence of str values (the order is followed), or a callable that takes a str value and returns a bool value.

frame_interval

Time interval between successive frames, in seconds

Type: float
localization_error

Localization error in $$\mu m^2$$

Type: float
reload_from_rwa_files(skip_missing=False)

Reloads the SPT data and analysis tree from the corresponding rwa files.

The rwa file that corresponds to an SPT file should be available at the same path with the .rwa extension instead of the SPT file’s extension.

This method is known to fail with a TypeError exception in cases where not any matching .rwa file can be found.

Note

As this operation modifies the SPT data source and filepath attributes, aliases should be favored when identifying or filtering SPT data items.

self_update(new_self)
set_precision(precision)

Sets the numerical precision of the raw data.

Parameters: precision (dict or str) – any of 'half', 'single', 'double', or a dictionnary of dtypes with column names as keys, as admitted by pandas.DataFrame.astype().
temperature

Temperature in K; can be set as a value-unit pair, with unit any of 'K', 'C' and 'F'

Type: float
time_step

Alias for the frame_interval property

Type: float
class tramway.analyzer.spt_data.SPTDataInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initial value for the RWAnalyzer spt_data attribute.

from_… methods alters the parent attribute which specializes into an initialized SPTData object.

from_ascii_file(filepath)

Sets a text file as the source of SPT data.

Note that data loading is NOT performed while calling this method. Loading is postponed until the data is actually required. This lets additional arguments to be provided to the RWAnalyzer spt_data attribute before the data are loaded.

See also StandaloneSPTAsciiFile.

from_ascii_files(filepattern)

Sets text files, which paths match with a pattern, as the source of SPT data.

filepattern is a standard filepath with the '*' placeholder. For example: ‘dataset/*.txt’

The parts of the filename that match the placeholder are used as keys.

Note that data loading is NOT performed while calling this method. Loading is postponed until the data is actually required. This lets additional arguments to be provided to the RWAnalyzer spt_data attribute before the data are loaded.

See also SPTAsciiFiles.

from_dataframe(df)

See also StandaloneSPTDataFrame.

from_dataframes(dfs)

See also SPTDataFrames.

from_mat_file(filepath)

Sets a MatLab V7 file as the source of SPT data.

Similarly to from_ascii_file(), data loading is lazy.

See also StandaloneSPTMatFile.

from_mat_files(filepattern)

Sets MatLab V7 files, which paths match with a pattern, as the source of SPT data.

filepattern is a standard filepath with the '*' placeholder. For example: ‘datasets/*.txt’

The parts of the filename that match the placeholder are used as keys.

Similarly to from_ascii_files(), data loading is lazy.

See also SPTMatFiles.

from_rw_generator(generator)

A random walk generator features a generate() method.

See also RWGenerator.

from_rwa_file(filepath)

Similar to from_ascii_file(), for .rwa files.

See also StandaloneRWAFile.

from_rwa_files(filepattern)

Similar to from_ascii_files(), for .rwa files.

See also RWAFiles.

from_tracker()

This initializer method does not need to be called; The RWAnalyzer tracker attribute does this automatically.

See also TrackerOutput.

class tramway.analyzer.spt_data.HasROI(roi=<class 'tramway.analyzer.roi.ROIInitializer'>, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Class to be inherited from by SPT data item classes.

Maintains a self-modifying roi attribute.

_get_roi()

ROI: Regions of interest for the parent data block

compatible_source(source)

Returns True if filter source matches with self.source.

Note

Does not check against the alias.

roi

Regions of interest for the parent data block

Type: ROI
class tramway.analyzer.spt_data.HasAnalysisTree(df=None, **kwargs)

Partial implementation for SPTData that complements SPTParameters.

check_cache(_raise=<class 'AttributeError'>)

Checks the parameter cache integrity.

If differences are found with the values in dataframe, check_cache() raises an exception of type _raise.

If _raise is None or False, then check_cache() returns a bool instead, that is False if the cache is alright, True otherwise. If _raise is True, then check_cache() returns True if the cache is alright, False otherwise.

clear_cache()

Clears the cached values and reads from the dataframe object.

commit_cache(autoload=False)

Pushes the cached parameters into the dataframe object.

class tramway.analyzer.spt_data._SPTDataFrame(df, source=None, **kwargs)

Basis for all concrete SPTDataItem classes.

discard_static_trajectories(dataframe=None, min_msd=None, **kwargs)

The minimum mean-square-displacement is set to the localization error per default.

If an input dataframe is given, then discard_static_trajectories() returns the processed dataframe and self does not maintain any copy of it.

Otherwise, discard_static_trajectories() applies inplace to the internal dataframe and does not return any dataframe. Note that it may set a flag instead of actually processing the internal dataframe, for the parcimonious processing in regions of interest only.

mpl

Matplotlib utilities

Type: tramway.analyzer.spt_data.mpl.Mpl
set_precision(precision)

Sets the numerical precision of the raw data.

Parameters: precision (dict or str) – any of 'half', 'single', 'double', or a dictionnary of dtypes with column names as keys, as admitted by pandas.DataFrame.astype().
to_ascii_file(filepath, columns=None, header=True, float_format='%.4f', **kwargs)

Exports the data to text file.

Beware: whitespaces in the column names should be avoided with header=True

Parameters: filepath (str or Path) – output filepath. columns (sequence of str) – columns to be exported. header (bool) – print column names on the first line. float_format (str) – see also pandas.DataFrame.to_csv().

Additional keyword arguments are passed to pandas.DataFrame.to_csv().

to_rwa_file(filepath, **kwargs)

Exports the analysis tree to file.

Calls save_rwa() with argument compress=False unless explicitly set.

class tramway.analyzer.spt_data.SPTDataFrame(df, source=None, **kwargs)
class tramway.analyzer.spt_data.StandaloneSPTDataFrame(df, source=None, **kwargs)

SPTData attribute for single dataframes.

class tramway.analyzer.spt_data.SPTDataFrames(dfs, **kwargs)

SPTData attribute for multiple dataframes.

class tramway.analyzer.spt_data.SPTFile(filepath, dataframe=None, **kwargs)

Basis for SPTDataItem classes for data in a file.

_trigger_discard_static_trajectories()

Calls SPTDataFrame.discard_static_trajectories(); requires the data are already loaded.

_trigger_reset_origin()

Calls SPTDataFrame.reset_origin(); requires the data are already loaded.

alias

Identifier, shorter than source

Type: str
discard_static_trajectories(dataframe=None, min_msd=None, **kwargs)

The minimum mean-square-displacement is set to the localization error per default.

If an input dataframe is given, then discard_static_trajectories() returns the processed dataframe and self does not maintain any copy of it.

Otherwise, discard_static_trajectories() applies inplace to the internal dataframe and does not return any dataframe. Note that it may set a flag instead of actually processing the internal dataframe, for the parcimonious processing in regions of interest only.

filepath

Alias for the source property

Type: str
get_image(match=None)

Looks for the corresponding localization microscopy image in the images attribute.

The search is based on the object’s alias. The first item that contains the alias in its filename is returned as a match.

If the alias attribute is not set or images do not have a defined filepath, an AttributeError exception is raised.

The optional argument match is a 2-argument callable that takes the alias (str) of self and the filepath (str) of an Image stack of images, and returns True if the filepath and alias match.

class tramway.analyzer.spt_data.RawSPTFile(filepath, dataframe=None, **kwargs)

Basis for SPTDataItem classes for raw data in a file, possibly with non-standard column names or data units.

class tramway.analyzer.spt_data.SPTFiles(filepattern, **kwargs)
alias

Function that extracts an alias out of filepaths (write-only property)

Type: callable
aliases

Aliases of the SPT data items (copy)

Type: list of str
filepaths

File paths (copy)

Type: list of str
filepattern

Filepath glob pattern

Type: str
files

SPT file objects

Type: list
filter_by_source(source_filter, return_index=False)

Generator function; similar to __iter__(); yields SPTDataItem objects.

source can be a single str value, or a set of str values, or a sequence of str values (the order is followed), or a callable that takes a str value and returns a bool value.

fully_reified

True if all the files have been loaded

Type: bool
list_files()

Interprets the filepath glob pattern and lists the matching files.

partially_reified

True if any file has been loaded

Type: bool
class tramway.analyzer.spt_data.RawSPTFiles(filepattern, **kwargs)
class tramway.analyzer.spt_data._SPTAsciiFile(filepath, dataframe=None, **kwargs)
class tramway.analyzer.spt_data.SPTAsciiFile(filepath, dataframe=None, **kwargs)
class tramway.analyzer.spt_data.StandaloneSPTAsciiFile(filepath, dataframe=None, **kwargs)

RWAnalyzer.spt_data attribute for single SPT text files.

class tramway.analyzer.spt_data.SPTAsciiFiles(filepattern, **kwargs)

SPTData class for multiple SPT text files.

list_files()

Interprets the filepath glob pattern and lists the matching files.

class tramway.analyzer.spt_data._RWAFile(filepath, **kwargs)
filepath

.rwa file path; distinct from source.

Type: str
class tramway.analyzer.spt_data.RWAFile(filepath, **kwargs)
class tramway.analyzer.spt_data.StandaloneRWAFile(filepath, **kwargs)

SPTata class for single RWA files.

class tramway.analyzer.spt_data.RWAFiles(filepattern, **kwargs)

SPTData class for multiple RWA files.

list_files()

Interprets the filepath glob pattern and lists the matching files.

reload_from_rwa_files(skip_missing=False)

Reloads the SPT data and analysis tree from the corresponding rwa files.

The rwa file that corresponds to an SPT file should be available at the same path with the .rwa extension instead of the SPT file’s extension.

This method is known to fail with a TypeError exception in cases where not any matching .rwa file can be found.

Note

As this operation modifies the SPT data source and filepath attributes, aliases should be favored when identifying or filtering SPT data items.

class tramway.analyzer.spt_data._SPTMatFile(filepath, dataframe=None, **kwargs)
coord_scale

Convertion factor for the loaded coordinates so that they read in $$\mu m$$

Type: float
pixel_size

Former name for coord_scale; deprecated

Type: float
class tramway.analyzer.spt_data.SPTMatFile(filepath, dataframe=None, **kwargs)
class tramway.analyzer.spt_data.StandaloneSPTMatFile(filepath, dataframe=None, **kwargs)

SPTData class for single MatLab v7 data files.

class tramway.analyzer.spt_data.SPTMatFiles(filepattern, **kwargs)

SPTData class for multiple MatLab v7 data files.

coord_scale

Convertion factor for the loaded coordinates so that they read in $$\mu m$$

Type: float
list_files()

Interprets the filepath glob pattern and lists the matching files.

pixel_size

Former name for coord_scale; deprecated

Type: float
class tramway.analyzer.spt_data.RWAnalyses(analyses, copy=False, **kwargs)

SPTData class for single analysis trees as stored in .rwa files.

Note

copying (initializing with copy=True) copies only the SPT data and NOT the subsequent analyses.

Warning

not thouroughly tested.

class tramway.analyzer.spt_data.MultipleRWAnalyses(analyses, copy=False, **kwargs)

SPTData class for multiple analysis trees as stored in .rwa files.

Note

copying (initializing with copy=True) copies only the SPT data and NOT the subsequent analyses.

Warning

not tested.

class tramway.analyzer.spt_data.RWGenerator(*args, **kwargs)

not implemented yet

class tramway.analyzer.spt_data.LocalizationFile(filepath, dataframe=None, **kwargs)
class tramway.analyzer.spt_data.TrackerOutput(**kwargs)

SPTData class for SPT data yielded by the tracker attribute.

add_tracked_data(trajectories, source=None, filepath=None)

Note

In most cases source and filepath are supposed to represent the same piece of information. Here, filepath should be preferred over source if the localization data come from a file.

filter_by_source(source_filter, return_index=False)

Generator function; similar to __iter__(); yields SPTDataItem objects.

source can be a single str value, or a set of str values, or a sequence of str values (the order is followed), or a callable that takes a str value and returns a bool value.

tramway.analyzer.spt_data.compute_dtypes(df, precision)

Returns a dictionnary of dtypes to align the numerical precision of a pandas.DataFrame data.

tramway.analyzer.spt_data.glob(pattern)

Same as glob.glob(), with support for tilde.

os.path.expanduser() is applied to pattern, and then the expanded part is replaced back with tilde in the resulting paths.

tramway.analyzer.spt_data.mpl module¶

class tramway.analyzer.spt_data.mpl.LineDealer(ax, n=None, colors=['darkgreen', 'darkkhaki', 'darkmagenta', 'darkolivegreen', 'darkorange', 'darkorchid', 'darkred', 'darksalmon', 'darkseagreen', 'darkslateblue', 'darkslategray', 'darkviolet', 'deeppink', 'deepskyblue', 'dodgerblue', 'firebrick', 'forestgreen', 'gold', 'goldenrod', 'hotpink', 'indianred', 'indigo', 'lightblue', 'lightcoral', 'lightpink', 'lightsalmon', 'lightseagreen', 'lightskyblue', 'lightsteelblue', 'limegreen', 'maroon', 'mediumaquamarine', 'mediumorchid', 'mediumpurple', 'mediumseagreen', 'mediumslateblue', 'mediumspringgreen', 'mediumturquoise', 'mediumvioletred', 'midnightblue', 'navajowhite', 'navy', 'olive', 'olivedrab', 'orange', 'orangered', 'orchid', 'palegreen', 'paleturquoise', 'palevioletred', 'papayawhip', 'peachpuff', 'peru', 'pink', 'plum', 'powderblue', 'purple', '#663399', 'rosybrown', 'royalblue', 'saddlebrown', 'salmon', 'sandybrown', 'seagreen', 'sienna', 'skyblue', 'slateblue', 'springgreen', 'steelblue', 'tan', 'teal', 'thistle', 'tomato', 'turquoise', 'violet', 'wheat', 'yellowgreen'], **kwargs)

Bases: object

Makes glyphs for trajectories to be drawn as lines and keeps track of the trajectories passed to animate so that glyphs are freed as soon as possible and can be assigned to new trajectories.

animate(trajs, dt)

Makes the function to be passed as second positional argument to FuncAnimation.

Parameters: trajs (DataFrame) – trajectories. dt (float) – time step. function that takes a list of index slices. callable
init_func()

To be passed as argument init_func to FuncAnimation.

plot(trajs)

Updates the glyphs with the active trajectories.

Parameters: trajs (list) – list of active trajectories (dataframes). sequence of updated glyphs. tuple

tramway.analyzer.roi package¶

class tramway.analyzer.roi.BaseRegion(spt_data, label=None, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

This class should not be directly instanciated. It brings basic functionalities to all the available representations of regions of interest, merely labelling and analysis registration.

class tramway.analyzer.roi.IndividualROI(spt_data, label=None, **kwargs)

for typing only

class tramway.analyzer.roi.BoundingBox(bb, label, spt_data, **kwargs)
crop_frames(**kwargs)

Iterates and crops the image frames.

kwargs are passed to the Images crop_frames() method.

class tramway.analyzer.roi.SupportRegion(r, regions, spt_data, **kwargs)

Union of overlapping ROI.

crop_frames(**kwargs)

Iterates and crops the image frames, based on bounding_box.

kwargs are passed to the Images crop_frames() method.

add_metadata(sampling, inplace=False)

Modifies sampling or returns a modified copy of sampling.

In both cases, returns the resulting Partition object.

add_sampling(sampling, label=None, comment=None, metadata='inplace')

If metadata=='inplace' (default), sampling is modified to store ROI-related information.

Pass metadata=True instead to store a copy of sampling in the analysis tree. Note however that sampling is copied only if modified.

class tramway.analyzer.roi.FullRegion(spt_data, label=None, **kwargs)

Wraps the full dataset; does not actually crop.

A FullRegion can be both an individual ROI and a support region.

crop_frames(**kwargs)

Note

Time cropping is not supported yet.

class tramway.analyzer.roi.DecentralizedROIManager(first_record=None, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

This class allows to iterate over the ROI defined at the level of each SPT data item.

as_individual_roi(index=None, collection=None, source=None, **kwargs)

Generator function; loops over all the individual roi.

Filtering is delegated to the individual SPTDataItem.roi attributes.

A callable filter takes a single key (int for indices, str for labels and paths) and returns a bool.

Parameters: index (int, set of int, sequence of int, or callable) – individual ROI index filter; indices apply within a collection collection (str, set of str, sequence of str, or callable) – collection label filter source (str, set of str, sequence of str, or callable) – SPT data source filter
as_support_regions(index=None, source=None, **kwargs)

Generator function; loops over all the support regions.

Support regions are equivalent to individual ROI if group_overlapping_roi was set to False.

Filtering is delegated to the individual SPT data block roi attributes.

A callable filter takes a single key (int for indices, str for paths) and returns a bool.

Parameters: index (int, set of int, sequence of int, or callable) – support region index filter source (str, set of str, sequence of str, or callable) – SPT data source filter
class tramway.analyzer.roi.ROIInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initial value for the RWAnalyzer roi attribute.

from_… methods alters the parent attribute which specializes into an initialized ROI object.

from_bounding_boxes(bb, label=None, group_overlapping_roi=False)

Defines ROI as bounding boxes.

Parameters: bb (sequence) – collection of bounding boxes, each bounding boxes being a pair of lower and upper bounds (numpy.ndarray) label (str) – unique label for the collection group_overlapping_roi (bool) – if False, as_support_regions() will behave similarly to as_individual_roi(), otherwise support regions are unions of overlapping ROI

See also BoundingBoxes.

from_squares(centers, side, label=None, group_overlapping_roi=False)

Defines spatial ROI as centers for squares/cubes of uniform size.

Centers should be provided as a sequence of ndarray or an NxD matrix, with D the number of spatial dimensions.

See also from_bounding_boxes().

from_ascii_file(filepath, size=None, label=None, group_overlapping_roi=False)

Reads the ROI centers or bounds from a text file.

Note

This initializer can only be called from the decentralized roi attribute of an SPTDataItem item of the RWAnalyzer spt_data main attribute.

See also ROIAsciiFile.

from_ascii_files(suffix='roi', extension='.txt', size=None, label=None, group_overlapping_roi=False, skip_missing=False)

Reads the ROI centers or bounds from text files – one file per item in spt_data.

The file paths are inferred from the SPT data source files (source attribute). Files are looked for in the same directories as the corresponding SPT data file, and are expected to be named with the same basename, plus a suffix and the .txt extension.

A hyphen or underscore character is automatically appended left of the suffix if necessary.

If the source attribute of the SPTDataItem items is not defined, a ValueError exception is raised.

Note

Calling this initializer method from a satellite roi attribute (nested in an SPTDataItem data block) is equivalent to calling the same initializer from the RWAnalyzer roi main attribute.

See also ROIAsciiFiles.

from_dedicated_rwa_record(label=None, version=None, **kwargs)

See also v1_ROIRecord and v2_ROIRecord.

from_dedicated_rwa_records(label=None, version=None, _impl=None)

See also ROIRecords.

as_support_regions(index=None, source=None, return_index=False)

Generator function; loops over all the support regions.

A ROIInitializer attribute object does not define any ROI, as a consequence a single FullRegion object is yielded.

as_individual_roi(index=None, collection=None, source=None, **kwargs)

Generator function; loops over all the individual ROI.

A ROIInitializer does not define any ROI, as a consequence a single FullRegion object is yielded.

class tramway.analyzer.roi.CommonROI(roi, parent=None)

Bases: tramway.analyzer.attribute.AnalyzerNode

Mirrors the global roi attribute.

The individual SPTDataItem.roi attributes become CommonROI objects as soon as the global roi attribute is specialized, so that as_support_regions() and as_individual_roi() iterators delegate to the global attribute.

to_ascii_file(filepath, collection=None, **kwargs)

Exports the regions of interest to a text file.

Parameters: filepath (str or Path) – output filepath. collection (str) – roi collection label.

All keyword arguments are passed to the common ROI object’s to_ascii_file method. See for example BoundingBoxes.to_ascii_file().

class tramway.analyzer.roi.SpecializedROI(**kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Basis for initialized ROI classes.

as_support_regions(index=None, source=None, return_index=False)

Generator function; iterates over the support regions.

Support regions are the regions to be processed. An individual ROI operates as a window on a support region.

get_support_region(index, collection=None)

Returns the SupportRegion object corresponding to an individual ROI.

Note

When using individual ROI indices and the parallelization capability of pipeline, beware that as_individual_roi() is not controlled by the proper filters, unlike as_support_regions(), in all the possible implementations. get_support_region() may still be called on workers assigned to processing other regions and consequently raise a RuntimeError exception.

class tramway.analyzer.roi.BoundingBoxes(bb, label=None, group_overlapping_roi=False, **kwargs)

Bounding boxes are a list of pairs of NumPy row arrays (1xD).

The first array specifies the lower bounds, the second array the upper bounds.

as_individual_roi(index=None, collection=None, source=None, return_index=False)

Generator function; iterates over the individual ROI.

index is the index in the collection and collection should be defined if multiple collections of ROI are defined.

Note

Iterating over the individual ROI may be useful for visualization; favor as_support_regions() for data processing.

index_format

Format of the numeric part of the label

Type: str
set_num_digits(n)

Sets the number of digits in the numeric part of the label.

to_ascii_file(filepath, collection=None, columns=None, header=True, float_format='%.4f', **kwargs)

Exports the bounding boxes to text file.

Parameters: filepath (str or Path) – output filepath. collection (str) – roi collection label. columns (sequence of str) – column names; default is: [‘x’, ‘y’] for 2D, [‘x’, ‘y’, ‘t’] for 3D and [‘x’, ‘y’, ‘z’, ‘t’] for 4D. header (bool) – print column names on the first line. float_format (str) – see also pandas.DataFrame.to_csv().

Additional keyword arguments are passed to pandas.DataFrame.to_csv().

class tramway.analyzer.roi.ROIAsciiFile(path, size=None, label=None, group_overlapping_roi=False, **kwargs)

ROI class for the decentralized HasROI.roi attributes to be loaded from text files.

A ROI file contains tab-separated columns with a header line.

The columns represent either centers or bounds.

ROI center information is formed by 'x' and 'y' columns (and optionally 'z' but not 't').

ROI bounds are defined by two columns for each coordinate, for example labelled 'x min' and 'x max' for coordinate x. Time can also be represented this way.

Note that combining spatial center information and time bounds is allowed, i.e. 'x', 'y', 't min' and 't max'.

The center information from a ROI file must be complemented with the size argument/attribute.

reified

True if the files have been loaded

Type: bool
filepath

Path of the ROI file

Type: str
size

ROI size for space components; apply solely to center-defined ROI

Type: float
as_support_regions(*args, **kwargs)

Generator function; iterates over the support regions.

Support regions are the regions to be processed. An individual ROI operates as a window on a support region.

class tramway.analyzer.roi.ROIAsciiFiles(suffix='roi', extension='.txt', side=None, label=None, group_overlapping_roi=False, skip_missing=False, **kwargs)

ROI class for multiple ROI text files.

The filepaths are inferred from the source attribute of each SPTDataItem in the main spt_data attribute. The SPT file extensions are replaced by a suffix (usually -roi) plus the .txt extension.

See also ROIAsciiFile for more information on the format.

class tramway.analyzer.roi.v1_ROIRecord(label=None, _impl=None, **kwargs)

ROI class for the individual special partitions in an analysis tree.

This storing strategy is likely to be marked as deprecated.

reified

True if the files have been loaded

Type: bool
as_support_regions(*args, **kwargs)

Generator function; iterates over the support regions.

Support regions are the regions to be processed. An individual ROI operates as a window on a support region.

class tramway.analyzer.roi.ROIRecoveredFromSampling(label=None, group_overlapping_roi=False, **kwargs)

ROI class that recovers bounding-box information from the sampling (Partition records) found in the analysis tree, provided that the records are labelled the default way, i.e. with no label or a static label prefix.

The bounding boxes are inferred from the data and, if a sliding time window was defined, from the windowing start time. If the SPT data are location or trajectory data, they are converted into translocation data prior to determining the spatial bounding box.

The resulting bounding boxes may be tighter than the original bounding boxes, but the sampling should not be affected. This may work only if the original ROI were defined with group_overlapping_roi=False for the sampling step.

A major drawback of this approach lies in the fact that ROI centers cannot be recovered, as they are usually implicitly encoded in the bounds (middle point).

A word of warning, though: the procedure of determining the bounding boxes loads all the data from the .rwa files, if the analysis trees are to be loaded from files.

As the name hints, this class was designed for recovering ROI information in the cases this information is no longer available elsewhere.

reified

True if the files have been loaded

Type: bool
as_support_regions(*args, **kwargs)

Generator function; iterates over the support regions.

Support regions are the regions to be processed. An individual ROI operates as a window on a support region.

tramway.analyzer.roi.v2_ROIRecord
class tramway.analyzer.roi.ROIRecords(label=None, version=None, _impl=None, **kwargs)

ROI class for the main roi attribute.

• version=1: v1_ROIRecord for analysis trees with a meta-partition
for each ROI collection;
• version=2: v2_ROIRecord to recover ROI definition from the
the sampling/partition records available in the analysis trees without any extra information (no meta-partition).
class tramway.analyzer.roi.HasROI(roi=<class 'tramway.analyzer.roi.ROIInitializer'>, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Class to be inherited from by SPT data item classes.

Maintains a self-modifying roi attribute.

roi

Regions of interest for the parent data block

Type: ROI
compatible_source(source)

Returns True if filter source matches with self.source.

Note

Does not check against the alias.

class tramway.analyzer.roi.ROI

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the roi attribute of an RWAnalyzer object.

as_individual_roi(index=None, collection=None)

Generator function; iterates over the individual ROI.

index is the index in the collection and collection should be defined if multiple collections of ROI are defined.

Note

Iterating over the individual ROI may be useful for visualization; favor as_support_regions() for data processing.

as_support_regions(index=None)

Generator function; iterates over the support regions.

Support regions are the regions to be processed. An individual ROI operates as a window on a support region.

tramway.analyzer.roi.utils module¶

tramway.analyzer.roi.utils.set_contiguous_time_support_by_count(points, space_bounds, time_window, min_points, min_segments=1, group_overlapping_roi=False, start_stop_min_points=None)
Parameters: points (DataFrame) – location or translocation data space_bounds (dict or sequence) – (collections of) boundaries, each boundary being a pair of NumPy arrays (lower, upper) time_window (float or pair of floats) – window duration or window duration and shift min_points (int) – desired minimum number of data rows per time segment min_segments (int) – desired minimum number of selected time segments. group_overlapping_roi (bool) – see RoiCollections similar to points, with an additional column for time in each bound array. dict or list
tramway.analyzer.roi.utils.group_roi(a, *args, overlap=0.75, return_matches_only=False)

Returns the smallest rectangles that contain the ROI grouped depending on whether they overlap or not.

A ROI should be a pair (tuple) of numpy.ndarray for (lower-,upper-) bounds.

Time is handled just like any space coordinate. As a consequence, if time bounds are also specified, the corresponding values should be scaled so that time can be artificially related to space in the volume calculation carried out in the estimatation of the amount of overlap.

tramway.analyzer.roi.utils.distance_to_roi_center(roi_obj, sampling)
Parameters: roi_obj (IndividualROI) – ROI object sampling (Partition or Analysis) – tessellation distance between each cell center and the ROI center ndarray

tramway.analyzer.tesseller package¶

class tramway.analyzer.tesseller.TessellerInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initializer class for the RWAnalyzer tesseller main attribute.

The tesseller attribute self-modifies on calling any of the from_… methods.

The easiest way to define a tesseller is to set the tesseller attribute with any of the tesseller classes provided by the tessellers module:

from tramway.analyzer import *

a = RWAnalyzer()
a.tesseller = tessellers.KMeans

Note that tessellers is made available by importing tramway.analyzer.

from_callable(cls)

Argument:

cls (callable):
no-argument callable object (usually a class) that returns a Tesseller object.
mpl

Matplotlib utilities

class tramway.analyzer.tesseller.Tesseller

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the tesseller attribute of an RWAnalyzer object.

resolution

Desired spatial resolution in $$\mu m$$

Type: float
class tramway.analyzer.tesseller.TessellerProxy(cls, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Encapsulates a tessellation plugin as defined in the tramway.tessellation package.

Attributes are managed with the following rules:

• if an attribute is set using a proxy property, the value is flagged as 'explicit' and overrides any default value;
• the arguments in _init_kwargs are passed to the wrapped tesseller’s __init__(); these arguments are intended to prevent __init__() from crashing if the later requires some arguments to be defined; non-explicit values are likely to be overriden and both explicit and non-explicit values may be altered by __init__();
• the arguments in _tessellate_kwargs are passed to the wrapped tesseller’s tessellate() method; all available arguments should be defined in the proxy’s __init__(), with default values;
• the wrapped tesseller’s attributes can be accessed using proxy properties; as a consequence, any key in _explicit_kwargs, that is not in _init_kwargs or _tessellate_kwargs, is considered as an actual attribute;
• an argument should not be defined both in _init_kwargs and _tessellate_kwargs;
• explicit __init__() arguments take precedence over standard attributes;
reset(clear_explicit_attrs=False)

resets the tesseller to let the calibration parameters vary.

helper_cls

Tessellation helper class, inheriting from tramway.helper.tessellation.Tessellate

Type: type
tessellate(spt_dataframe)

Grows and returns the tessellation.

mpl

Matplotlib utilities

class tramway.analyzer.tesseller.TessellerPlugin(name, **kwargs)

Wraps any plugin referenced in tramway.tessellation.plugins.

class tramway.analyzer.tesseller.TessellationPostProcessing

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the post attribute of a Tesseller object.

tramway.analyzer.tesseller.proxy module¶

class tramway.analyzer.tesseller.proxy.TessellerProxy(cls, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

Encapsulates a tessellation plugin as defined in the tramway.tessellation package.

Attributes are managed with the following rules:

• if an attribute is set using a proxy property, the value is flagged as 'explicit' and overrides any default value;
• the arguments in _init_kwargs are passed to the wrapped tesseller’s __init__(); these arguments are intended to prevent __init__() from crashing if the later requires some arguments to be defined; non-explicit values are likely to be overriden and both explicit and non-explicit values may be altered by __init__();
• the arguments in _tessellate_kwargs are passed to the wrapped tesseller’s tessellate() method; all available arguments should be defined in the proxy’s __init__(), with default values;
• the wrapped tesseller’s attributes can be accessed using proxy properties; as a consequence, any key in _explicit_kwargs, that is not in _init_kwargs or _tessellate_kwargs, is considered as an actual attribute;
• an argument should not be defined both in _init_kwargs and _tessellate_kwargs;
• explicit __init__() arguments take precedence over standard attributes;
helper_cls

Tessellation helper class, inheriting from tramway.helper.tessellation.Tessellate

Type: type
mpl

Matplotlib utilities

reset(clear_explicit_attrs=False)

resets the tesseller to let the calibration parameters vary.

tessellate(spt_dataframe)

Grows and returns the tessellation.

tramway.analyzer.tesseller.proxy.proxy_property(propname, level='default', doc=None)

Property factory function similar to builtin property, dedicated to the TessellerProxy class.

For 'tessellate' level properties, the default level is safe.

For '__init__' level properties, the level must be specified.

For standard attributes, it is safer to make the level explicit, so that some conflicts may be detected earlier (e.g. at module loading).

class tramway.analyzer.tesseller.proxy.FreeResolutionTesseller(cls, **kwargs)

tramway.analyzer.tesseller.proxied module¶

This module is exported by the tramway.analyzer package as tessellers.

class tramway.analyzer.tesseller.proxied.Squares(**kwargs)
avg_distance

Average distance between adjacent square centers or, equivalently, average square size; ignored if avg_probability is defined

Type: float
avg_probability

Average probability for a point to fall within any given square

Type: float
count_per_dim

Number of squares per space dimension

Type: int
lower_bound

Scaled lower space bounds

Type: ndarray or Series
min_distance

Minimum distance between adjacent square centers or, equivalently, minimum square size; ignored if avg_distance is defined

Type: float
upper_bound

Scaled upper space bounds

Type: ndarray or Series
class tramway.analyzer.tesseller.proxied.Hexagons(**kwargs)
avg_distance

Average distance between adjacent hexagon centers or, equivalently, average diameter of the inscribed circle; ignored if avg_probability is defined

Type: float
avg_probability

Average probability for a point to fall within any given hexagon

Type: float
lower_bound

Scaled lower space bounds

Type: ndarray or Series
min_distance

Minimum distance between adjacent hexagon centers or, equivalently, minimum diameter of the inscribed circle; ignored if avg_distance is defined

Type: float
tilt

Angle of the “main” axis, in $$\frac{\pi}{6}$$ radians; 0= the main axis is the x-axis; 1= the main axis is the y-axis

Type: float
upper_bound

Scaled upper space bounds

Type: ndarray or Series
class tramway.analyzer.tesseller.proxied.KMeans(**kwargs)
avg_distance

Average distance between adjacent cell centers; affects the 'grid' initialization only

Type: float
avg_probability

Average probability for a point to fall within any given cell

Type: float
initial

Any of 'grid' (default), 'random' and 'center'; 'grid' uses Squares to initialize the cell centers; 'random' randomly samples the initial cell centers; 'center' is similar to 'random' but confines the random cell centers within a tiny area in the middle

Type: str
min_distance

Minimum distance between adjacent cell centers; affects the 'grid' initialization only

Type: float
prune

Maximum edge length for the Voronoi graph, relative to the median edge length; if True, defaults to 2.5; the edges that exceed the derived threshold value are pruned

Type: bool or float
tol

Error tolerance; passed as thresh to scipy.cluster.vq.kmeans()

Type: float
class tramway.analyzer.tesseller.proxied.GWR(**kwargs)
alpha_risk

Threshold p-value in the comparison between distance distributions to determine whether the edges that are not in the Delaunay graph are still valid

Type: float
batch_size

Number of points per epoch; this merely affects the node merging mechanism triggered between epochs

Type: int
collapse_tol

Maximum ratio of the number of collapsed nodes over the total number of nodes

Type: float
complete_delaunay

Use the Delaunay graph instead, for determining the cell adjacency; default is True

Type: bool
error_count_tol

Maximum rate of errors as defined by residual_factor and the batch size; as long as the rate does not fall below this threshold value, tessellate() keeps on sampling batches

Type: float
lifetime

Edge lifetime in number of iterations; taken as absolute, if greater than 1; otherwise relative to the number of nodes in the graph

Type: float
min_growth

Minimum relative increase in the number of nodes

Type: float
min_probability

Minimum probability for a point to fall within any given cell

Type: float
pass_count

Number of points to sample (with replacement), as a multiple of the total size of the data; a pair of values denotes the lower and upper bounds on the number of points; a single value is interpreted as the lower bound, and the upper bound is then set equal to 2 * pass_count

Type: float or (float, float)
residual_factor

Maximum residual for each sample point, relative to _max_distance

Type: float
tau

Habituation scaling factor, in number of iterations, for the nearest and second nearest nodes respectively

Type: float or (float, float)
tessellate(spt_dataframe)

Grows and returns the tessellation.

topology

Any of 'approximate density' and 'displacement length' (default for trajectory/translocation data)

Type: str
trust

Confidence in outstanding points to become new nodes; the new node is set as $$\frac{(1-\rm{trust})*w + (1+\rm{trust})*\eta}{2}$$; the original GWR algorithm corresponds to trust = 0

Type: float
verbose

Verbose mode; default is False

Type: bool

tramway.analyzer.tesseller.plugin module¶

class tramway.analyzer.tesseller.plugin.TessellerPlugin(name, **kwargs)

Wraps any plugin referenced in tramway.tessellation.plugins.

tramway.analyzer.tesseller.plugin.tesseller_plugin(name)

Translate plugin names into RWAnalyzer-ready tessellers as defined in the tessellers module, if available, else returns a generic TessellerPlugin initializer.

tramway.analyzer.tesseller.post package¶

class tramway.analyzer.tesseller.post.TessellationPostProcessingInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initializer class for attribute tesseller post.

For now, a single use case is available:

a = RWAnalyzer()
# initialize attribute tesseller
a.tesseller = tessellers.KMeans
# .. so that attribute post is exposed
a.tesseller.post = cell_mergers.ByTranslocationCount
# .. and now tesseller.post is initialized
a.tesseller.post.count_threshold = 20

Note that cell_mergers is exported by the tramway.analyzer module, just like tessellers.

See also ByTranslocationCount.

from_callable(cls)

Argument:

cls (callable):
no-argument callable object (usually a class) that returns a TessellationPostProcessing object.

tramway.analyzer.tesseller.post.merger module¶

This module is exported by the tramway.analyzer package as cell_mergers.

class tramway.analyzer.tesseller.post.merger.ByTranslocationCount(**kwargs)

Bases: tramway.analyzer.tesseller.post.merger.CellMerger

Merges the cells/microdomains that exhibit a number of translocations below some threshold.

Note

For now, all locations are counted instead of translocations only.

tramway.analyzer.tesseller.mpl module¶

class tramway.analyzer.tesseller.mpl.Mpl(parent=None)

Bases: tramway.analyzer.attribute.AnalyzerNode

Matplotlib plotting utilities for 2D data; no time support.

animate(fig, sampling, axes=None, voronoi_options={}, location_options={}, **kwargs)

As this method is of limited interest, it has been poorly tested.

The RWAnalyzer.time attribute is accessed.

plot(tessellation, locations=None, axes=None, voronoi_options={}, delaunay_options=None, location_options={}, **kwargs)

Plot the particle locations and the Voronoi graph (or tessellation).

plot does not access any RWAnalyzer attribute and can be safely called with no side effect.

plot_cell_indices(tessellation, axes=None, voronoi_options={}, delaunay_options=None, aspect='equal', title=None, **kwargs)

Plot the Voronoi graph and Voronoi cell indices.

The placement of the text elements is not optimized.

tramway.analyzer.time package¶

class tramway.analyzer.time.DT

Bases: object

Implements the default behavior of methods common to the initializer and the specialized attributes.

It gives access to the frame interval (the dt and time_step attributes are aliases of frame_interval), and features the as_time_segments() slicer.

The default implementation suits the initializer’s behavior, i.e. a single all-in time segment.

enable_regularization()

This method is called before running the inference plugins that define time_prior parameters.

n_time_segments(sampling)

Returns the number of time segments (int) that sampling includes, under the hypothesis that sampling was generated following this segments definition (self).

as_time_segments(sampling, maps=None, index=None, return_index=False, return_times=True)

Generator function; yields single-segment sampling and map objects.

Slices sampling and maps and yields tuples with elements in the following order:

• segment index (int), if return_index is True,
• segment start and stop times (float, float), if return_times is True (default),
• segment Partition object, from sampling,
• segment maps (pandas.DataFrame) from maps, if maps is defined.

index is a selector on the segment index, either as an int, a set of int, a sequence of int, or a callable that takes a segment index (int) as input argument and returns a bool.

dt

See dt

Type: float
time_step
Type: float
frame_interval
Type: float
get_spatial_segmentation(sampling, segment=None)

Returns the spatial tessellation.

class tramway.analyzer.time.TimeInitializer(*args, **kwargs)

Bases: tramway.analyzer.attribute.Initializer, tramway.analyzer.time.DT

Initializer Time class for the RWAnalyzer time main attribute.

The time attribute self-modifies on calling from_… methods.

from_sliding_window(duration=None, shift=None)

Defines a sliding time window.

Parameters: duration (float) – window duration in seconds shift (float) – time shift between successive segments, in seconds; by default, equals to duration

See also SlidingWindow.

from_sampling(sampling=None, verbose=False)

Extracts the time segmentation parameters stored in a Partition object and tries to initialize the parent time attribute correspondingly.

This may fail, either silently or raising a ValueError exception, as this method covers only cases of sliding windows.

If argument sampling is not an Analysis or Partition object, it is taken as the label of an artefact in any analysis tree.

class tramway.analyzer.time.SlidingWindow(duration=None, shift=None, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode, tramway.analyzer.time.DT

Specialization for the time attribute.

Defines the segment() method that segments the SPT data into time segments and combines with the spatial tessellation.

duration

Window duration in seconds

Type: float
shift

Time shift between successive time segments, in seconds

Type: float
window_duration

Alias for duration

Type: float
window_shift

Alias for shift

Type: float
start_time

Start time for running the sliding window. By default, the window starts from the first data point in the input data (usually the ROI-cropped data, NOT the entire SPT dataset).

Type: float
sync_start_times()

aligns the start times of all the ROI to the same minimum time.

Beware this may load all the SPT data files. Setting the bounds attribute of the spt_data main attribute discards the need for screening the SPT data.

segment(spt_dataframe, tessellation=None)

Segments the SPT data, combines the segmentation with a spatial tessellation if any, and returns a TimeLattice object.

enable_regularization()

This method is called before running the inference plugins that define time_prior parameters.

regularize_in_time

True if time regularization is enabled

Type: bool
get_time_segments(sampling)

Returns the time segment bounds as an Nx2 array.

get_spatial_segmentation(sampling, segment=None)

Returns the spatial tessellation.

n_time_segments(sampling)

Returns the number of time segments (int) that sampling includes, under the hypothesis that sampling was generated following this segments definition (self).

as_time_segments(sampling, maps=None, index=None, return_index=False, return_times=True)

Generator function; yields single-segment sampling and map objects.

Slices sampling and maps and yields tuples with elements in the following order:

• segment index (int), if return_index is True,
• segment start and stop times (float, float), if return_times is True (default),
• segment Partition object, from sampling,
• segment maps (pandas.DataFrame) from maps, if maps is defined.

index is a selector on the segment index, either as an int, a set of int, a sequence of int, or a callable that takes a segment index (int) as input argument and returns a bool.

segment_label(map_label, times, sampling)

Makes a label combining the input label as prefix and time-related suffix.

class tramway.analyzer.time.Time

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the time attribute of an RWAnalyzer object.

segment(spt_dataframe, tessellation=None)

Segments the SPT data, combines the segmentation with a spatial tessellation if any, and returns a TimeLattice object.

as_time_segments(sampling, maps=None, index=None, return_index=False, return_times=True)

Generator function; yields single-segment sampling and map objects.

Slices sampling and maps and yields tuples with elements in the following order:

• segment index (int), if return_index is True,
• segment start and stop times (float, float), if return_times is True (default),
• segment Partition object, from sampling,
• segment maps (pandas.DataFrame) from maps, if maps is defined.

index is a selector on the segment index, either as an int, a set of int, a sequence of int, or a callable that takes a segment index (int) as input argument and returns a bool.

dt

See dt

Type: float

tramway.analyzer.sampler package¶

class tramway.analyzer.sampler.BaseSampler(**kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

wraps the Partition.cell_index logics that readily implements all the possibilities mentioned in this module.

min_location_count

Minimum number of assigned (trans-)locations, as given by the default Voronoi sampling; any microdomain with too few assigned (trans-)locations are marked as disabled and are excluded from further analyses

Type: int
class tramway.analyzer.sampler.VoronoiSampler(**kwargs)

nearest neighbor assignment.

Each data point is assigned to exactly one cell/microdomain.

class tramway.analyzer.sampler.SamplerInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Initializer class for the RWAnalyzer sampler main attribute.

The sampler attribute self-modifies on calling any of the from_… methods.

The default not-initialized sampler attribute behaves like:

a = RWAnalyzer()
a.sampler.from_voronoi()

from_voronoi()

default sampler.

The data points are assigned to the nearest cell/microdomain.

See also VoronoiSampler.

from_spheres(radius)

nearest neighbor assignment by distance.

Voronoi assignment is applied first and then, for each microdomain, the maximum distance of the assigned points to the center of the cell is considered. The radius argument defines a lower and/or upper bound(s) on the distance from the cell center. If the most distant assigned point is out of the specified bounds, additional points are selected (or assigned points are discarded) in order of distance from the corresponding cell center.

See also SphericalSampler.

from_nearest_neighbors(knn)

nearest neighbor assignment by count.

The Voronoi assignment is applied first. The knn argument defines a lower and/or upper bound(s) on the number of neighbors. For each microdomain, if the number that results from Voronoi assignment is out of the specified bounds, additional points are selected (or assigned points are discarded) in order of distance from the corresponding cell center.

See also Knn.

from_nearest_time_neighbors(knn)

similar to from_nearest_neighbors but cell/microdomain size is adjusted in time instead of space.

See also TimeKnn.

sample(spt_data, segmentation=None)

main processing method.

class tramway.analyzer.sampler.SphericalSampler(radius, **kwargs)

nearest neighbor selection by distance.

radius

Lower bound or (lower bound, upper bound) pair on the distance from a cell/microdomain center; alternatively, a function can define these bounds for each microdomain (takes the microdomain index as input argument)

Type: float or (float, float) or callable
class tramway.analyzer.sampler.Knn(knn, **kwargs)

nearest neighbor selection by count.

knn

Lower bound or (lower bound, upper bound) pair on the number of data points which, if Voronoi assignment yields a number out of these bounds, triggers a procedure that picks extra points (or discards assigned points) wrt distance from the Voronoi cell center. This applies independently for each microdomain with insufficient or too many points. Alternatively, bounds can be defined on a per-microdomain basis with a function that takes the microdomain index as an int and returns either an int or a pair of int or None

Type: int or (int, int) or callable
class tramway.analyzer.sampler.TimeKnn(knn, **kwargs)

nearest neighbor selection by count across time.

knn

Lower bound or (lower bound, upper bound) pair on the number of data points which, if Voronoi assignment yields a number out of these bounds, triggers the shrinking or widening of the time window, centered on the original middle point of the time segment. This applies independently for each microdomain with insufficient or too many points. microdomain with insufficient or too many points. Alternatively, bounds can be defined on a per-microdomain basis with a function that takes the microdomain index as an int and returns either an int or a pair of int or None

Type: int or (int, int) or callable
class tramway.analyzer.sampler.Sampler

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the sampler attribute of an RWAnalyzer object.

tramway.analyzer.mapper package¶

class tramway.analyzer.mapper.MapperInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer, tramway.analyzer.mapper.plugin.MapperAttribute

from_maps(label_or_maps=None, exclude_attrs=(), verbose=False)

Sets the mapper up on basis of parameters in a Maps object.

If a label is passed instead of a Maps object (or nothing), the corresponding artefact is sought for in the analysis tree, starting from the first branch (first sampling) in the first tree.

This method has been designed for the stochastic.dv plugin. Application to other plugins has not been tested.

Parameters: label_or_maps (Maps or Analysis or int or str or tuple or list) – maps object or label(s) of the maps artefact to be found in any registered analysis tree exclude_attrs (iterable) – attributes of the maps object to be ignored verbose (bool) – prints the plugin name and loaded attributes
class tramway.analyzer.mapper.Mapper

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the mapper attribute of an RWAnalyzer object.

class tramway.analyzer.mapper.MapperPlugin(plugin, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode, tramway.analyzer.mapper.plugin.MapperAttribute

tramway.analyzer.mapper.mpl module¶

class tramway.analyzer.mapper.mpl.PatchCollection(ax, mesh, bounding_box=None, overlay_locations=False, time_label_fmt='t= %t-%ts', time_label_loc=(0.01, 1.01), **kwargs)

Bases: object

Makes glyphs for space bins to be drawn as patches.

For constant spatial mesh and 2D localization data only.

Vector maps are not supported yet.

animate(map)

To be passed as second positional argument to FuncAnimation.

Parameters: map (Series) – parameter values; can also be a tuple with the actual map argument being last. list of glyphs to update. callable
init_func()

To be passed as argument init_func to FuncAnimation.

plot(map, times=None, locations=None)

Updates the color of the patches.

Parameters: map (Series) – parameter values. times (tuple) – time segment bounds, in seconds. locations (DataFrame) – segment locations. sequence of updated glyphs. tuple
class tramway.analyzer.mapper.mpl.Mpl(parent=None)

Bases: tramway.analyzer.attribute.AnalyzerNode

Matplotlib interface for maps.

animate(fig, maps, feature, sampling=None, overlay_locations=False, axes=None, aspect='equal', logscale=False, composable=True, **kwargs)

Animates the time-segmented inference parameters.

Vector features are represented as amplitude.

The RWAnalyzer.time attribute is accessed.

Parameters: fig (matplotlib.figure.Figure) – figure. maps (Analysis or Maps) – map series. feature (str) – parameter to be drawn. sampling (Analysis or Partition) – spatial bins and time segments; optional only if maps is an Analysis. overlay_locations (bool or dict) – styling options for the overlaid locations. axes (matplotlib.axes.Axes) – figure axes. aspect (str or None) – aspect ratio. logscale (bool or str) – transform the color-coded values in natural logarithm; can also be ‘log’, ‘natural’ or ‘log10’. composable (bool) – returns an overloaded FuncAnimation object that can be passed in place of argument fig in later calls to animate() so to stack animations on different axes (axes) of a same figure (fig). animation object. matplotlib.animation.FuncAnimation

Extra input arguments are passed to FuncAnimation or PatchCollection (and scalar_map_2d()).

Notebook example:

Note: the above example seems to work equally well without composable=True.

clabel(feature, kwargs, logscale=None, map_kwargs=None)

Extracts from kwargs arguments related to the colorbar label and adds a 'unit' or clabel argument to map_kwargs if necessary.

plot(maps, feature, sampling=None, axes=None, aspect='equal', interior_contour=None, overlay_locations=False, logscale=None, **kwargs)

Calls map_plot().

May be reworked in the future to remove the helper dependency.

logscale applies only to the color-coded background of field maps.

new in 0.5.2: argument interior_contour is a :classdict with the following keys allowed: margin, linestyle, linewidth and color. The default value for margin (or relative_margin) is 0.01.

plot does not access any analyzer attributes and can be safely called from any analyzer:

from tramway.analyzer import RWAnalyzer

RWAnalyzer().mapper.mpl.plot(…)

or instanciating an Mpl object:

from tramway.analyzer.mapper.mpl import Mpl

Mpl().plot(…)

tramway.analyzer.pipeline package¶

class tramway.analyzer.pipeline.Pipeline(*args, **kwargs)

Bases: tramway.analyzer.attribute.AnalyzerNode

pipeline attribute of an RWAnalyzer object.

The main methods are append_stage() and run().

add_collectible(filepath)

Registers a file as to be collected after stage completion.

append_stage(stage, granularity=None, requires_mutability=None, **options)

Appends a pipeline stage to the processing chain.

Parameters: stage (callable) – function that takes an RWAnalyzer object as unique input argument. granularity (str) – smallest data item stage can independently process; any of 'coarsest' or equivalently 'full dataset', 'source' or equivalently 'spt data', 'data source' or 'spt data source', 'roi' or equivalently 'region of interest', 'time' or equivalently 'segment' or 'time segment' (case-insensitive). new in 0.6.2: granularity can be prefixed with min: requires_mutability (bool) – callable object stage alters input argument self. Stages with this argument set to True are always run as dependencies. Default is False. update_existing_rwa_files (bool) – see also PipelineStage. run_everywhere (bool) – new in 0.6.2; see also PipelineStage.

new in 0.6.2: the min: prefix for granularity can be passed to prevent flexible-level stages to be combined with others of incompatible granularity. For example, a fresh_start stage should operate no below source, because it may delete source-level files, which is not compatible with a roi-level stage that may be split into multiple jobs working on the same source file. Note however that passing run_everywhere=True to a fresh_start stage is preferred as this is more portable.

early_setup(**kwargs)

Sets the submit_side/worker_side properties of the env attribute.

early_setup() can be called once env is initialized and before run() is called. This allows to run some conditional code, specifically on the submit side or on the worker side.

This method returns silently if env is not initialized and both the env.EnvironmentInitializer.submit_side and env.EnvironmentInitializer.worker_side properties are False.

reset()

Empties the pipeline processing chain.

resume(**kwargs)

Looks for orphaned remote jobs and collect the generated files.

Works as a replacement for the run() method to recover after connection loss.

Recovery procedures featured by the env backend may fail or recover some of the generated files only.

See also the resume() method of the env attribute, if available.

run()

Sequentially runs the different stages of the pipeline.

class tramway.analyzer.pipeline.PipelineStage(run, granularity=None, requires_mutability=None, update_existing_rwa_files=None, run_everywhere=None, **options)

Bases: object

Wrapper for callables to be run on calling Pipeline.run().

requires_mutability defaults to False.

update_existing_rwa_files defaults to False as of version 5.2.

new in 0.6.2: boolean argument and attribute run_everywhere. The main difference with requires_mutability is that the run_everywhere stage runs at most once on each host.

A fresh_start stage will typically set run_everywhere to True, while a reload stage will set requires_mutability to True instead.

granularity
Type: str
name

Callable’s name

Type: str
requires_mutability
Type: bool
run_everywhere

Run once on every host, both local and remote

Type: bool

tramway.analyzer.pipeline.stages module¶

This module is exported by the tramway.analyzer package.

Standard analysis steps for RWAnalyzer.pipeline

tramway.analyzer.pipeline.stages.tessellate(label=None, roi_expected=False, spt_data=True, tessellation='freeze', **kwargs)

Returns a standard pipeline stage for SPT data sampling.

Although the name ‘tessellate’ refers merely to the spatial segmentation, time segmentation is also handled, if defined. The name alludes to the standalone tramway.helper.tessellation.tessellate() function.

The default granulariy is set to ‘spt data’, whereas in principle the finest valid granularity is ‘roi’. The tessellation step is fast enough to a avoid the overhead of saving as many files as regions of interest.

Important

If the input SPT data is defined as ascii file(s), the corresponding .rwa files will be overwritten.

If analysis trees already reference analysis artefacts for the specified label, these artefacts are also overwritten.

This stage building function features two mechanisms to make the resulting .rwa files smaller in size:

• with option spt_data=’placeholder’, the SPT data can be omitted in the .rwa files; see also restore_spt_data();
• the spatial tessellation can be freezed (default); this implies the tesellation cannot be updated any longer with extra data.
tramway.analyzer.pipeline.stages.infer(map_label=None, sampling_label=None, roi_expected=False, overwrite=False, single_path=False, **kwargs)

Returns a standard pipeline stage for inferring model parameters on each region of interest, or SPT data item if no roi are defined.

The default granularity is set to ‘roi’, which is suitable for computer-intensive inferences such as ‘DV’.

With default overwrite=False, if the specified output label map_label already exists in analysis trees, the inference is skipped for these analysis trees and the corresponding artefact not overwritten. However, if map_label is None, overwrite is ignored and the stage acts like if overwrite were True.

tramway.analyzer.pipeline.stages.reload(skip_missing=True)

Returns a pipeline stage to reload the generated .rwa files.

This is useful if a first computation - e.g. tessellate - was dispatched (including with the environments.LocalHost environment) and the .rwa files were generated and retrieved from the worker environments. In the case a second stage has to be dispatched - e.g. infer, the local pipeline must be updated with the content of these retrieved files.

This may also be required on the worker side for the next stages, for example if the SPT data was initially defined from ascii files and the coming stages should take over from the corresponding .rwa files. As a consequence, this reload stage is set with requires_mutability=True.

tramway.analyzer.pipeline.stages.restore_spt_data()

Reintroduces the original SPT dataframe into the .rwa files.

This post-processing stage - typically post-infer stage - is expected to be called only when the tessellate stage was called before with option spt_data=’placeholder’.

This stage was tested with SPT data defined as SPTAsciiFiles or spt_data.RWAFiles. However, with SPTAsciiFiles, the alias attribute should be defined.

tramway.analyzer.pipeline.stages.tessellate_and_infer(map_label=None, sampling_label=None, spt_data=True, overwrite=False, roi_expected=False, load_rwa_files=None, **kwargs)

Combines tessellate and infer at roi granularity.

See infer() for important notes on overwrite argument.

new in 0.6: unless load_rwa_files=False, .rwa files are loaded if the SPT data source has not already been loaded from such files.

tramway.analyzer.env package¶

class tramway.analyzer.env.EnvironmentInitializer(attribute_setter, parent=None)

Bases: tramway.analyzer.attribute.Initializer

Can be left not-initialized.

For local multi-processing:

a.env = environments.LocalHost

For sbatch job scheduling on an SSH-reachable server:

a.env = environments.SlurmOverSSH

script

Path to the local script; this compatibility attribute is actually used by the browser

Type: str
collectibles

Compatilibity attribute; not used

Type: set
class tramway.analyzer.env.Environment

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the env attribute of an RWAnalyzer object.

script

Path to the local script; usually a filename

Type: str
dispatch(**kwargs)

Input arguments must be keyworded.

Parameters: stage_index (int) – index of the pipeline stage which material has to be dispatched. source (str) – source name of the spt dataset to be dispatched.

tramway.analyzer.env.environments module¶

This module is exported by the tramway.analyzer package as environments.

class tramway.analyzer.env.environments.Environment

Bases: tramway.analyzer.attribute.abc.Attribute

Abstract base class for the env attribute of an RWAnalyzer object.

dispatch(**kwargs)

Input arguments must be keyworded.

Parameters: stage_index (int) – index of the pipeline stage which material has to be dispatched. source (str) – source name of the spt dataset to be dispatched.
script

Path to the local script; usually a filename

Type: str
class tramway.analyzer.env.environments.LocalHost(**kwargs)

Bases: tramway.analyzer.env.environments.Env

Runs jobs in local python processes.

Because of a design limitation in tramway.analyzer.pipeline (type check), Every class that similarly implements local-only parallel processing should ideally be derived from this class. This may not be critical, as failure to do so will only make run_everywhere stages to run twice instead of once.

interrupt_jobs()

Interrupts the running jobs.

worker_count

Desired number of workers

Type: int
class tramway.analyzer.env.environments.SlurmOverSSH(**kwargs)

Bases: tramway.analyzer.env.environments.Slurm, tramway.analyzer.env.environments.RemoteHost

Calls sbatch through an SSH connection to a Slurm server.

Note

All filepaths should be absolute or relative to the \$HOME directory. This applies especially to all file-based initializers.

collect_results(stage_index=None, inplace=False, reload_existing_rwa_files=False)

Downloads the reported collectibles from the remote host (worker side) to the local host (submit side).

See Env.collect_results() for information on the distinct behavior of the inplace=True case.

delete_temporary_data()

Deletes all the temporary data, on both the submit and worker sides.

dispatch(**kwargs)

Prepares the worker side. To be called from the submit side only.

early_setup(*argv, connect=False, **kwargs)

Determines which side is running and sets the submit_side/worker_side attributes.

Takes command-line arguments (sys.argv).

filter_script_content(content)

Processes the script content for its dispatch onto the worker side.

Parameters: content (list of str) – lines with the 'n' character at the end of each line modified lines list of str
make_job(stage_index=None, source=None, region_index=None, segment_index=None)

Registers a new pending job.

Parameters: stage_index (int or list of int) – stage index(ices) source (str) – SPT datablock identifier (source path or alias) region_index (int) – index of the support region (see also as_support_regions()) segment_index (int) – index of the time segment
pack_temporary_rwa_files(log=None, wd=None, stage_index=None, job_id=None)

Similarly to resume(), pack_temporary_rwa_files combines the intermediate .rwa files in the temporary directory for a running instance on the compute host.

This does not move files out of the temporary directory. Instead, the intermediate .rwa files are replaced by new (but fewer) intermediate .rwa files that result from combining the former files.

This may be useful to save disk space, as the localization data is duplicated as many times as there are intermediate files.

Warning

not tested yet

resume(log=None, wd=None, stage_index=None, job_id=None)

Parses log output of the disconnected instance, looks for the current stage index, and tries to collect the resulting files.

This completes the current stage only. Further stages are not run.

Parameters: log (str) – log output; progress information can be omitted wd (str) – location of the working directory on the remote host stage_index (int or list) – index of the stage(s) to resume job_id (str) – Slurm job array ID
setup(*argv, connect=True, **kwargs)

Determines which side is running and alters iterators of the main RWAnalyzer attributes.

Takes command-line arguments (sys.argv).

class tramway.analyzer.env.environments.Tars(**kwargs)

Bases: tramway.analyzer.env.environments.SingularitySlurm

Designed for server tars.pasteur.fr.

The server is closed.

class tramway.analyzer.env.environments.GPULab(**kwargs)

Bases: tramway.analyzer.env.environments.SingularitySlurm

Designed for server adm.inception.hubbioit.pasteur.fr.

class tramway.analyzer.env.environments.Maestro(**kwargs)

Bases: tramway.analyzer.env.environments.SingularitySlurm

Designed for server maestro.pasteur.fr.

tramway.analyzer.browser package¶

class tramway.analyzer.browser.Browser(analyzer)

Bases: tramway.analyzer.attribute.AnalyzerNode

browser attribute of an RWAnalyzer object.

Rendering is based on bokeh and is performed in a web browser tab. An optional side panel with experimental export features is shown if argument side_panel=True is passed to show_maps() or argument webdriver is defined:

from tramway.analyzer import *

a = RWAnalyzer()

a.spt_data.from_rwa_files('*.rwa')

from selenium import webdriver

a.browser.show_maps(webdriver=webdriver.Firefox)

Defining a webdriver is required for exporting figures. Supported file formats are .png and .svg. Note that package selenium is required.

The above example can be explicitly run with bokeh serve, or else it can be run with the standard Python interpreter or in a Jupyter notebook as long as the script attribute is defined:

from tramway.analyzer import *

a = RWAnalyzer()

a.spt_data.from_rwa_files('*.rwa')

try:
a.script = __file__
except NameError: # in a notebook
a.script = 'MyNotebook.ipynb' # this notebook's name; please adapt

from selenium import webdriver

a.browser.show_maps(webdriver=webdriver.Firefox)

The later example will call bokeh serve --show on the file specified in the script attribute.

The showed parameter values can also be exported with the side panel. Note that all features are exported together with the spatial bin center coordinates.

clim

Color lower and upper values (dict values) for each feature (dict keys)

Type: dict of 2-element array-like
colormap

Colormap for inferred parameter maps.

See also scalar_map_2d().

Type: str
show_maps(**kwargs)

See also browse_maps().


text:
# 10 Most Common SAT Math Questions

Preparing for the SAT Math test? Want a preview of the most common mathematics questions on the SAT Math test? If so, then you are in the right place.

The mathematics section of SAT can be a challenging area for many test-takers, but with enough patience, it can be easy and even enjoyable!

Preparing for the SAT Math test can be a nerve-wracking experience. Learning more about what you’re going to see when you take the SAT can help to reduce those pre-test jitters. Here’s your chance to review the 10 most common SAT Math questions to help you know what to expect and what to practice most. Try these 10 most common SAT Math questions to hone your mathematical skills and to see if your math skills are up to date on what’s being asked on the exam or if you still need more practice.

Make sure to follow some of the related links at the bottom of this post to get a better idea of what kind of mathematics questions you need to practice.

$15.99 Satisfied 107 Students ## 10 Sample SAT Math Practice Questions 1- John buys a pepper plant that is 6 inches tall. With regular watering, the plant grows 4 inches a year. Writing John’s plant’s height as a function of time, what does the $$y$$-intercept represent? A. The $$y$$-intercept represents the rate of growth of the plant which is 5 inches B. The $$y$$-intercept represents the starting height of 6 inches C. The $$y$$-intercept represents the rate of growth of the plant which is 3 inches per year D. There is no $$y$$-intercept 2- What is the value of $$\frac{4b}{c}$$ when $$\frac{c}{b} = 2$$ A. 8 B. 4 C. 2 D. 1 3- Which of the following is equivalent to $$\frac{x+(4x)^2+(3x)^3}{x}$$ =? A. $$16x^2+27x+1$$ B. $$27x^2+16x+1$$ C. $$16x^2+27x$$ D. $$27x^3+16x^2+1$$ 4- Given a right triangle ∆ABC whose $$n∠B=90^\circ$$,$$sin \space C=\frac{2}{3}$$, find $$cos \space A$$? A. $$1$$ B. $$\frac{1}{2}$$ C. $$\frac{2}{3}$$ D. $$\frac{3}{2}$$ 5- What is the equation of the graph? A. $$x^2+6x+5$$ B. $$x^2+2x+4$$ C. $$2x^2-4x+4$$ D. $$2x^2+4x+2$$ 6- A construction company is building a wall. The company can build 30 cm of the wall per minute. After 40 minutes $$\frac{3}{4}$$ of the wall is completed. How many meters is the wall? __________ 7- 6 liters of water are poured into an aquarium that’s 15 cm long, 5 cm wide, and 60 cm high. How many centimeters will the water level in the aquarium rise due to this added water? (1 liter of water = 1000 $$cm^3$$) __________ 8- If the interior angles of a quadrilateral are in the ratio $$1:4:7:8$$, what is the measure of the largest angle? __________ 9- The length of a rectangle is 3 meters greater than 4 times its width. The perimeter of the rectangle is 36 meters. What is the area of the rectangle in meters? __________ 10- If the ratio of $$5a$$ to $$2b$$ is $$\frac{1}{10}$$, what is the ratio of $$b$$ to $$a$$? ___________ ## Best SAT Math Prep Resource for 2022 ## Answers: 1- B To solve this problem, first recall the equation of a line: $$y = mx + b$$ Where $$m=slope$$ $$y=y-intercept$$ Remember that slope is the rate of change that occurs in a function and that the y-intercept is the y value corresponding to $$x = 0$$. Since the height of John’s plant is 6 inches tall when he gets it. Time (or $$x$$) is zero. The plant grows 4 inches per year. Therefore, the rate of change of the plant’s height is 4. The y-intercept represents the starting height of the plant which is 6 inches. 2- C To solve this problem first solve the equation for $$c$$. $$\frac{c}{b}=2$$ Multiply by b on both sides. Then: $$b×\frac{c}{b}=2×b→c=2b$$ Now to calculate $$\frac{4b}{c}$$, substitute the value for $$c$$ into the denominator and simplify. $$\frac{4b}{c}=\frac{4b}{2b}=\frac{4}{2}=\frac{2}{1}=2$$ 3- B Simplify the numerator. $$\frac{x+(4x)^2+(3x)^3}{x}=\frac{x+4^2 x^2+3^3 x^3}{x}=\frac{x+16x^2+27x^3}{x}$$ Pull an $$x$$ out of each term in the numerator. $$\frac{x(1+16x+27x^2)}{x}$$ The $$x$$ in the numerator and the $$x$$ in the denominator cancel: $$1+16x+27x^2=27x^2+16x+1$$ 4- C To solve for $$cos \space A$$ first identify what is known. The question states that ∆ABC is a right triangle whose $$n∠B=90^\circ \space and \space sin C =\frac{2}{3}$$ It is important to recall that any triangle has a sum of interior angles that equals 180 degrees. Therefore, to calculate $$cos \space A$$ use the complementary angles identify of a trigonometric function. $$cos \space A=cos \space (90-C)$$ Then: $$cos \space A=sin \space C$$ For complementary angles, the sin of one angle is equal to the cos of the other angle. $$cos \space A=\frac{2}{3}$$ 5- C To figure out what the equation of the graph is, first find the vertex. From the graph, we can determine that the vertex is at (1,2). We can use vertex form to solve the equation of this graph. Recall vertex form, $$y=a(x-h)^2+k$$, where h is the $$x$$ coordinate of the vertex, and k is the $$y$$ coordinate of the vertex. Plugging in our values, you get $$y=a(x-1)^2+2$$ To solve for a, we need to pick a point on the graph and plug it into the equation. Let’s pick (-1,10) $$10=a(-1-1)^2+2$$ $$10=a(-2)^2+2$$ $$10=4a+2$$ $$8=4a$$ $$a=2$$ Now the equation is : $$y=2(x-1)^2+2$$ Let’s expand this, $$y=2(x^2-2x+1)+2$$ $$y=2x^2-4x+2+2$$ $$y=2x^2-4x+4$$ The equation in Choice C is the same. 6- 16 The rate of construction compan $$y=\frac{30 \space cm}{1 \space min}=30 \space cm/min$$ Height of the wall after 40 minutes $$= \frac{30 \space cm}{1 \space min}×40 \space min=1200 \space cm$$ Let $$x$$ be the height of wall, then $$\frac{3}{4}x=1200 \space cm$$ $$→x=\frac{4×1200}{3}→x=1600 \space cm=16 \space m$$ 7- 80 $$One \space liter = 1000 \space cm^3→ 6 \space liters = 6000 \space cm^3$$ $$6000=15×5×h→h=\frac{6000}{75}=80 \space cm$$ 8- 144 The sum of all angles in a quadrilateral is 360 degrees. Let $$x$$ be the smallest angle in the quadrilateral. Then the angles are: $$x,4x,7x,8x$$ $$x+4x+7x+8x=360→20x=360→x=18$$ The angles in the quadrilateral are: $$18\circ, 72\circ, 126\circ$$, and $$144\circ$$ 9- 45 Let L be the length of the rectangular and W be the with of the rectangular. Then, $$L=4W+3$$ The perimeter of the rectangle is 36 meters. Therefore: $$2L+2W=36$$ $$L+W=18$$ Replace the value of L from the first equation into the second equation and solve for W: $$(4W+3)+W=18→5W+3=18→5W=15→W=3$$ The width of the rectangle is 3 meters and its length is: $$L=4W+3=4(3)+3=15$$ The area of the rectangle is: length $$×$$ width $$= 3 × 15 = 45$$ 10- 25 Write the ratio of $$5a$$ to $$2b$$. $$\frac{5a}{2b}=\frac{1}{10}$$ Use cross multiplication and then simplify. $$5a×10=2b×1→50a=2b→a=\frac{2b}{50}=\frac{b}{25}$$ Now, find the ratio of $$b$$ to $$a$$. $$\frac{b}{a}=\frac{b}{\frac{b}{25}}→b÷\frac{b}{25}= b× \frac{25}{b}= 25$$ ## College Entrance Tests Looking for the best resource to help you succeed on the SAT Math test? ## The Best Books to Ace the SAT Math Test$15.99
Satisfied 107 Students

### What people say about "10 Most Common SAT Math Questions"?

No one replied yet.

X
24% OFF

Limited time only!

Save Over 24%

SAVE $5 It was$20.99 now it is \$15.99

format: plain


text:
• Corpus ID: 210919910

# Aliasing error of the exp$(\beta \sqrt{1-z^2})$ kernel in the nonuniform fast Fourier transform

@article{Barnett2020AliasingEO,
title={Aliasing error of the exp\$(\beta \sqrt\{1-z^2\})\$ kernel in the nonuniform fast Fourier transform},
author={Alex H. Barnett},
journal={arXiv: Numerical Analysis},
year={2020}
}
• A. Barnett
• Published 26 January 2020
• Mathematics, Computer Science
• arXiv: Numerical Analysis
The most popular algorithm for the nonuniform fast Fourier transform (NUFFT) uses the dilation of a kernel $\phi$ to spread (or interpolate) between given nonuniform points and a uniform upsampled grid, combined with an FFT and diagonal scaling (deconvolution) in frequency space. The high performance of the recent FINUFFT library is in part due to its use of a new exponential of semicircle'' kernel $\phi(z)=e^{\beta \sqrt{1-z^2}}$, for $z\in[-1,1]$, zero otherwise, whose Fourier transform…
2 Citations
How exponentially ill-conditioned are contiguous submatrices of the Fourier matrix?
The proof uses the Kaiser-Bessel transform pair, and estimates on sums over distorted sinc functions, to construct a localized trial vector whose DFT is also localized, and proves a lower bound on the condition number of any cyclically contiguous submatrix of the discrete Fourier transform (DFT) matrix.
Continuous window functions for NFFT
• Computer Science, Mathematics
• 2021
This paper considers the continuous/discontinuous Kaiser--Bessel, continuous $\exp$- type, and continuous $\cosh$-type window functions and presents novel explicit error estimates for NFFT with such a window function and derive rules for the optimal choice from the parameters involved in N FFT.

## References

SHOWING 1-10 OF 41 REFERENCES
A parallel non-uniform fast Fourier transform library based on an "exponential of semicircle" kernel
• Computer Science, Mathematics
SIAM J. Sci. Comput.
• 2019
FINUFFT is presented, an efficient parallel library for type 1 (nonuiform to uniform), type 2 (uniform to nonuniform), or type 3 (non uniform toNonuniform) transforms, in dimensions 1, 2, or 3, which uses minimal RAM, requires no precomputation or plan steps, and has a simple interface to several languages.
Accelerating the Nonuniform Fast Fourier Transform
• Mathematics, Computer Science
SIAM Rev.
• 2004
This paper observes that one of the standard interpolation or "gridding" schemes, based on Gaussians, can be accelerated by a significant factor without precomputation and storage of the interpolation weights, of particular value in two- and three- dimensional settings.
Nonuniform fast Fourier transforms using min-max interpolation
• Mathematics, Computer Science
IEEE Trans. Signal Process.
• 2003
This paper presents an interpolation method for the nonuniform FT that is optimal in the min-max sense of minimizing the worst-case approximation error over all signals of unit norm and indicates that the proposed method easily generalizes to multidimensional signals.
Optimized Least-Square Nonuniform Fast Fourier Transform
• M. Jacob
• Mathematics, Computer Science
IEEE Transactions on Signal Processing
• 2009
A memory efficient approximation to the nonuniform Fourier transform of a support limited sequence is derived based on the theory of shift-invariant representations and an exact expression for the worst-case mean square approximation error is derived.
Uniform asymptotic expansions for prolate spheriodal functions with large parameters
By application of the theory for second order linear differential equations with a turning point and a regular (double pole) singularity developed by Boyd and Dunster (this Journal, 17 (1986), pp.
PROBABILITY AGAINST CONDITION NUMBER AND SAMPLING OF MULTIVARIATE TRIGONOMETRIC RANDOM POLYNOMIALS
• 2006
The difficult factor in the condition number of a large linear system is the spectral norm of . To eliminate this factor, we here replace worst case analysis by a probabilistic argument. To be more
Fast Fourier Transforms for Nonequispaced Data
• Mathematics, Computer Science
SIAM J. Sci. Comput.
• 1993
A group of algorithms is presented generalizing the fast Fourier transform to the case of noninteger frequencies and nonequispaced nodes on the interval $[ - \pi ,\pi ]$. The schemes of this paper
On the Fast Fourier Transform of Functions with Singularities
Abstract We consider a simple approach for the fast evaluation of the Fourier transform of functions with singularities based on projecting such functions on a subspace of Multiresolution Analysis.
Automated parameter tuning based on RMS errors for nonequispaced FFTs
• F. Nestler
• Mathematics, Computer Science