A tool for tracking worm positions on plates with food patches.
Project description
WORMTRACKATRON7000
Worm Tracker is a Python-based tool for processing and analyzing worm-tracking videos in .wmv format. It facilitates segmenting worms inside a defined polygonal region of interest (ROI) versus those outside it, saving results to CSV, generating labeled output videos (optional), producing trace maps, and reviewing and adjusting worm counts post-processing.
Features
-
Polygon ROI Selection:
For each video or group of videos (organized by their folder structure), you can select or reuse previously saved polygons to define the area of interest. -
Video Processing & Counting:
Using image processing and thresholding, the software detects and counts worms inside and outside the polygon. It stores the counts in a CSV file for each video. -
Parallel Processing:
Multiple videos are processed in parallel usingmultiprocessing, speeding up analysis for larger datasets. -
Trace Maps & Visualization:
Generates a color-coded "trace map" image showing where worms were detected most frequently inside and outside the polygon over time. -
Review Mode:
Allows you to revisit completed videos, review worm counts, and apply offset corrections to inside/outside counts across one or multiple videos (if grouped by folder). -
Plot Generation:
Automatically generates plots showing original and offset-adjusted worm counts over time for each processed CSV file.
Requirements
- Python 3.8+
- Packages:
opencv-python(OpenCV)numpypandasmatplotlibPyQt6
You can install the dependencies using:
pip install opencv-python numpy pandas matplotlib PyQt6
Usage
Running the analysis
python wormtrack analyse
Process:
- The tool first asks for configuration parameters (threshold, blur kernel, etc.).
- You select if you want to group videos by folder, whether to reuse previously saved polygons, and if you want to save labeled videos.
- Videos found in the current working directory and its subdirectories (
.wmvfiles) are processed. Worm counts are saved to CSV files named[video_basename]_worms_count.csv, and optional labeled videos are saved as[video_basename]_labeled.avi. - A polygon ROI file (
[video_basename]_polygon.npy) and a trace map file ([video_basename]_trace.png) are generated.
Running the review
python wormtrack review
Process:
- Displays a simplified configuration GUI for review mode.
- Allows you to select which processed videos to review. Videos without trace files will be disabled for selection.
- For selected videos, you can adjust worm counts by applying offsets to inside/outside counts.
- If videos are grouped by folder, you can apply the same offsets to all videos in that folder.
The CSV files are updated with the offset corrections after confirmation.
Generating plots
python wormtrack plot
Process:
- Scans for all CSV files in the current directory and subdirectories.
- Generates
*_plot_original.pngand*_plot_adjusted.pnggraphs for each CSV file, showing worm counts over frames.
File structure
-
main.pyThe main entry point for the application.
Handles command-line arguments and launches the appropriate mode (analyse,review, orplot). -
worm_tracker.pyContains theWormTrackerclass, which handles video loading, polygon ROI selection, worm counting, and trace map creation. -
worm_tracker_utils.pyUtility functions to:- Organize videos by folder.
- Handle polygon selection and loading/saving.
- Process videos in parallel.
- Update CSV files with offsets.
- Manage the review workflow.
-
gui.pyContains GUI classes and functions for:- Configuration windows (
ModernConfigWindow,ReviewConfigWindow). - Polygon selection windows (
ModernPolygonSelector). - Video selection for review (
VideoReviewSelector). - Offset adjustment window (
OffsetAdjustmentWindow).
- Configuration windows (
-
plot_utils.pyFunctions for generating plots from CSV files.
Input/ output Files
- Input:
.wmvvideo files located in the current directory and subdirectories. - Output:
[video_basename]_polygon.npy: Polygon ROI coordinates.[video_basename]_worms_count.csv: CSV file with frame-by-frame worm counts.[video_basename]_labeled.avi: Optional labeled video with worm outlines and counts.[video_basename]_trace.png: Color-coded trace map image.[video_basename]_plot_original.pngand[video_basename]_plot_adjusted.png: Plots showing original and adjusted worm counts over time.
Notes
- Ensure that the working directory is the folder containing your
.wmvvideos before runningwormtrack. - The GUI-based approach may require a display environment (i.e., not headless) when run locally.
- This code was tested with
.wmvformat videos. Other formats may work if OpenCV supports them.
License
This project is distributed under the MIT License. See LICENSE file for more details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file wormtrackatron7000-0.1.6.tar.gz.
File metadata
- Download URL: wormtrackatron7000-0.1.6.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87e4a9008059b8f0f8eae87e12e7b171ef385e220d9091bee6b600434ef8d029
|
|
| MD5 |
6f7ba8ddc8f97f659a851c483c4dc155
|
|
| BLAKE2b-256 |
fd125195a85c99e1d539ba948aa5cabed24aeb8520b9aca81a10404b38d1afb3
|
File details
Details for the file wormtrackatron7000-0.1.6-py3-none-any.whl.
File metadata
- Download URL: wormtrackatron7000-0.1.6-py3-none-any.whl
- Upload date:
- Size: 17.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
edb190642bb52b3a29cee7d240fd7a678bac1c84fe043651c8cef89d2c8ddc16
|
|
| MD5 |
e58915e36f24e6e4e1ae7d46da6d5225
|
|
| BLAKE2b-256 |
05da6de80d565e960b1fbc994f1a62fecc4216e936635e28ec29ae4dcd1ff77f
|