Components Overview
Here you’ll find documentation for each of the individual components and an overview on their usage.
Map Components
These components control how a slide and associated annotations are viewed.
Slide Map
MultiFrame Slide Map
Overlay Options
Channel Mixer
Slide Image Overlay
Components used for high-resolution image viewing
- class fusion_tools.components.maps.ChannelMixer
Bases:
MapComponentChannelMixer component that allows users to select various frames from their image to overlay at the same time with different color (styles) applied.
- Parameters:
MapComponent (None) – General component class for children of SlideMap
- add_color_selector_tab(channel_mix_values: list | None, current_channels: list | None, current_colors: list | None)
Add a new color selector tab to channel-mixer-parent for selecting overlaid channel color
- Parameters:
channel_mix_values (list) – Selected list of channels to overlay
current_channels (list) – Current set of overlaid channels (names)
current_colors (list) – Current set of overlaid channels (colors)
- gen_layout(session_data: dict)
Generating layout for ChannelMixer component
- get_callbacks()
Initializing callbacks and adding to DashBlueprint
- load(component_prefix: int)
- process_frames(image_metadata: dict)
Extracting names for each frame for easy reference
- updat_layout(session_data: dict, use_prefix: bool)
Updating layout of ChannelMixer component
- Parameters:
session_data (dict) – Current data relating to visualization session
use_prefix (bool) – Whether or not this is the initial load of the component
- Returns:
ChannelMixer component
- update_channel_mix(butt_click: list, current_channels: list, current_colors: list, frame_names: list, slide_info: list)
Updating urls of all tile layers to include selected overlay channels
- Parameters:
butt_click (list) – Button clicked to update channel mix
current_channels (list) – Names of channels to overlay
current_colors (list) – Colors of channels to overlay
- update_slide(selected_slide, vis_data)
Updating component data when a new slide is selected
- Parameters:
selected_slide (list) – New slide
vis_data (str) – Data relating to current visualization session
- update_tab_style(color_select)
Updating color of tab label based on selection
- Parameters:
color_select (str) – “rgba” formatted color selection
- class fusion_tools.components.maps.MapComponent
Bases:
objectGeneral class for components added to SlideMap For more information see dash-leaflet: https://www.dash-leaflet.com/
- class fusion_tools.components.maps.MultiFrameSlideMap
Bases:
SlideMapMultiFrameSlideMap component, containing an image with multiple frames which are added as additional, selectable dl.TileLayer() components
- Parameters:
SlideMap (None) – dl.Map() container where image tiles are displayed.
- gen_layout(session_data: dict)
Generating layout for MultiFrameSlideMap
- load(component_prefix: int)
- process_frames(image_metadata, tiles_url)
Create BaseLayer and TileLayer components for each of the different frames present in a multi-frame image Also initializes base tile url and styled tile url
- update_layout(session_data: dict, use_prefix: bool)
Updating layout of MultiFramSlideMap component
- Parameters:
session_data (dict) – Data relating to current visualization session
use_prefix (bool) – Whether or not this is the initial loading of the component
- Returns:
Component layout
- class fusion_tools.components.maps.SlideImageOverlay(image_path: str, image_crs: list = [0, 0], image_properties: dict | None = {'None': ''})
Bases:
MapComponentImage overlay on specific coordinates within a SlideMap
- Parameters:
MapComponent (None) – General component class for children of SlideMap
- get_image_bounds()
Get total bounds of image overlay in original CRS (number of pixels)
- Returns:
List of image bounds in overlay CRS ([minx, miny, maxx, maxy])
- Return type:
list
- to_dict()
- class fusion_tools.components.maps.SlideMap
Bases:
MapComponentThis is a general high-resolution tiled image component.
- Parameters:
MapComponent (None) – General class for components added to SlideMap
- add_manual_roi(new_geojson: list, uploaded_shape: list, current_annotations: list, frame_layers: list, line_colors: list, colormap: list, separate_switch: list, summarize_switch: list) list
Adding a manual region of interest (ROI) to the SlideMap using dl.EditControl() tools including polygon, rectangle, and markers.
- Parameters:
new_geojson (list) – Incoming GeoJSON object that is emitted by dl.EditControl() following annotation on SlideMap
current_annotations (list) – Initial annotations added to the map on initialization
annotation_names (list) – Names for each annotation layer on the slide map
frame_layers (list) – Frame layers for multi-frame visualization
- Raises:
exceptions.PreventUpdate – new_geojson input is None
exceptions.PreventUpdate – No new features are added, this can occur after deletion of previous manual ROIs.
- Returns:
List of new children to dl.LayerControl() consisting of overlaid GeoJSON components.
- Return type:
list
- download_manual_roi(button_click, current_manual_geojson, slide_information)
- export_image_overlay_bounds(button_click, current_position, slide_information)
Exporting position of image overlay
- Parameters:
button_click (int) – Export button clicked
current_position (list) – Current position of the image overlay
- Raises:
exceptions.PreventUpdate – Preventing callback if button isn’t clicked
- Returns:
JSON file containing original image path and current position on the slide
- Return type:
dict
- gen_image_mover(button_click, current_bounds, button_text)
Creates a draggable Marker to facilitate moving an image overlay around
- Parameters:
button_click (dict) – Position button is clicked
current_bounds (list) – Current bounds of the image overlay, used for setting initial position of mover Marker
button_text (str) – Text displayed on position button.
- Raises:
exceptions.PreventUpdate – Prevent update if button is not pressed.
- Returns:
New text for the position button and mover Marker
- Return type:
tuple
- gen_layout(session_data: dict)
- get_callbacks()
Initializing callback functions for interactive components in SlideMap. Adding these callbacks to the DashBlueprint() object enable embedding into other layouts.
- get_click_popup(clicked)
Populating popup Div with summary information on the clicked GeoJSON feature
- Parameters:
clicked (dl.GeoJSON.GeoJSON) – GeoJSON feature on SlideMap that was selected
- Raises:
exceptions.PreventUpdate – Stops callback execution
- Returns:
Popup with summary information on clicked GeoJSON. Nested properties (in dictionaries) appear as collapsible dbc.AccordionItem() with their own dash_table.DataTable
- Return type:
dash.html.Div.Div
- get_image_overlay_popup(st, st_idx)
Getting popup components for image overlay annotations
- Parameters:
st (SlideImageOverlay) – New ImageOverlay annotation
st_idx (int) – Index to use for interactive components
- get_namespace()
Adding JavaScript functions to the SlideMap Namespace
These functions are automatically written to .fusion_assets/fusionTools_default.js where they are accessible to select interactive components in SlideMap.
For more information on adding JS functions to a Dash application, see:
https://www.dash-extensions.com/sections/javascript and https://www.dash-leaflet.com/docs/geojson_tutorial
- get_scale_factors(image_metadata: dict)
Function used to initialize scaling factors applied to GeoJSON annotations to project annotations into the SlideMap CRS (coordinate reference system)
- Returns:
x and y (horizontal and vertical) scale factors applied to each coordinate in incoming annotations
- Return type:
float
- load(component_prefix: int)
- make_geojson_layers(geojson_list: list, names_list: list, index_list: list, line_color: list, colormap: str) list
Creates new dl.Overlay() dl.GeoJSON components from list of GeoJSON FeatureCollection objects
- Parameters:
geojson_list (list) – List of GeoJSON FeatureCollection objects
names_list (list) – List of names for each layer
index_list (list) – List of indices to apply to each component
- Returns:
Overlay components on SlideMap.
- Return type:
list
- move_image_overlay(new_position, old_bounds)
Move image overlay to location of mover Marker
- Parameters:
new_position (dict) – New top-left position of image overlay (keys: lat, lng)
old_bounds (list) – Old bounds of the image, used for determining bottom-right coordinates
- Raises:
exceptions.PreventUpdate – Prevents callback execution until a position is set
- Returns:
New bounds for image overlay component
- Return type:
list
- update_image_overlay_transparency(new_opacity: float)
Update transparency of image overlay component
- Parameters:
new_opacity (float) – New opacity level (0-1 (0.1 increments)) from slider
- Returns:
New opacity level
- Return type:
float
- update_layout(session_data: dict, use_prefix: bool)
Generating SlideMap layout
- Returns:
Div object containing interactive components for the SlideMap object.
- Return type:
dash.html.Div.Div
- update_slide(slide_selected, vis_data)
- update_vis_session(new_vis_data)
Updating slide dropdown options based on current visualization session
- Parameters:
new_vis_data (str) – Visualization session data containing information on selectable slides
- Returns:
New options for slide dropdown
- Return type:
list
- upload_shape(upload_clicked, is_open)
Plotting Components
Visualization tools which can be linked to SlideMap components (but don’t have to be)
- class fusion_tools.components.tools.GlobalPropertyPlotter(ignore_list: list = [], property_depth: int = 6, preloaded_properties: DataFrame | None = None, structure_column: str | None = None, slide_column: str | None = None, bbox_columns: list | str | None = None, nested_prop_sep: str = ' --> ')
Bases:
MultiTool- extract_all_properties(session_data)
- extract_property_info()
- gen_layout(session_data: dict)
- gen_scatter_plot(data_df: DataFrame, plot_cols: list, label_col: str | None, customdata_cols: list)
Generating a 2D scatter plot using provided data
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
plot_cols (list) – Names of columns containing properties for the scatter plot
label_cols (Union[str,None]) – Name of column to use to label markers.
customdata_cols (list) – Names of columns to use for customdata on plot
- Returns:
Scatter plot figure
- Return type:
go.Figure
- gen_umap_cols(data_df: DataFrame, property_columns: list) DataFrame
Scale and run UMAP for dimensionality reduction
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
property_columns (list) – Names of columns containing properties for UMAP plot
- Returns:
Dataframe containing colunns named UMAP1 and UMAP2
- Return type:
pd.DataFrame
- gen_violin_plot(data_df: DataFrame, label_col: str | None, property_column: str, customdata_columns: list)
Generating a violin plot using provided data, property columns, and customdata
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
label_col (Union[str,None]) – Name of column to use for label
property_column (str) – Name of column to use for property (y-axis) value
customdata_columns (list) – Names of columns to use for customdata (accessible from clickData and selectedData)
- Returns:
Figure containing violin plot data
- Return type:
go.Figure
- generate_plot(butt_click, current_data)
Generate a new plot based on selected properties
- Parameters:
butt_click (list) – Generate Plot button clicked
current_data (list) – Dictionary containing current selected properties (in a list)
- generate_property_dict(available_properties, title: str = 'Properties')
- get_callbacks()
- load(component_prefix: int)
- parse_filter_divs(add_property_parent: list) list
Processing parent div object and extracting name and range for each property filter.
- Parameters:
add_property_parent (list) – Parent div containing property filters
- Returns:
List of property filters (dicts with keys: name and range)
- Return type:
list
- select_data_from_plot(selected_data, session_data)
Select point(s) from the plot and extract the image from that/those point(s)
- Parameters:
selected_data (list) – Multiple points selected using either a box or lasso select
session_data (list) – Data for each slide in the current session
- update_drop_type(switch_switched)
Update the property selection mode (either dropdown menu or tree view)
- Parameters:
switch_switched (list) – Switch selected
- Returns:
New property selector component
- Return type:
list
- update_filter_properties(add_click: list, remove_click: list, property_info: list)
Adding/removing property filter dropdown
- Parameters:
add_click (list) – Add property filter clicked
remove_click (list) – Remove property filter clicked
- Returns:
Property filter dropdown and parent div of range selector
- Return type:
tuple
- update_properties_and_filters(property_selection, property_checked, structure_selection, label_selection, filter_prop_mod, filter_prop_remove, filter_prop_selector, property_divs, current_data)
Updating the properties, structures, and filters incorporated into the main plot
- Parameters:
property_selection (list) – Properties selected for plotting
property_checked (list) – Properties selected from property tree view
structure_selection (list) – Structures selected to be plotted
label_selection (list) – Label selected for the plot
remove_prop (list) – Remove property filter clicked
prop_mod (list) – Modifier applied to property filter changed
property_divs (list) – Children of property filter parent has been updated
current_data (list) – Contents of the global-property-store, updated by this plugin.
- Returns:
Updated global-property-store object
- Return type:
list
- update_property_selector(property_value: str, property_info: list)
Updating property filter range selector
- Parameters:
property_value (str) – Name of property to generate selector for
property_info (list) – Dictionary containing range/unique values for each property
- Returns:
Either a multi-dropdown for categorical properties or a RangeSlider for quantitative values
- Return type:
tuple
- class fusion_tools.components.tools.HRAViewer
Bases:
ToolHRAViewer Tool which enables hierarchy visualization for organs, cell types, biomarkers, and proteins in the Human Reference Atlas
For more information on the Human Reference Atlas (HRA), see: https://humanatlas.io/
- Parameters:
Tool (None) – General class for interactive components that visualize, edit, or perform analyses on data.
- gen_layout(session_data: dict)
Generate layout for HRA Viewer component
- get_callbacks()
Initializing callbacks and attaching to DashBlueprint
- get_organ_table(organ: str)
Grabbing ASCT+B Table for a specific organ
- Parameters:
organ (str) – Name of organ to get table for
- load(component_prefix: int)
- update_hra_viewer(viewer_drop_value)
Updating the HRAViewer component based on selected view
- Parameters:
viewer_drop_value (list) – Selected component from dropdown (one of FTU Explorer or {organ} ASCT+B Table)
- class fusion_tools.components.tools.MultiTool
Bases:
objectGeneral class for a Tool which works on multiple slides at once
- class fusion_tools.components.tools.OverlayOptions(ignore_list: list = ['_id', '_index'], property_depth: int = 4)
Bases:
ToolOverlayOptions Tool which enables editing overlay visualization properties including line color, fill color, and filters.
- Parameters:
Tool (None) – General class for interactive components that visualize, edit, or perform analyses on data.
- add_filter(add_filter_click, delete_filter_click, overlay_info_state, overlay_options)
Adding a new filter to apply to GeoJSON features
- Parameters:
add_filter_click (_type_) – Add filter icon clicked
delete_filter_click (_type_) – Delete filter icon (x) clicked
overlay_info_state (_type_) – Summary information on properties for GeoJSON features
- Raises:
exceptions.PreventUpdate – Stop callback execution
exceptions.PreventUpdate – No information provided for GeoJSON properties, cancels adding new filter.
- Returns:
List of current filters applied to GeoJSON features
- Return type:
list
- add_structure_line_color(overlay_names: list)
- adv_update_overlays(butt_click: list, colorbar_width: list, colormap_val: list, current_feature_hideout: list)
Update some additional properties of the overlays and display.
- Parameters:
butt_click (list) – Button clicked to update overlay properties
colorbar_width (list) – Width of colorbar in pixels
colormap_val (list) – Colormap option to pass to chroma
current_feature_hideout (list) – Current hideout properties for all structures
- Returns:
Updated colorbar width, line width, and colormap
- Return type:
tuple
- create_layer_from_filter(icon_click: list, current_filters: list, current_annotations: list, current_overlay_names: list, line_colors: list, colormap: list)
- export_layers(button_click, current_layers, slide_information)
- gen_layout(session_data: dict)
Generating OverlayOptions layout, added to DashBlueprint() object to be embedded in larger layout.
- get_callbacks()
Initializing callbacks for OverlayOptions Tool
- load(component_prefix: int)
- parse_added_filters(add_filter_parent: list) list
Getting all filter values from parent div
- Parameters:
add_filter_parent (list) – List of dictionaries containing component information from dynamically added filters.
- Returns:
List of filter values to apply to current GeoJSON features.
- Return type:
list
- update_filter_selector(add_filter_value, overlay_info_state)
Updating the filter selector (either a RangeSlider or Dropdown component depending on property type)
- Parameters:
add_filter_value (str) – Selected property to be used for filters.
overlay_info_state (list) – Current information on GeoJSON feature properties (contains “min” and “max” for numeric properties and “unique” for categorical properties)
- Raises:
exceptions.PreventUpdate – Stop callback execution
- Returns:
Filter selector. Either a dropdown menu for categorical properties or a dcc.RangeSlider for selecting a range of values between the minimum and maximum for that property
- Return type:
_type_
- update_overlays(overlay_value, transp_value, lineColor_butt, filter_parent, filter_value, delete_filter, overlay_state, transp_state, overlay_info_state, lineColor_state, overlay_names, colormap_val, current_hideout)
Update overlay transparency and color based on property selection
Adding new values to the “hideout” property of the GeoJSON layers triggers the featureStyle Namespace function
- Parameters:
overlay_value (list) – Value to use as a basis for generating colors (range of colors for numeric properties and list of colors for categorical properties)
transp_value (list) – Transparency value for each feature.
lineColor_butt (list) – Whether the button to update the lineColor property was clicked.
filter_parent (list) – Parent Div containing filter information
filter_value (list) – Whether the callback is triggered by a new filter value being selected
delete_filter (list) – Whether the callback is triggered by a filter being deleted
overlay_state (list) – State of overlay dropdown if not triggered by new overlay value selection
transp_state (list) – State of transparency slider if not triggered by transparency slider adjustment
overlay_info_state (list) – Information on overlay properties for current GeoJSON features
lineColor_state (list) – Current selected lineColors to apply to current GeoJSON features
colormap_val (list) – Current colormap applied to overlays,
current_hideout (list) – Current hideout properties assigned to each GeoJSON layer
- Returns:
List of dictionaries added to the GeoJSONs’ “hideout” property (used by Namespace functions) and a colorbar based on overlay value.
- Return type:
tuple
- update_slide(new_annotations: list)
- class fusion_tools.components.tools.PropertyPlotter(ignore_list: list = [], property_depth: int = 6)
Bases:
ToolPropertyPlotter Tool which enables more detailed selection of properties across the entire tissue. Allows for generation of violin plots, scatter plots, and UMAP plots.
- Parameters:
Tool (None) – General class for interactive components that visualize, edit, or perform analyses on data.
- extract_data_from_features(geo_list: list, properties: list, labels: list, filter_list: list | None = None) list
Iterate through properties and extract data based on selection
- Parameters:
geo_list (list) – List of current GeoJSON features
properties (list) – List of properties to use in the current plot
labels (list) – List of labels to use in the current plot (should just be one element)
filter_list – List of dictionaries containing g_idx and f_idx corresponding to the layers and features to extract data from
filter_list – Union[list,None], optional
- Returns:
Extracted data to use for the plot
- Return type:
list
- extract_property(feature: dict, properties: list, labels: list) dict
Extracting list of properties and labels from a single feature in a GeoJSON FeatureCollection
- Parameters:
feature (dict) – One Feature in GeoJSON FeatureCollection
properties (list) – List of property names to extract
labels (list) – List of properties used as labels to extract
- Returns:
Dictionary of properties and labels for a single Feature
- Return type:
dict
- gen_layout(session_data: dict)
Generating layout for PropertyPlotter Tool
- Returns:
Layout for PropertyPlotter DashBlueprint object to be embedded in larger layouts
- Return type:
dash.html.Div.Div
- gen_scatter_plot(data_df: DataFrame, plot_cols: list, label_col: str | None, customdata_cols: list)
Generating a 2D scatter plot using provided data
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
plot_cols (list) – Names of columns containing properties for the scatter plot
label_cols (Union[str,None]) – Name of column to use to label markers.
customdata_cols (list) – Names of columns to use for customdata on plot
- Returns:
Scatter plot figure
- Return type:
go.Figure
- gen_selected_div(n_markers: int, available_properties)
Generate a new property-graph-selected-div after changing the number of markers
- Parameters:
n_markers (int) – New number of markers
- gen_umap_cols(data_df: DataFrame, property_columns: list) DataFrame
Scale and run UMAP for dimensionality reduction
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
property_columns (list) – Names of columns containing properties for UMAP plot
- Returns:
Dataframe containing colunns named UMAP1 and UMAP2
- Return type:
pd.DataFrame
- gen_violin_plot(data_df: DataFrame, label_col: str | None, property_column: str, customdata_columns: list)
Generating a violin plot using provided data, property columns, and customdata
- Parameters:
data_df (pd.DataFrame) – Extracted data from current GeoJSON features
label_col (Union[str,None]) – Name of column to use for label
property_column (str) – Name of column to use for property (y-axis) value
customdata_columns (list) – Names of columns to use for customdata (accessible from clickData and selectedData)
- Returns:
Figure containing violin plot data
- Return type:
go.Figure
- generate_property_dict(available_properties, title: str = 'Features')
- get_callbacks()
Initializing callbacks for PropertyPlotter Tool
- load(component_prefix: int)
- make_property_plot_tabs(data_df: DataFrame, label_col: str | None, property_cols: list, customdata_cols: list) list
Generate property plot description tabs
- Parameters:
data_df (pd.DataFrame) – Current data used to generate the plot
label_col (Union[str,None]) – Column of data_df used to label points in the plot.
property_cols (list) – Column(s) of data_df plotted in the plot.
customdata_cols (list) – Column(s) used in the “customdata” field of points in the plot
- Returns:
List of tabs including summary statistics, clustering options, selected data options
- Return type:
list
- remove_marker_label(delete_click, current_plot_data, available_properties)
Remove marker from selected feature
- Parameters:
delete_click (list) – Clear marker button clicked
current_plot_data (list) – Current data for plot
- Returns:
Updating current markers on SlideMap, current plot data, and property-graph-selected-div
- Return type:
tuple
- select_data_from_plot(selected_data, current_plot_data, available_properties)
Updating selected data tab based on selection in primary graph
- Parameters:
selected_data (list) – Selected data points in the current plot
current_plot_data (list) – Data used to generate the current plot
- Raises:
exceptions.PreventUpdate – Stop callback execution because there is no selected data
exceptions.PreventUpdate – Stop callback execution because there is no selected data
- Returns:
Selected data description div, markers to add to the map, updated current plot data
- Return type:
tuple
- sub_select_data(sub_selected_data)
Updating the markers on the map according to selected data in the sub-plot
- Parameters:
sub_selected_data (list) – Selected points in the sub-plot
current_plot_data (list) – Plot data in the main-plot
current_features (list) – Current GeoJSON features on the map
- Returns:
Updated list of markers applied to the map
- Return type:
list
- update_property_graph(plot_butt_click, property_list, label_list, property_keys, current_features, current_plot_data)
Updating plot based on selected properties, label(s)
- Parameters:
plot_butt_click (list) – Whether this callback is triggered by the plot button being clicked
property_list (list) – List of properties to incorporate in the generated plot
label_list (list) – List of properties to use as labels in the generated plot
current_features (list) – Current set of GeoJSON features
current_plot_data (list) – Data present in the current plot.
- Raises:
exceptions.PreventUpdate – Stop callback execution because no properties are selected
exceptions.PreventUpdate – Stop callback execution because no properties are selected
- Returns:
Generated plot figure and new plot data
- Return type:
tuple
- update_slide(new_annotations: list)
- update_sub_div(plot_butt_clicked, marker_butt_clicked, sub_plot_value, current_plot_data, current_features, current_labels)
Updating the property-graph-selected-div based on selection of either a property to plot a sub-plot of or whether the marker properties button was clicked
- Parameters:
plot_butt_clicked (list) – Update sub-plot button was clicked
marker_butt_clicked (list) – Get marker features for selected samples clicked
current_plot_data (list) – Current data in the plot
current_features (list) – Current set of GeoJSON FeatureCollections on the SlideMap
current_labels (list) – Current labels applied to the main plot
- Returns:
Updated children of the selected-property-graph-div including either sub-plot or table of marker features
- Return type:
tuple
- class fusion_tools.components.tools.PropertyViewer(ignore_list: list = [], property_depth: int = 6)
Bases:
ToolPropertyViewer Tool which allows users to view distribution of properties across the current viewport of the SlideMap
- Parameters:
Tool (None) – General class for interactive components that visualize, edit, or perform analyses on data
- gen_layout(session_data: dict)
Generating layout for PropertyViewer Tool
- Returns:
Layout added to DashBlueprint() object to be embedded in larger layout
- Return type:
dash.html.Div.Div
- generate_plot_tabs(current_property_data, current_features)
Generating tabs for each structure containing plot of selected value.
- Parameters:
current_property_data (dict) – Data stored for current viewport and property value selection
current_features (list) – Current GeoJSON features
- Returns:
Tabs object containing a tab for each structure with a plot of the selected property value
- Return type:
dbc.Tabs
- get_callbacks()
Initializing callbacks for PropertyViewer Tool
- load(component_prefix: int)
- update_property_viewer(slide_map_bounds, view_type_value, view_subtype_value, view_butt_click, active_tab, current_property_data, update_viewer, current_subtype_children, current_geojson, available_properties)
Updating visualization of properties within the current viewport
- Parameters:
slide_map_bounds (list) – Current viewport boundaries
view_type_value (list) – Property to view across each GeoJSON object
view_subtype_value (list) – If a subtype is available for the view type, what it’s value is. This is present for nested (dictionary) properties.
view_butt_click (list) – Whether the callback is triggered by update plot button
active_tab (list) – Which tool tab is currently in view. Prevents update if the current tab isn’t “property-viewer”
current_property_data (list) – Data used in current set of plots
update_viewer (list) – Switch value for whether or not to update the plots based on panning around in the SlideMap
current_subtype_children (list) – Parent container of all sub-type dropdown divs.
current_geojson (list) – Current set of GeoJSON features and their properties
- Raises:
exceptions.PreventUpdate – Stop callback execution
- Returns:
List of PropertyViewer tabs (separated by structure) and data used in plots
- Return type:
tuple
- update_slide(new_annotations: list)
- class fusion_tools.components.tools.Tool
Bases:
objectGeneral class for interactive components that visualize, edit, or perform analyses on data.
Annotation Components
Components related to segmentation
- class fusion_tools.components.segmentation.BulkLabels(ignore_list: list = [], property_depth: int = 4)
Bases:
ToolAdd labels to many structures at the same time
- Parameters:
Tool (None) – General class for interactive components that visualize, edit, or perform analyses on data
- add_labels_to_structures(button_click, current_annotations, current_labels)
- apply_labels(button_click, current_markers, current_data, label_type, label_text, label_rationale, label_source, label_method, slide_information)
Applying current label to marked structures
- Parameters:
button_click (list) – Button clicked
current_markers (list) – Current markers on the slide-map
current_data (list) – Current labels data
label_type (list) – Type of label being added
label_text (list) – Label being added to structures
label_rationale (list) – Optional additional rationale to save with label decision
label_source (list) – Property and spatial filters incorporated to generate markers
label_method (list) – Method used to apply labels to structures
current_annotations (list) – Current GeoJSON annotations on the slide map
- Returns:
Updated labels data and annotations with label added as a property
- Return type:
tuple
- download_data(button_click, label_data)
Download both the labels applied to the current session as well as the labeling metadata
- Parameters:
button_click (list) – Download button clicked
label_data (list) – Current label data and metadata
- Returns:
Data sent to the two download components in the layout containing JSON formatted label data and metadata
- Return type:
tuple
- gen_layout(session_data: dict)
Generating layout for BulkLabels component
- Returns:
BulkLabels layout
- Return type:
html.Div
- get_callbacks()
Adding callbacks to DashBlueprint object
- get_namespace()
Adding JavaScript functions to the BulkLabels Namespace
- get_scale_factors(image_metadata: dict)
Function used to initialize scaling factors applied to GeoJSON annotations to project annotations into the SlideMap CRS (coordinate reference system)
- Returns:
x and y (horizontal and vertical) scale factors applied to each coordinate in incoming annotations
- Return type:
float
- load(component_prefix: int)
- parse_filter_divs(add_property_parent: list) list
Processing parent div object and extracting name and range for each property filter.
- Parameters:
add_property_parent (list) – Parent div containing property filters
- Returns:
List of property filters (dicts with keys: name and range)
- Return type:
list
- parse_spatial_divs(spatial_query_parent: list, slide_information: dict) list
Parsing through parent div containing all spatial queries and returning them in list form
- Parameters:
spatial_query_parent (list) – Div containing spatial query child divs
- Returns:
Processed queries with keys “type”, “structure”, and “distance” (if “nearest” selected)
- Return type:
list
- refresh_labels(refresh_click, structure_options)
Clear current label components and start over
- Parameters:
refresh_click (list) – Refresh icon clicked
structure_options (list) – Names of current overlay layers
- Returns:
Cleared labeling components
- Return type:
tuple
- search_labels(marker_features, current_labels, label_type, label_text, label_method)
Checking current labels and adding the new label based on label_method (inclusive, exclusive, or unlabeled).
- Parameters:
marker_features (list) – GeoJSON Features for new markers
current_labels (list) – List of all current labels (dicts with keys: centroid, labels)
label_type (str) – String corresponding to the type for the new label
label_text (str) – String corresponding to the new label to apply to each centroid
label_method (str) – One of: in (inclusive, append new label to current regardless of type), over (exclusive, replace existing labels of same type), or un (unlabeled, only apply label to structures that do not have a label for this type)
- Returns:
Updated set of labels, including original set
- Return type:
dict
- update_filter_data(property_filter, sp_query_type, sp_query_structure, sp_query_distance, remove_sq, remove_prop, spatial_mod, prop_mod, property_divs: list, spatial_divs: list, slide_information: list)
- update_label_properties(add_click: list, remove_click: list, property_info: list)
Adding/removing property filter dropdown
- Parameters:
add_click (list) – Add property filter clicked
remove_click (list) – Remove property filter clicked
- Returns:
Property filter dropdown and parent div of range selector
- Return type:
tuple
- update_label_structures(update_structures_click: list, include_structures: list, filter_data: list, current_features: list, slide_information: list)
Go through current structures and return all those that pass spatial and property filters.
- Parameters:
update_structures_click (list) – Button clicked
include_structures (list) – List of structures to include in the final filtered GeoJSON
filter_properties (list) – List of property filters to apply to current GeoJSON
spatial_queries (list) – List of spatial filters to apply to current GeoJSON
current_features (list) – Current structures in slide map
- Returns:
Markers over structures that pass the spatial and property filters, count of structures, enabled label components
- Return type:
tuple
- update_label_table(table_data, current_labels)
- update_method_explanation(method)
Updating explanation given for the selected label method
- Parameters:
method (list) – Name of method selected
- Returns:
Description of the labeling method selected
- Return type:
list
- update_property_selector(property_value: str, property_info: list)
Updating property filter range selector
- Parameters:
property_value (str) – Name of property to generate selector for
property_info (list) – Dictionary containing range/unique values for each property
- Returns:
Either a multi-dropdown for categorical properties or a RangeSlider for quantitative values
- Return type:
tuple
- update_slide(new_annotations: list)
- update_spatial_queries(add_click, remove_click, structure_names)
Generating a new spatial query selector once the add/remove icons are clicked
- Parameters:
add_click (list) – Add spatial query icon selected
remove_click (list) – Delete spatial query icon selected
structure_names (list) – Names of current overlay structures
- Returns:
Spatial query selectors (two dropdown menus and delete icon)
- Return type:
tuple
- update_spatial_query_definition(query_type)
Returning the definition for the selected spatial predicate type
- Parameters:
query_type (str) – Name of spatial predicate
- Returns:
Markdown string
- Return type:
dcc.Markdown
- update_structure_count(marker_dblclicked, marker_geo)
- class fusion_tools.components.segmentation.FeatureAnnotation(storage_path: str, labels_format: str = 'json', annotations_format: str = 'one-hot')
Bases:
ToolEnables annotation (drawing) on top of structures in the SlideMap using a separate interface.
- Parameters:
Tool (None) – General Class for interactive components that visualize, edit, or perform analyses on data.
- add_new_class_label(add_class, add_label, new_class, new_label, label_text, current_structure_data, current_structure, slide_information)
Adding a new class or label to the current structure
- Parameters:
add_class (list) – Add class clicked
add_label (list) – Add label clicked
new_class (list) – New class to add to the current structure
new_label (list) – New label name to add for the current structure
label_text (list) – New label text to add for the current structure
current_structure_data (list) – Current structure bounding boxes and indices
current_structure (list) – Current structure selection
- Returns:
Returning updated figure with new line color, fill color and saving the new label to the save directory
- Return type:
list
- create_class_label(add_class_value, add_submit_click, add_class_color, add_class_name, add_label_name, current_class_options, current_label_options)
Creating a new class or label to add to the session
- Parameters:
add_class_value (list) – Dropdown value for adding either a class or label
add_submit_click (list) – Submit button clicked
add_class_color (list) – New color for the new class added
add_class_name (list) – New name for the new class added
add_label_name (list) – New name for new label added
current_class_options (list) – Current options in the class dropdown menu
current_label_options (list) – Current options in the label dropdown menu
- Returns:
Updating the label and class dropdown options
- Return type:
tuple
- gen_layout(session_data: dict)
Generating layout for component
- get_callbacks()
Initializing callbacks and adding to DashBlueprint
- get_scale_factors(image_metadata: dict)
Function used to initialize scaling factors applied to GeoJSON annotations to project annotations into the SlideMap CRS (coordinate reference system)
- Returns:
x and y (horizontal and vertical) scale factors applied to each coordinate in incoming annotations
- Return type:
float
- get_structure_region(structure_bbox: list, slide_information: dict, scale: bool = True)
Using the tile server “regions_url” property to pull out a specific region of tissue
- Parameters:
structure_bbox (list) – List of minx, miny, maxx, maxy coordinates
scale (bool) – Whether or not to scale the bbox values to slide coordinates
- load(component_prefix: int)
- save_annotation(save_click, current_annotations, current_classes, current_structure_data, current_structure, slide_information)
Saving the current annotation in image format
- Parameters:
save_click (list) – Save button is clicked
current_annotations (list) – Current annotations (in SVG path format)
- save_label(label_name, label_text, image_bbox, slide_information)
Save new label to current save folder.
- Parameters:
label_name (str) – Name of label type adding label_text to (e.g. “color”)
label_text (str) – Label to add (e.g. “blue”)
- save_mask(annotations, class_options, image_bbox, slide_information)
Saving annotation mask with annotated classes using pre-specified format
- Parameters:
annotations (list) – List of SVG paths from the current figure
class_options (list) – List of colors and names for all classes
image_bbox (list) – Bounding box for the current image
- update_slide(slide_selection, vis_data)
- update_structure(structure_drop_value, prev_click, next_click, current_structure_data, current_class_value, slide_information)
Updating the current structure figure based on selections
- Parameters:
structure_drop_value (list) – Structure name selected from the structure dropdown menu
prev_click (list) – Previous button clicked
next_click (list) – Next button clicked
current_structure_data (list) – Current structure bounding boxes and indices
current_class_value (list) – Current class value from the class dropdown menu
- Returns:
Updated figure containing new structure, updated structure index if previous or next button is clicked, cleared label text
- Return type:
tuple
- update_structure_options(slide_bounds, current_features, active_tab)
Updating the structure options based on updated slide bounds
- Parameters:
slide_bounds (list) – Current slide bounds
current_features (list) – Current set of GeoJSON FeatureCollections
active_tab (list) – Active tab in vis-tools
- Returns:
Updated structure dropdown options and bounding box data
- Return type:
tuple