Skip to content

Commit b47b4b2

Browse files
Minor improvements
1 parent 9c9d5b5 commit b47b4b2

File tree

3 files changed

+18
-20
lines changed

3 files changed

+18
-20
lines changed

PySpatialAnalysis_StreamlitApp.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -101,19 +101,19 @@
101101

102102
with left_column:
103103

104-
st.slider('Threshold (σ) for Nuclei detection. Higher value detects lesser Nuclei.', min_value = 0.1, max_value = 0.9, value = 0.5, step = 0.1, format = '%0.1f', label_visibility = "visible", key = '-SensitivityKey-')
104+
st.slider('Threshold (σ) for Nuclei detection. Higher value detects lesser Nuclei.', min_value = 0.1, max_value = 0.9, value = 0.3, step = 0.1, format = '%0.1f', label_visibility = "visible", key = '-SensitivityKey-')
105105

106106
ModelSensitivity = round(float(st.session_state['-SensitivityKey-']), 2)
107107

108108
with middle_column:
109109

110-
st.number_input('Number of classes for Area, between 1 and 10.', key = '-n_clusters_area_key-', min_value = 1, max_value = 10, value = 3, step = 1, format = '%d')
110+
st.number_input('Number of classes for Area, between 1 and 10.', key = '-n_clusters_area_key-', min_value = 1, max_value = 10, value = 4, step = 1, format = '%d')
111111

112112
area_cluster_number = int(st.session_state['-n_clusters_area_key-'])
113113

114114
with right_column:
115115

116-
st.number_input('Number of classes for Roundness, between 1 and 10.', key = '-n_clusters_roundness_key-', min_value = 1, max_value = 10, value = 3, step = 1, format = '%d')
116+
st.number_input('Number of classes for Roundness, between 1 and 10.', key = '-n_clusters_roundness_key-', min_value = 1, max_value = 10, value = 4, step = 1, format = '%d')
117117

118118
roundness_cluster_number= int(st.session_state['-n_clusters_roundness_key-'])
119119

@@ -286,18 +286,16 @@
286286
# plt.close(result_figure)
287287

288288
##################################################################
289+
290+
# Call the make_graph function to get the graph and node labels
289291

290-
with st.spinner('Generating Nuclei connectivity graphs...'):
291-
292-
# Call the make_graph function to get the graph and node labels
293-
294-
distance_threshold = 50
295-
296-
graph, labels = make_weighted_network_connectivity_graph(labelled_image, distance_threshold)
297-
# graph, labels = make_network_connectivity_graph(labelled_image, distance_threshold)
292+
distance_threshold = 50
293+
294+
graph, labels = make_weighted_network_connectivity_graph(labelled_image, distance_threshold)
295+
# graph, labels = make_network_connectivity_graph(labelled_image, distance_threshold)
298296

299-
# Compute Voronoi tessellation of the labelled image
300-
vor = voronoi_tessellation(labelled_image)
297+
# Compute Voronoi tessellation of the labelled image
298+
vor = voronoi_tessellation(labelled_image)
301299

302300
##################################################################
303301

@@ -343,7 +341,7 @@
343341

344342
# Draw the graph
345343
pos = nx.get_node_attributes(graph, 'pos')
346-
nx.draw_networkx_nodes(graph, pos, node_color=[node_colors[label] for label in labels], node_size = 3, ax=ax)
344+
nx.draw_networkx_nodes(graph, pos, node_color=[node_colors[label] for label in labels], node_size = 2, ax = ax)
347345
nx.draw_networkx_edges(graph, pos, edge_color='gray', width = 0.2, ax=ax)
348346

349347
# Add the labels image with transparency

TestImage.jpeg

-126 KB
Loading

modules.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def perform_analysis(rgb_image, threshold_probability):
129129

130130
# number_of_tiles = model._guess_n_tiles(rgb_image)
131131

132-
labels, detailed_info = model.predict_instances(normalize(rgb_image), n_tiles = (10, 10, 1),prob_thresh = threshold_probability, nms_thresh = 0.3, show_tile_progress = False)
132+
labels, detailed_info = model.predict_instances(normalize(rgb_image), n_tiles = (10, 10, 1), prob_thresh = threshold_probability, nms_thresh = 0.3, show_tile_progress = False)
133133

134134
except:
135135

@@ -183,7 +183,7 @@ def colorize_labels(labels):
183183
from skimage.measure import regionprops
184184
from sklearn.neighbors import KernelDensity
185185

186-
def weighted_kde_density_map(nucleus_mask, bandwidth='auto', kernel='gaussian', num_points = 500):
186+
def weighted_kde_density_map(nucleus_mask, bandwidth = 'auto', kernel = 'gaussian', num_points = 1000):
187187
"""
188188
Compute the weighted kernel density estimate (KDE) of the centroids of regions in a binary image.
189189
@@ -564,7 +564,7 @@ def make_second_plot(perform_analysis_image, ModelSensitivity, modified_labels_r
564564

565565
# Display the density map figure
566566

567-
im_density = axs['c'].imshow(Local_Density_mean_filter, vmin = 0, vmax = 1, alpha=ALPHA, zorder = 2, cmap='cividis')
567+
im_density = axs['c'].imshow(Local_Density_mean_filter, vmin = 0, vmax = 1, alpha=ALPHA, zorder = 2, cmap='magma')
568568
# Add a colorbar
569569
divider = make_axes_locatable(axs['c'])
570570
cax = divider.append_axes("right", size=SIZE, pad=PAD)
@@ -584,7 +584,7 @@ def make_second_plot(perform_analysis_image, ModelSensitivity, modified_labels_r
584584

585585
# Display the density map figure
586586

587-
im_density = axs['d'].imshow(Local_Density_KDE, vmin = 0, vmax = 1, alpha=ALPHA, zorder = 2, cmap='cividis')
587+
im_density = axs['d'].imshow(Local_Density_KDE, vmin = 0, vmax = 1, alpha=ALPHA, zorder = 2, cmap='magma')
588588
# Add a colorbar
589589
divider = make_axes_locatable(axs['d'])
590590
cax = divider.append_axes("right", size=SIZE, pad=PAD)
@@ -604,7 +604,7 @@ def make_second_plot(perform_analysis_image, ModelSensitivity, modified_labels_r
604604

605605
# # Display the area clustered blob labels figure
606606

607-
im_area_cluster_labels = axs['e'].imshow(area_cluster_labels, alpha=ALPHA, cmap = 'brg')
607+
im_area_cluster_labels = axs['e'].imshow(area_cluster_labels, alpha=ALPHA, cmap = 'rainbow')
608608
# Add a colorbar
609609
divider = make_axes_locatable(axs['e'])
610610
cax = divider.append_axes("right", size=SIZE, pad=PAD)
@@ -626,7 +626,7 @@ def make_second_plot(perform_analysis_image, ModelSensitivity, modified_labels_r
626626

627627
# # Display the roundness clustered blob labels figure
628628

629-
im_roundness_cluster_labels = axs['f'].imshow(roundness_cluster_labels, alpha=ALPHA, cmap = 'brg')
629+
im_roundness_cluster_labels = axs['f'].imshow(roundness_cluster_labels, alpha=ALPHA, cmap = 'rainbow')
630630
# Add a colorbar
631631
divider = make_axes_locatable(axs['f'])
632632
cax = divider.append_axes("right", size=SIZE, pad=PAD)

0 commit comments

Comments
 (0)