Reader and Writer¶
napari_relax._reader
¶
napari reader for LineageTree files and the formats LineageTree loads.
Opening a file shows the loader selection and Loading Parameters dialogs, then builds a Points layer (and a Surface layer when the dataset has meshes) that carries the LineageTree in its metadata. See https://napari.org/stable/plugins/guides.html#readers.
napari_get_reader(path)
¶
Return the ReLAX reader if the file extension is supported.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or list of str
|
Path to file, or list of paths. |
required |
Returns:
| Type | Description |
|---|---|
function or None
|
If the path is a recognized format, return a function that accepts the same path or list of paths, and returns a list of layer data tuples. |
reader_function(path)
¶
Load a dataset and return the napari layers to create.
Readers are expected to return data as a list of tuples, where each tuple is (data, [add_kwargs, [layer_type]]), "add_kwargs" and "layer_type" are both optional.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Path to the file to open. |
required |
Returns:
| Type | Description |
|---|---|
list of tuple or None
|
A list of LayerData tuples (data, add_kwargs, layer_type), or None if the Loading Parameters dialog was cancelled. |
initial_loading(lT, scaling=False)
¶
Compute the minimal data needed to display a LineageTree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lT
|
LineageTree
|
The LineageTree to load. |
required |
scaling
|
bool
|
If True, divide the positions by the largest distance between two cells, by default False. |
False
|
Returns:
| Type | Description |
|---|---|
namedtuple
|
|
graph_loading(lT, last_c_of_track, first_c_to_track, divisor)
¶
Build the lineage graphs displayed in the Lineage Viewer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lT
|
LineageTree
|
The LineageTree to draw. |
required |
last_c_of_track
|
dict
|
Last node of each chain, from |
required |
first_c_to_track
|
dict
|
Chain index of each first node, from |
required |
divisor
|
int
|
Filter value from the Loading Parameters dialog. Lineages with fewer than (number of timepoints / divisor) nodes are skipped; 0 keeps every lineage. |
required |
Returns:
| Type | Description |
|---|---|
tuple of dict
|
The graph of each lineage, the node positions of each graph, and the chain connectivity used to build a Tracks layer. |
layer_preparation(lT, points_layer_name, no_graph=False, parameters=None)
¶
Prepare the napari layers for a LineageTree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lT
|
LineageTree
|
The LineageTree to display. |
required |
points_layer_name
|
str or Path
|
Name of the Points layer. If it is an existing file path, its stem is used. |
required |
no_graph
|
bool
|
If True, skip building the Lineage Viewer graphs, by default False. |
False
|
parameters
|
dict
|
Loading parameters: |
None
|
Returns:
| Type | Description |
|---|---|
list of tuple
|
LayerData tuples: one Points layer, plus one Surface layer if the LineageTree has meshes. |
napari_relax._writer
¶
napari writer saving a LineageTree as a .lT file.
write_single_image(path, data, meta)
¶
Save the LineageTree of a layer as a .lT file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str
|
Destination path. |
required |
data
|
Any
|
Layer data, unused. |
required |
meta
|
dict
|
Layer attributes; the LineageTree is read from its metadata or from the metadata of the linked layer. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
The path that was written. |