[78ef36]: / docs / _sources / slidemap.rst.txt

Download this file

62 lines (49 with data), 2.7 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.. currentmodule:: slideflow
slideflow.SlideMap
==================
:class:`slideflow.SlideMap` assists with visualizing tiles and slides in two-dimensional space.
Once a model has been trained, tile-level predictions and intermediate layer activations can be calculated
across an entire dataset with :class:`slideflow.DatasetFeatures`.
The :class:`slideflow.SlideMap` class can then perform dimensionality reduction on these dataset-wide
activations, plotting tiles and slides in two-dimensional space. Visualizing the distribution and clustering
of tile-level and slide-level layer activations can help reveal underlying structures in the dataset and shared
visual features among classes.
The primary method of use is first generating an :class:`slideflow.DatasetFeatures` from a trained
model, then using :meth:`slideflow.DatasetFeatures.map_activations`, which returns an instance of
:class:`slideflow.SlideMap`.
.. code-block:: python
ftrs = sf.DatasetFeatures(model='/path/', ...)
slide_map = ftrs.map_activations()
Alternatively, if you would like to map slides from a dataset in two-dimensional space using pre-calculated *x* and *y*
coordinates, you can use the :meth:`sldieflow.SlideMap.from_xy` class method. In addition to X and Y, this method
requires supplying tile-level metadata in the form of a list of dicts. Each dict must contain the name of the origin
slide and the tile index in the slide TFRecord.
.. code-block:: python
x = np.array(...)
y = np.array(...)
slides = ['slide1', 'slide1', 'slide5', ...]
slide_map = sf.SlideMap.from_xy(x=x, y=y, slides=slides)
.. autoclass:: SlideMap
Methods
-------
.. autofunction:: slideflow.SlideMap.activations
.. autofunction:: slideflow.SlideMap.build_mosaic
.. autofunction:: slideflow.SlideMap.cluster
.. autofunction:: slideflow.SlideMap.neighbors
.. autofunction:: slideflow.SlideMap.filter
.. autofunction:: slideflow.SlideMap.umap_transform
.. autofunction:: slideflow.SlideMap.label
.. autofunction:: slideflow.SlideMap.label_by_preds
.. autofunction:: slideflow.SlideMap.label_by_slide
.. autofunction:: slideflow.SlideMap.label_by_uncertainty
.. autofunction:: slideflow.SlideMap.load
.. autofunction:: slideflow.SlideMap.load_coordinates
.. autofunction:: slideflow.SlideMap.load_umap
.. autofunction:: slideflow.SlideMap.plot
.. autofunction:: slideflow.SlideMap.plot_3d
.. autofunction:: slideflow.SlideMap.save
.. autofunction:: slideflow.SlideMap.save_3d
.. autofunction:: slideflow.SlideMap.save_plot
.. autofunction:: slideflow.SlideMap.save_coordinates
.. autofunction:: slideflow.SlideMap.save_umap
.. autofunction:: slideflow.SlideMap.save_encoder