Product Documentation
HomepageLoginSign up
  • Welcome to Biodock
  • Why Biodock
  • Quickstart
    • Start here (choose a tutorial)
    • Path 1: AI-assisted analysis
    • Path 2: Train a fully-automated AI model
      • Set up your project
      • Label and train
      • Labeling shortcuts
      • Run your AI model
      • Configuring your model
  • AI Projects
    • Project settings
    • Sharing your AI project
    • Training a model
  • AI Analysis
    • Results dashboard overview
    • Download results and reports
    • Correcting results to improve your model
    • Editing objects (QC)
    • Filters (like flow cytometry)
  • Biodock Scripts
    • Biodock Platform Script Guidelines
  • Files
    • Uploading images
    • AWS S3 integration
    • View and manage data
      • Viewing images
      • File details and download
      • Copy, cut, move
      • Sharing data
      • Merging channels
    • Supported image types
  • Public API (Beta)
    • Overview
    • Authentication
    • Examples
    • Resources
      • Files
      • Analysis Jobs
      • Pipelines
    • Limitations
  • Deep AI models
    • Evaluating Performance
  • User
    • Account registration
    • Change password, login, logout
    • Usage limits and team
      • Filesize based limits
      • Run credits limits
    • Billing
  • Company
    • Academics and startups
    • Contact us
    • Citing Biodock
    • Security and IP
Powered by GitBook
On this page
  • Overview
  • 1. Convert the Notebook to a Python Script
  • 2. Handling Input Paths for Images and JSON Files
  • 3. Writing Output Files
  • 4. Handling Matplotlib Plots
  • 5. Remove Unnecessary Imports
  • 6. Specify Dependencies in requirements.txt
  • 7. Uploading and Running Your Script
  1. Biodock Scripts

Biodock Platform Script Guidelines

Overview

This guide provides instructions for running scripts on the Biodock platform via the new "Scripts" tab. Follow these steps to ensure your script functions correctly within the platform's environment.

1. Convert the Notebook to a Python Script

Convert your Jupyter notebook (.ipynb) to a single Python script (.py). Ensure that all necessary code and dependencies are included in the script file.

2. Handling Input Paths for Images and JSON Files

Biodock handles file management before invoking your script. All images and GeoJSON files will exist in the same filesystem as your script, so you do not need to download anything manually.

Modify your script to accept file paths via command-line arguments:

import sys
import json

input_items_path = sys.argv[1]  # Path to input JSON file list
output_dir = sys.argv[2]  # Directory for output files

with open(input_items_path, "r") as f:
    input_items = json.load(f)
print(f"Loaded {len(input_items)} input items.")

# Example: Accessing the first image and its corresponding GeoJSON file
json_file_path = input_items[0]["geojson_path"]
image_path = input_items[0]["image_path"]

3. Writing Output Files

All output files should be written to the output_dir. Any file in this directory will be automatically uploaded to the cloud and made accessible to the user.

Example:

import os

example_output_path = os.path.join(output_dir, "example_output.txt")
with open(example_output_path, "w") as f:
    f.write("This is an example output file.")

4. Handling Matplotlib Plots

Replace all plt.show() calls with plt.savefig() to ensure that plots are saved instead of being displayed interactively. Save the files in output_dir.

Example:

import matplotlib.pyplot as plt

plt.savefig(os.path.join(output_dir, f"{layer_name}_Thickness_by_Adjusted_Angle.png"))

5. Remove Unnecessary Imports

Remove any imports related to Google Cloud or Google Colab, as these are not needed within the Biodock platform environment.

6. Specify Dependencies in requirements.txt

Create a requirements.txt file listing all the dependencies required for your script. Before execution, Biodock will create a new Python environment and install these dependencies.

Example requirements.txt:

matplotlib
numpy
pandas
shapely
tifffile
scikit-image

7. Uploading and Running Your Script

Once your script and requirements.txt file are ready, follow these steps:

  1. Place the .py file and requirements.txt in a single folder.

  2. On the Biodock platform, navigate to the Scripts tab.

  3. Click Upload Script > Browse Folders and upload your script folder.

  4. Once uploaded, go to the Runs sub-tab.

  5. Click Run Script and specify the script and analysis job.

  6. After execution, download the results, including:

    • Script outputs

    • Console output (print statements)

    • Error messages (if any)

Following these guidelines ensures that your script runs efficiently on the Biodock platform. If you have any questions, contact Biodock support for further assistance.

PreviousFilters (like flow cytometry)NextUploading images

Last updated 2 months ago