pymaid.tiles.TileLoader¶
- class pymaid.tiles.TileLoader(bbox, stack_id, zoom_level=0, coords='NM', image_mirror='auto', mem_lim=4000, remote_instance=None, **fetch_kwargs)[source]¶
Load tiles from CATMAID, stitch into image and render output.
Important
Loading lots of tiles is memory intensive. A single 100x100 pixel image already requires 80Kb, 1000x1000 8Mb and so on.
- Parameters:
bbox (list | numpy.array) – Window to crop:
left, right, top, bottom, z1, [z2, stepsize]
. Can be single or list/array of bounding boxes.z2
can be omitted, in which casez2 = z1
. Optionally you can provide a 7thstepsize
parameter.stack_id (int) – ID of EM image stack to use.
zoom_level (int, optional) – Zoom level
coords ('NM' | 'PIXEL', optional) – Dimension of bbox.
image_mirror (int | str | 'auto', optional) –
Image mirror to use:
int
is interpreted as mirror IDstr
must be URL'auto'
will automatically pick fastest
mem_lim (int, optional) – Memory limit in megabytes for loading tiles. This restricts the number of tiles that can be simultaneously loaded into memory.
Examples
>>> # Generate the job >>> job = pymaid.tiles.TileLoader([119000, 124000, ... 36000, 42000, ... 4050], ... stack_id=5, ... coords='PIXEL') >>> # Load, stitch and crop the required EM image tiles >>> job.load_in_memory() >>> # Render image >>> ax = job.render_im(slider=False, figsize=(12, 12)) >>> # Add nodes >>> job.render_nodes(ax, nodes=True, connectors=False) >>> # Add scalebar >>> job.scalebar(size=1000, ax=ax, label=False) >>> # Show >>> plt.show()
Initialise class.
- __init__(bbox, stack_id, zoom_level=0, coords='NM', image_mirror='auto', mem_lim=4000, remote_instance=None, **fetch_kwargs)[source]¶
Initialise class.
Methods
__init__
(bbox, stack_id[, zoom_level, ...])Initialise class.
bboxes2imgcoords
()Convert bounding box(es) to coordinates for individual images.
estimate_memory
()Estimate memory [Mb] consumption of loading all tiles.
get_stack_info
([image_mirror])Retrieve basic info about image stack and mirrors.
load_and_save
(filepath[, filename])Download and stitch tiles, and save as images right away (memory efficient).
load_in_memory
()Download and stitch tiles, and keep images in memory.
render_im
([slider, ax])Draw image slices with a slider.
render_nodes
(ax[, nodes, connectors, ...])Render nodes onto image.
scalebar
(ax[, size, pos, label, line_kws, ...])Add scalebar to image.