Access output data¶
To access the data that OCTRON has generated (the coordinates of all your labelled objects for each frame, masks, etc), you can either drag and drop the prediction output folder on the napari window and click "Open with OCTRON", or use python directly to access the data. We have compiled this tutorial notebook for that purpose.
To learn more about the output that OCTRON saves for each analysed video file see the File System - Analysis page.
Access OCTRON prediction results¶
# To access any prediction results programmatically,
# you can use the AnalysisResults class.
from octron import AnalysisResults
results_dir = 'path_to_folder/predictions/some_output_bytetrack'
results = AnalysisResults(results_dir, verbose=True)
# results contains quite a bit of information now ...
print(results.height, results.width, results.num_frames)
# The track_id_label is a dictionary that contains the
# track id as key and the label as value
print(results.track_id_label)
# to access tracking data
tracking = results.get_tracking_data(interpolate=False)
# to access mask data
masks = results.get_mask_data()
Load OCTRON prediction results into napari¶
You can either drag and drop the folder onto the napari main window, or trigger the same operation like this:
# You can access the AnalysisOctron class directly if you
# want to use it for your own purposes
# This allows you to plot things in napari like you would when
# drag-and-dropping the results into napari
# This is just a convenience function to load the results,
# but should not be used for any serious analysis.
# In fact, AnalysisOctron accesses AnalysisResults itself to load the results!
from octron import AnalysisOctron
results_dir = 'path_to_folder/predictions/some_output_bytetrack'
analysis = AnalysisOctron()
# Loop over all results and add them to napari one by one
# (positions are shown raw by default - pass sigma_tracking_pos=2
# or higher if you want a smoothed, less jittery display instead)
for frame_results in analysis.load_predictions(save_dir=results_dir,
open_viewer=True
):
# you can access the tracking_df and features_df here if you want to ...
# label, trackid, color, tracks, feats, masks = frame_results
# ...
# ...
# ... or just continue
continue