fusion-tools 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- fusion_tools-0.0.1/LICENSE +201 -0
- fusion_tools-0.0.1/PKG-INFO +19 -0
- fusion_tools-0.0.1/README.md +2 -0
- fusion_tools-0.0.1/fusion_tools.egg-info/PKG-INFO +19 -0
- fusion_tools-0.0.1/fusion_tools.egg-info/SOURCES.txt +17 -0
- fusion_tools-0.0.1/fusion_tools.egg-info/dependency_links.txt +1 -0
- fusion_tools-0.0.1/fusion_tools.egg-info/requires.txt +1 -0
- fusion_tools-0.0.1/fusion_tools.egg-info/top_level.txt +1 -0
- fusion_tools-0.0.1/pyproject.toml +12 -0
- fusion_tools-0.0.1/setup.cfg +4 -0
- fusion_tools-0.0.1/setup.py +36 -0
- fusion_tools-0.0.1/src/__init__.py +0 -0
- fusion_tools-0.0.1/src/fusion_tools/__init__.py +0 -0
- fusion_tools-0.0.1/src/fusion_tools/access.py +118 -0
- fusion_tools-0.0.1/src/fusion_tools/handler.py +96 -0
- fusion_tools-0.0.1/src/fusion_tools/utils.py +88 -0
- fusion_tools-0.0.1/src/fusion_tools/visualization.py +327 -0
- fusion_tools-0.0.1/tests/test_feature_visualization.py +44 -0
- fusion_tools-0.0.1/tests/test_tile_server.py +36 -0
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fusion-tools
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Utility functions for generating, saving, and converting annotation files
|
|
5
|
+
Home-page: https://github.com/spborder/fusion-tools
|
|
6
|
+
Author: Sam Border
|
|
7
|
+
Author-email: sam.border2256@gmail.com
|
|
8
|
+
Project-URL: Homepage, https://github.com/spborder/fusion-tools
|
|
9
|
+
Project-URL: Issues, https://github.com/spborder/fusion-tools/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: dynamic
|
|
17
|
+
|
|
18
|
+
# fusion-tools
|
|
19
|
+
Some utilities, accession, and visualization tools for data derived from FUSION (Functional Unit State Identification in WSIs).
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: fusion-tools
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Utility functions for generating, saving, and converting annotation files
|
|
5
|
+
Home-page: https://github.com/spborder/fusion-tools
|
|
6
|
+
Author: Sam Border
|
|
7
|
+
Author-email: sam.border2256@gmail.com
|
|
8
|
+
Project-URL: Homepage, https://github.com/spborder/fusion-tools
|
|
9
|
+
Project-URL: Issues, https://github.com/spborder/fusion-tools/issues
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: dynamic
|
|
17
|
+
|
|
18
|
+
# fusion-tools
|
|
19
|
+
Some utilities, accession, and visualization tools for data derived from FUSION (Functional Unit State Identification in WSIs).
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.md
|
|
3
|
+
pyproject.toml
|
|
4
|
+
setup.py
|
|
5
|
+
fusion_tools.egg-info/PKG-INFO
|
|
6
|
+
fusion_tools.egg-info/SOURCES.txt
|
|
7
|
+
fusion_tools.egg-info/dependency_links.txt
|
|
8
|
+
fusion_tools.egg-info/requires.txt
|
|
9
|
+
fusion_tools.egg-info/top_level.txt
|
|
10
|
+
src/__init__.py
|
|
11
|
+
src/fusion_tools/__init__.py
|
|
12
|
+
src/fusion_tools/access.py
|
|
13
|
+
src/fusion_tools/handler.py
|
|
14
|
+
src/fusion_tools/utils.py
|
|
15
|
+
src/fusion_tools/visualization.py
|
|
16
|
+
tests/test_feature_visualization.py
|
|
17
|
+
tests/test_tile_server.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
dynamic
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
src
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "fusion-tools"
|
|
3
|
+
dynamic = ["version","authors","readme","description","classifiers"]
|
|
4
|
+
dependencies = ["dynamic"]
|
|
5
|
+
|
|
6
|
+
[build-system]
|
|
7
|
+
requires = ["setuptools>=61.0"]
|
|
8
|
+
build-backend = "setuptools.build_meta"
|
|
9
|
+
|
|
10
|
+
[project.urls]
|
|
11
|
+
Homepage = "https://github.com/spborder/fusion-tools"
|
|
12
|
+
Issues = "https://github.com/spborder/fusion-tools/issues"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import setuptools
|
|
2
|
+
|
|
3
|
+
with open("README.md", "r") as fh:
|
|
4
|
+
long_description = fh.read()
|
|
5
|
+
|
|
6
|
+
setuptools.setup(
|
|
7
|
+
name="fusion-tools",
|
|
8
|
+
version="0.0.1",
|
|
9
|
+
author="Sam Border",
|
|
10
|
+
author_email="sam.border2256@gmail.com",
|
|
11
|
+
description="Utility functions for generating, saving, and converting annotation files",
|
|
12
|
+
long_description=long_description,
|
|
13
|
+
long_description_content_type="text/markdown",
|
|
14
|
+
url="https://github.com/spborder/fusion-tools",
|
|
15
|
+
install_requires=[
|
|
16
|
+
"lxml>=4.9.2",
|
|
17
|
+
"geojson>=3.0.1",
|
|
18
|
+
"shapely>=2.0.1",
|
|
19
|
+
"tqdm",
|
|
20
|
+
"numpy>=1.20.0",
|
|
21
|
+
"large-image[common]",
|
|
22
|
+
"wsi-annotations-kit",
|
|
23
|
+
"uuid",
|
|
24
|
+
"scikit-image",
|
|
25
|
+
"fastapi",
|
|
26
|
+
"uvicorn",
|
|
27
|
+
"threading"
|
|
28
|
+
],
|
|
29
|
+
packages=setuptools.find_packages(),
|
|
30
|
+
classifiers=[
|
|
31
|
+
"Development Status :: 4 - Beta",
|
|
32
|
+
"Programming Language :: Python :: 3",
|
|
33
|
+
"License :: OSI Approved :: Apache Software License",
|
|
34
|
+
"Operating System :: OS Independent",
|
|
35
|
+
],
|
|
36
|
+
)
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Functions related to access of data derived from FUSION
|
|
3
|
+
|
|
4
|
+
- Query available data in FUSION instance
|
|
5
|
+
- Count of slides, names of annotations, annotation names per slide, slide metadata
|
|
6
|
+
- Extract
|
|
7
|
+
- annotations (various formats, regions, full), images (regions, full, thumbnails), files
|
|
8
|
+
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
import sys
|
|
13
|
+
import json
|
|
14
|
+
import requests
|
|
15
|
+
|
|
16
|
+
import girder_client
|
|
17
|
+
|
|
18
|
+
import pandas as pd
|
|
19
|
+
import anndata as ad
|
|
20
|
+
import geojson
|
|
21
|
+
|
|
22
|
+
import geopandas as gpd
|
|
23
|
+
|
|
24
|
+
from typing_extensions import Union
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Accessor:
|
|
28
|
+
def __init__(self,
|
|
29
|
+
fusion_handler):
|
|
30
|
+
|
|
31
|
+
self.fusion_handler = fusion_handler
|
|
32
|
+
|
|
33
|
+
def query_annotation_count(self, item:Union[str,list]) -> dict:
|
|
34
|
+
"""
|
|
35
|
+
Get count of annotations for a given item
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
if type(item)==str:
|
|
39
|
+
item = [item]
|
|
40
|
+
|
|
41
|
+
ann_counts = []
|
|
42
|
+
for it in item:
|
|
43
|
+
item_dict = {}
|
|
44
|
+
if '/' in it:
|
|
45
|
+
item_info = self.get_path_info(it)
|
|
46
|
+
else:
|
|
47
|
+
item_info = self.fusion_handler.gc.get(f'/item/{it}')
|
|
48
|
+
|
|
49
|
+
item_dict['name'] = item_info['name']
|
|
50
|
+
item_dict['id'] = item_info['_id']
|
|
51
|
+
item_anns = self.fusion_handler.gc.get(f'/annotation',parameters={'itemId':it})
|
|
52
|
+
|
|
53
|
+
if len(item_anns)>0:
|
|
54
|
+
for ann in item_anns:
|
|
55
|
+
# Only grabbing centroids to make it a little more lightweight
|
|
56
|
+
ann_centroids = self.fusion_handler.gc.get(f'/annotation/{ann["_id"]}',parameters={'centroids': True})
|
|
57
|
+
ann_count = len(ann_centroids['annotation']['elements'])
|
|
58
|
+
|
|
59
|
+
item_dict[ann['annotation']['name']] = ann_count
|
|
60
|
+
|
|
61
|
+
ann_counts.append(item_dict)
|
|
62
|
+
|
|
63
|
+
ann_counts_df = pd.DataFrame.from_records(ann_counts).fillna(0)
|
|
64
|
+
|
|
65
|
+
return ann_counts_df
|
|
66
|
+
|
|
67
|
+
def get_path_info(self, item_path: str) -> dict:
|
|
68
|
+
"""
|
|
69
|
+
Get item information from path
|
|
70
|
+
"""
|
|
71
|
+
|
|
72
|
+
# First searching for the "resource"
|
|
73
|
+
assert any([i in item_path for i in ['collection','user']])
|
|
74
|
+
|
|
75
|
+
resource_find = self.fusion_handler.gc.get('/resource/lookup',parameters={'path': item_path})
|
|
76
|
+
|
|
77
|
+
return resource_find
|
|
78
|
+
|
|
79
|
+
def get_folder_slide_count(self, folder_path: str, ignore_histoqc = True) -> list:
|
|
80
|
+
"""
|
|
81
|
+
Get number of slide items in a folder
|
|
82
|
+
"""
|
|
83
|
+
|
|
84
|
+
if '/' in folder_path:
|
|
85
|
+
folder_info = self.get_path_info(folder_path)
|
|
86
|
+
else:
|
|
87
|
+
folder_info = self.fusion_handler.gc.get(f'/folder/{folder_path}')
|
|
88
|
+
|
|
89
|
+
folder_items = self.fusion_handler.gc.get(f'/resource/{folder_info["_id"]}',
|
|
90
|
+
parameters = {
|
|
91
|
+
'type': folder_info["type"],
|
|
92
|
+
'limit': 0
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
if len(folder_items)>0:
|
|
96
|
+
if ignore_histoqc:
|
|
97
|
+
folders_in_folder = list(set([i['folderId'] for i in folder_items]))
|
|
98
|
+
folder_names = [
|
|
99
|
+
self.fusion_handler.gc.get(f'/folder/{i}')['name']
|
|
100
|
+
for i in folders_in_folder
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
if 'histoqc_outputs' not in folder_names:
|
|
104
|
+
ignore_folders = []
|
|
105
|
+
else:
|
|
106
|
+
ignore_folders = [folders_in_folder[i] for i in range(len(folder_names)) if folder_names[i]=='histoqc_outputs']
|
|
107
|
+
|
|
108
|
+
else:
|
|
109
|
+
ignore_folders = []
|
|
110
|
+
|
|
111
|
+
folder_image_items = [i for i in folder_items if 'largeImage' in i and not i['folderId'] in ignore_folders]
|
|
112
|
+
|
|
113
|
+
else:
|
|
114
|
+
folder_image_items = []
|
|
115
|
+
|
|
116
|
+
return folder_image_items
|
|
117
|
+
|
|
118
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Handler for requests made to a running FUSION instance.
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
import girder_client
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
import json
|
|
13
|
+
import numpy as np
|
|
14
|
+
|
|
15
|
+
from typing_extensions import Union
|
|
16
|
+
|
|
17
|
+
from skimage.draw import polygon
|
|
18
|
+
from PIL import Image
|
|
19
|
+
from io import BytesIO
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class FUSIONHandler:
|
|
23
|
+
def __init__(self,
|
|
24
|
+
girderApiUrl: str,
|
|
25
|
+
username: str,
|
|
26
|
+
password: str):
|
|
27
|
+
|
|
28
|
+
self.girderApiUrl = girderApiUrl
|
|
29
|
+
self.username = username
|
|
30
|
+
self.password = password
|
|
31
|
+
|
|
32
|
+
self.gc = girder_client.GirderClient(apiUrl=self.girderApiUrl)
|
|
33
|
+
self.gc.authenticate(
|
|
34
|
+
username = self.username,
|
|
35
|
+
password=self.password
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
# Token used for authenticating requests
|
|
39
|
+
self.user_token = self.gc.get(f'/token/session')['token']
|
|
40
|
+
|
|
41
|
+
def get_image_region(self, item_id: str, coords_list: list, style: Union[dict,None] = None)->np.ndarray:
|
|
42
|
+
"""
|
|
43
|
+
Grabbing image region from list of bounding box coordinates
|
|
44
|
+
"""
|
|
45
|
+
|
|
46
|
+
image_array = np.zeros((256,256))
|
|
47
|
+
|
|
48
|
+
if style is None:
|
|
49
|
+
image_array = np.uint8(
|
|
50
|
+
np.array(
|
|
51
|
+
Image.open(
|
|
52
|
+
BytesIO(
|
|
53
|
+
requests.get(
|
|
54
|
+
self.gc.urlBase+f'/item/{item_id}/tiles/region?token={self.user_token}&left={coords_list[0]}&top={coords_list[1]}&right={coords_list[2]}&bottom={coords_list[3]}'
|
|
55
|
+
).content
|
|
56
|
+
)
|
|
57
|
+
)
|
|
58
|
+
)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
else:
|
|
62
|
+
print('Adding style parameters are in progress')
|
|
63
|
+
raise NotImplementedError
|
|
64
|
+
|
|
65
|
+
return image_array
|
|
66
|
+
|
|
67
|
+
def make_boundary_mask(self, exterior_coords: list) -> np.ndarray:
|
|
68
|
+
"""
|
|
69
|
+
Making a binary mask given a set of coordinates, scales coordinates to fit within bounding box.
|
|
70
|
+
|
|
71
|
+
Expects coordinates in x,y format
|
|
72
|
+
"""
|
|
73
|
+
x_coords = [i[0] for i in exterior_coords]
|
|
74
|
+
y_coords = [i[1] for i in exterior_coords]
|
|
75
|
+
|
|
76
|
+
min_x = min(x_coords)
|
|
77
|
+
max_x = max(x_coords)
|
|
78
|
+
min_y = min(y_coords)
|
|
79
|
+
max_y = max(y_coords)
|
|
80
|
+
|
|
81
|
+
scaled_coords = [[int(i[0]-min_x), int(i[1]-min_y)] for i in exterior_coords]
|
|
82
|
+
|
|
83
|
+
boundary_mask = np.zeros((int(max_y-min_y),int(max_x-min_x)))
|
|
84
|
+
|
|
85
|
+
row,col = polygon(
|
|
86
|
+
[i[1] for i in scaled_coords],
|
|
87
|
+
[i[0] for i in scaled_coords],
|
|
88
|
+
(int(max_y-min_y), int(max_x-min_x))
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
boundary_mask[row,col] = 1
|
|
92
|
+
|
|
93
|
+
return boundary_mask
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Utility functions for data derived from FUSION
|
|
3
|
+
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import os
|
|
7
|
+
import sys
|
|
8
|
+
|
|
9
|
+
import numpy as np
|
|
10
|
+
|
|
11
|
+
import geopandas as gpd
|
|
12
|
+
import pandas as pd
|
|
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
|
+
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Functions related to visualization for data derived from FUSION.
|
|
3
|
+
|
|
4
|
+
- Interactive feature charts
|
|
5
|
+
- View images at points
|
|
6
|
+
- Local slide viewers
|
|
7
|
+
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import large_image.exceptions
|
|
11
|
+
from fastapi import FastAPI, APIRouter, Response
|
|
12
|
+
|
|
13
|
+
import large_image
|
|
14
|
+
import pandas as pd
|
|
15
|
+
import dash_leaflet as dl
|
|
16
|
+
from dash import dcc, callback, ctx, ALL, exceptions
|
|
17
|
+
import dash_bootstrap_components as dbc
|
|
18
|
+
from dash_extensions.enrich import DashProxy, html, Input, Output, State
|
|
19
|
+
|
|
20
|
+
import plotly.express as px
|
|
21
|
+
import plotly.graph_objects as go
|
|
22
|
+
|
|
23
|
+
import numpy as np
|
|
24
|
+
|
|
25
|
+
from typing_extensions import Union
|
|
26
|
+
from PIL import Image
|
|
27
|
+
from io import BytesIO
|
|
28
|
+
import json
|
|
29
|
+
import uvicorn
|
|
30
|
+
import requests
|
|
31
|
+
|
|
32
|
+
class TileServer:
|
|
33
|
+
def __init__(self,
|
|
34
|
+
local_image_path: str
|
|
35
|
+
):
|
|
36
|
+
|
|
37
|
+
self.local_image_path = local_image_path
|
|
38
|
+
|
|
39
|
+
self.tile_source = large_image.open(self.local_image_path,encoding='PNG')
|
|
40
|
+
self.tile_metadata = self.tile_source.getMetadata()
|
|
41
|
+
|
|
42
|
+
self.router = APIRouter()
|
|
43
|
+
self.router.add_api_route('/',self.root,methods=["GET"])
|
|
44
|
+
self.router.add_api_route('/tiles/{z}/{x}/{y}',self.get_tile,methods=["GET"])
|
|
45
|
+
self.router.add_api_route('/metadata',self.get_metadata,methods=["GET"])
|
|
46
|
+
|
|
47
|
+
def root(self):
|
|
48
|
+
return {'message': "Oh yeah, now we're cooking"}
|
|
49
|
+
|
|
50
|
+
def get_tile(self,z:int, x:int, y:int):
|
|
51
|
+
try:
|
|
52
|
+
raw_tile = self.tile_source.getTile(
|
|
53
|
+
x = x,
|
|
54
|
+
y = y,
|
|
55
|
+
z = z
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
except large_image.exceptions.TileSourceXYZRangeError:
|
|
59
|
+
# This error appears for any negative tile coordinates
|
|
60
|
+
raw_tile = np.zeros((self.tile_metadata['tileHeight'],self.tile_metadata['tileWidth']),dtype=np.uint8).tobytes()
|
|
61
|
+
|
|
62
|
+
return Response(content = raw_tile, media_type='image/png')
|
|
63
|
+
|
|
64
|
+
def get_metadata(self):
|
|
65
|
+
large_image_metadata = self.tile_source.getMetadata()
|
|
66
|
+
return Response(content = json.dumps(large_image_metadata),media_type = 'application/json')
|
|
67
|
+
|
|
68
|
+
def start(self, port = 8050):
|
|
69
|
+
app = FastAPI()
|
|
70
|
+
app.include_router(self.router)
|
|
71
|
+
|
|
72
|
+
uvicorn.run(app,host='0.0.0.0',port=port)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class LocalSlideViewer:
|
|
76
|
+
def __init__(self,
|
|
77
|
+
tile_server_port: str,
|
|
78
|
+
app_port: str):
|
|
79
|
+
|
|
80
|
+
self.app_port = app_port
|
|
81
|
+
self.tile_server_port = tile_server_port
|
|
82
|
+
|
|
83
|
+
image_metadata = requests.get(
|
|
84
|
+
f'http://localhost:{self.tile_server_port}/metadata'
|
|
85
|
+
).json()
|
|
86
|
+
|
|
87
|
+
self.viewer_app = DashProxy(__name__)
|
|
88
|
+
self.viewer_app.layout = self.gen_layout(
|
|
89
|
+
tile_size = image_metadata['tileWidth'],
|
|
90
|
+
zoom_levels = image_metadata['levels'],
|
|
91
|
+
tile_server_port = self.tile_server_port
|
|
92
|
+
)
|
|
93
|
+
self.viewer_app.title = 'FUSION'
|
|
94
|
+
|
|
95
|
+
# Add callback functions here
|
|
96
|
+
self.get_callbacks()
|
|
97
|
+
|
|
98
|
+
# Running using default Flask server
|
|
99
|
+
self.viewer_app.run(
|
|
100
|
+
host = '0.0.0.0',
|
|
101
|
+
port = self.app_port,
|
|
102
|
+
debug = False
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
def gen_layout(self, tile_size:int, zoom_levels: int, tile_server_port:str):
|
|
106
|
+
"""
|
|
107
|
+
Generate simple slide viewer layout
|
|
108
|
+
"""
|
|
109
|
+
layout = html.Div(
|
|
110
|
+
dbc.Container(
|
|
111
|
+
id = 'container',
|
|
112
|
+
fluid = True,
|
|
113
|
+
children = [
|
|
114
|
+
dbc.Row(
|
|
115
|
+
html.Div(
|
|
116
|
+
dl.Map(
|
|
117
|
+
id = 'slide-map',
|
|
118
|
+
crs = 'Simple',
|
|
119
|
+
center = [120,-120],
|
|
120
|
+
zoom = 0,
|
|
121
|
+
style = {'height': '100vh','width': '100vw','margin': 'auto','display': 'inline-block'},
|
|
122
|
+
children = [
|
|
123
|
+
dl.TileLayer(
|
|
124
|
+
id = 'slide-tile-layer',
|
|
125
|
+
url = f'http://localhost:{tile_server_port}/tiles'+'/{z}/{x}/{y}',
|
|
126
|
+
tileSize=tile_size,
|
|
127
|
+
maxNativeZoom=zoom_levels-1,
|
|
128
|
+
minZoom = 0,
|
|
129
|
+
#bounds = [[0,0],[tile_size,-tile_size]]
|
|
130
|
+
),
|
|
131
|
+
dl.FullScreenControl(
|
|
132
|
+
position = 'upper-left'
|
|
133
|
+
),
|
|
134
|
+
dl.LayersControl(
|
|
135
|
+
id = 'slid-layers-control',
|
|
136
|
+
children = []
|
|
137
|
+
)
|
|
138
|
+
]
|
|
139
|
+
)
|
|
140
|
+
)
|
|
141
|
+
)
|
|
142
|
+
]
|
|
143
|
+
)
|
|
144
|
+
)
|
|
145
|
+
|
|
146
|
+
return layout
|
|
147
|
+
|
|
148
|
+
def get_callbacks(self):
|
|
149
|
+
# Add callbacks to self.viewer_app
|
|
150
|
+
# Maybe add something so users can point the app to some zarr storage or add polygons either through uploads or on initialization
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
pass
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
class FeatureViewer:
|
|
157
|
+
def __init__(self,
|
|
158
|
+
feature_df: pd.DataFrame,
|
|
159
|
+
item_id: str,
|
|
160
|
+
ann_name: str,
|
|
161
|
+
mode: str,
|
|
162
|
+
mode_col: Union[str,list],
|
|
163
|
+
fusion_handler,
|
|
164
|
+
viewer_title = 'Feature Viewer'
|
|
165
|
+
):
|
|
166
|
+
|
|
167
|
+
self.feature_df = feature_df
|
|
168
|
+
self.viewer_title = viewer_title
|
|
169
|
+
self.item_id = item_id
|
|
170
|
+
self.mode = mode
|
|
171
|
+
self.mode_col = mode_col
|
|
172
|
+
self.ann_name = ann_name
|
|
173
|
+
|
|
174
|
+
assert mode in ['bbox','index','column_index','element_id']
|
|
175
|
+
|
|
176
|
+
if self.mode=='bbox' and not type(self.mode_col)==list:
|
|
177
|
+
print('If using "bbox" mode, provide a list of column names containing bounding box coordinates in minx, miny, maxx, maxy format.')
|
|
178
|
+
raise TypeError
|
|
179
|
+
elif not self.mode=='bbox' and type(self.mode_col)==list:
|
|
180
|
+
print('Provide a single column name (type: str) to identify samples in the target slide.')
|
|
181
|
+
raise TypeError
|
|
182
|
+
|
|
183
|
+
self.fusion_handler = fusion_handler
|
|
184
|
+
|
|
185
|
+
self.feature_viewer = DashProxy(
|
|
186
|
+
__name__
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
self.feature_viewer.title = self.viewer_title
|
|
190
|
+
self.feature_viewer.layout = self.get_layout()
|
|
191
|
+
self.get_callbacks()
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def get_callbacks(self):
|
|
195
|
+
"""
|
|
196
|
+
Put all callbacks in here
|
|
197
|
+
"""
|
|
198
|
+
# First callback is selecting features to view and plotting them when "Plot" button is pressed
|
|
199
|
+
self.feature_viewer.callback(
|
|
200
|
+
[
|
|
201
|
+
Output('feature-graph','figure'),
|
|
202
|
+
Output('image-graph','figure')
|
|
203
|
+
],
|
|
204
|
+
[
|
|
205
|
+
Input('feature-drop','value'),
|
|
206
|
+
Input('label-drop','value')
|
|
207
|
+
],
|
|
208
|
+
prevent_initial_call = True
|
|
209
|
+
)(self.update_plot)
|
|
210
|
+
|
|
211
|
+
# Second callback is grabbing images associated with selected points
|
|
212
|
+
self.feature_viewer.callback(
|
|
213
|
+
[
|
|
214
|
+
Output('image-graph','figure')
|
|
215
|
+
],
|
|
216
|
+
[
|
|
217
|
+
Input('feature-graph','selectedData')
|
|
218
|
+
],
|
|
219
|
+
prevent_initial_call = True
|
|
220
|
+
)(self.graph_image)
|
|
221
|
+
|
|
222
|
+
def get_layout(self):
|
|
223
|
+
"""
|
|
224
|
+
Assembling a layout based on the provided feature dataframe
|
|
225
|
+
"""
|
|
226
|
+
|
|
227
|
+
main_layout = html.Div([
|
|
228
|
+
dbc.Container(
|
|
229
|
+
id = 'feature-viewer-container',
|
|
230
|
+
fluid = True,
|
|
231
|
+
children = [
|
|
232
|
+
html.H1(self.viewer_title),
|
|
233
|
+
dbc.Row([
|
|
234
|
+
dbc.Col([
|
|
235
|
+
dbc.Row([
|
|
236
|
+
dbc.Col(
|
|
237
|
+
dbc.Label('Select feature(s) for plotting:',html_for='feature-drop'),
|
|
238
|
+
md = 3
|
|
239
|
+
),
|
|
240
|
+
dbc.Col(
|
|
241
|
+
dcc.Dropdown(
|
|
242
|
+
options = [
|
|
243
|
+
{'label': i, 'value': i, 'disabled': False}
|
|
244
|
+
if not i in self.mode_col else
|
|
245
|
+
{'label': i, 'value': i, 'disabled': True}
|
|
246
|
+
for i in self.feature_df.columns.tolist()
|
|
247
|
+
],
|
|
248
|
+
value = [],
|
|
249
|
+
multi = True,
|
|
250
|
+
id = 'feature-drop'
|
|
251
|
+
),
|
|
252
|
+
md = 9
|
|
253
|
+
)
|
|
254
|
+
]),
|
|
255
|
+
dbc.Row([
|
|
256
|
+
dbc.Col(
|
|
257
|
+
dbc.Label('(Optional) Select a label for the plot:',html_for='label-drop'),
|
|
258
|
+
md = 3
|
|
259
|
+
),
|
|
260
|
+
dbc.Col(
|
|
261
|
+
dcc.Dropdown(
|
|
262
|
+
options = [
|
|
263
|
+
{'label': i,'value': i,'disabled': False}
|
|
264
|
+
if not i in self.mode_col else
|
|
265
|
+
{'label': i, 'value': i, 'disabled': True}
|
|
266
|
+
for i in self.feature_df.columns.tolist()
|
|
267
|
+
],
|
|
268
|
+
value = [],
|
|
269
|
+
multi = False,
|
|
270
|
+
id = 'label-drop'
|
|
271
|
+
)
|
|
272
|
+
)
|
|
273
|
+
]),
|
|
274
|
+
dbc.Row([
|
|
275
|
+
dcc.Graph(
|
|
276
|
+
id = 'feature-graph',
|
|
277
|
+
figure = go.Figure()
|
|
278
|
+
)
|
|
279
|
+
])
|
|
280
|
+
], md = 6),
|
|
281
|
+
dbc.Col([
|
|
282
|
+
dbc.Row(
|
|
283
|
+
html.H3('Select points to see the image at that point')
|
|
284
|
+
),
|
|
285
|
+
dbc.Row(
|
|
286
|
+
dcc.Graph(
|
|
287
|
+
id = 'image-graph',
|
|
288
|
+
figure = go.Figure()
|
|
289
|
+
)
|
|
290
|
+
)
|
|
291
|
+
])
|
|
292
|
+
])
|
|
293
|
+
]
|
|
294
|
+
)
|
|
295
|
+
])
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
return main_layout
|
|
299
|
+
|
|
300
|
+
def update_plot(self, features_selected, labels_selected, plot_button):
|
|
301
|
+
"""
|
|
302
|
+
Plotting selected data with label
|
|
303
|
+
"""
|
|
304
|
+
|
|
305
|
+
print(ctx.triggered)
|
|
306
|
+
|
|
307
|
+
if not ctx.triggered:
|
|
308
|
+
raise exceptions.PreventUpdate
|
|
309
|
+
|
|
310
|
+
return_plot = go.Figure()
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
return return_plot
|
|
315
|
+
|
|
316
|
+
def grab_image(self, selected_points):
|
|
317
|
+
"""
|
|
318
|
+
Grabbing image region based on selected points
|
|
319
|
+
"""
|
|
320
|
+
|
|
321
|
+
return_image = go.Figure()
|
|
322
|
+
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
return return_image
|
|
326
|
+
|
|
327
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Testing visualization functionality
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
|
|
10
|
+
import pandas as pd
|
|
11
|
+
|
|
12
|
+
from src.fusion_tools.handler import FUSIONHandler
|
|
13
|
+
from src.fusion_tools.visualization import FeatureViewer
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main():
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
feature_path = ''
|
|
20
|
+
feature_df = pd.read_csv(feature_path)
|
|
21
|
+
|
|
22
|
+
fusion_handler = FUSIONHandler(
|
|
23
|
+
girderApiUrl = os.environ.get('DSA_URL'),
|
|
24
|
+
username = os.environ.get('DSA_USER'),
|
|
25
|
+
password = os.environ.get('DSA_PWORD')
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
feature_viewer = FeatureViewer(
|
|
29
|
+
feature_df = feature_df,
|
|
30
|
+
item_id = '',
|
|
31
|
+
mode = '',
|
|
32
|
+
mode_col = '',
|
|
33
|
+
fusion_handler=fusion_handler,
|
|
34
|
+
viewer_title = 'Test Feature Viewer'
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if __name__=='__main__':
|
|
42
|
+
main()
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"""
|
|
2
|
+
|
|
3
|
+
Testing tile server with local tile source
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
sys.path.append('./src/')
|
|
10
|
+
from fusion_tools.visualization import TileServer, LocalSlideViewer
|
|
11
|
+
import threading
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def main():
|
|
15
|
+
|
|
16
|
+
path_to_slide = 'C:\\Users\\samuelborder\\Desktop\\HIVE_Stuff\\FUSION\\Test Upload\\XY01_IU-21-015F.svs'
|
|
17
|
+
|
|
18
|
+
tile_server = TileServer(
|
|
19
|
+
local_image_path = path_to_slide
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
#TODO: Should this be included in the tile_server.start method?
|
|
23
|
+
new_thread = threading.Thread(target = tile_server.start, name = 'local_tile_server', args = ['8050'])
|
|
24
|
+
new_thread.daemon = True
|
|
25
|
+
new_thread.start()
|
|
26
|
+
|
|
27
|
+
slide_viewer = LocalSlideViewer(
|
|
28
|
+
tile_server_port='8050',
|
|
29
|
+
app_port = '8080'
|
|
30
|
+
)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
if __name__=='__main__':
|
|
34
|
+
main()
|
|
35
|
+
|
|
36
|
+
|