Skip to content
jvoganPublic

About

AI-native microscopy analysis. Ask your AI agent to track spots, measure microtubule dynamics, analyze changes over time and across conditions, and go back and forth with tools like ImageJ.

Topics

Resources

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Repository files navigation

mtrack: AI-native microscopy analysis. Track dynamics with your AI agent.

mtrack

mtrack is an AI-native tool for measuring microtubule growth and dynamics in microscopy movies. Ask your AI agent to track the growing ends in a movie, and it reports the growth rate and opens the tracks on the movie. Curate them together: point at a comet and ask about it, or join, split, and reject tracks, and the agent recomputes the numbers. Compare conditions, make kymographs, and go back and forth with ImageJ.

Works in Claude Science, Claude Code, Codex, and any other agent that supports MCP (the Model Context Protocol).

mtrack-demo.mp4

The demo in Claude Science, 2 min 28 s: one neuron tracked; a comet checked; growth rates in a box, along a line, and inside a Fiji region; where comets disappear; taxol against DMSO; a z-stack in 3D; and the twelve-cell gallery. Full-resolution film.

You:     Track the EB3 comets in DMSO cell 4 and show me the growth rate.
Claude:  The EB3 comets in DMSO cell 4 grow at 19.8 µm/min ±4%, and mtrack
         rates that number usable.

Claude Science: the reply with the growth rate, next to the viewer with the tracks on DMSO cell 4

mtrack in Claude Science: the reply, and the viewer with the tracks drawn on the movie.

Work with your agent

Review the tracks together

The viewer plays the movie in your browser, offline, with the tracks drawn on it. Pick a track to see its growth rate. To ask about a spot, point at a comet or draw a box or a line, press Copy for chat, and paste it to your agent. It answers about that spot: Inside box m1, comets grow at 20.0 µm/min (104 segments).

Curate the tracks together

Join, split, or reject tracks in the viewer, press Copy request, and paste it to your agent: mtrack replays your edits and recomputes the numbers. Or ask for an edit in the chat, such as Reject tracks 3 and 7, and confirm it in the viewer.

Go back and forth with ImageJ and other tools

From the viewer's Fiji menu, your agent writes a folder that opens in ImageJ with the movie, the tracks, and your marks, plus a TrackMate file. For a z-stack, the folder also holds a macro that turns the stack in 3D. Save a selection in ImageJ, and your agent can measure inside it: Comets in the region you drew in Fiji grow at 20.0 µm/min, from 128 growth segments.

mtrack also reads tracks from TrackMate, Trackastra, btrack, or any Python tracker, spots from Spotiflow or trackpy, and masks from Cellpose-SAM, micro-SAM, or StarDist. It writes tracks for napari and TrackMate, in the GEFF and Cell Tracking Challenge formats, and as tables for Prism or Excel (ImageJ and other tools).

The viewer and the ImageJ round trip have also run on a movie of lysosomes. mtrack's growth-rate readouts are validated for microtubules.

Open microscope files directly

Give your agent the file from the microscope. mtrack opens .nd2, .czi, .lif, and other microscope files directly and reads the pixel size and frame interval from their metadata.

Paste a methods paragraph

mtrack writes a methods paragraph from the settings the run recorded: the detector and its threshold, the linking distance, the calibration and its source, and how mtrack computed the growth rate. From DMSO cell 4: The movie was calibrated at 0.147 µm/px and 1 s per frame (file metadata).

Measure growth and dynamics

Get a growth rate and its rating

mtrack finds comets in each frame, links them into tracks, and splits each track into growth segments: the stretches where the comet moves steadily forward. It reports the segments' median speed as the growth rate and rates it usable, usable with caveats, or withheld. Checks for calibration, crowding, drift, zigzag tracks, and linking set the rating. For a withheld rate, mtrack prints the reason and the setting to try instead of a number.

mtrack also reports the comet disappearance rate: in DMSO cell 4, comets disappear 7.2 times per minute of tracked growth.

Movie, comets, tracks cut into growth segments, and the growth rate with its rating

Compare conditions

Give your agent a folder of movies and name the groups. mtrack tracks every movie at one shared threshold, counts each movie once, and writes a table and a plot with a 95% confidence interval. For three DMSO and three taxol neurons, growth is 3.5 µm/min slower with taxol (−16.9%), 95% CI −6.3 to −0.7. The tables open in Prism or Excel.

Growth speed per movie: 17% slower with taxol than with DMSO

Compare regions of a cell

Ask where comets disappear, and mtrack divides the cell into regions by distance from the cell body and reports each region's growth rate and disappearance rate. In DMSO cell 4, comets disappear most often far from the cell body: 1.3 times as often as in the rest of the cell. You can also set the regions with your own drawing or a label image.

The regions page for DMSO cell 4, with each region's rates

Make a kymograph along a line you choose

Draw a line in the viewer or name a track, and mtrack makes the kymograph along it and measures each streak: along track 276, 10 streaks with a median of 17.3 µm/min. mtrack also measures growth from kymographs when fluorescent tubulin labels the whole microtubule.

A kymograph along track 276: 10 streaks, median 17.3 µm/min

Choose a z-stack plane and turn the stack in 3D

Ask which plane has the most comets. mtrack surveys and ranks every plane, tracks three of the best, or every plane if you ask, and shows them side by side in a plane gallery. For a lattice light-sheet stack of HeLa cells with all 51 planes tracked, the reply was Most comets of 51 tracked: plane 23 (102.9 comets per frame). From the plane gallery, turn the whole stack in 3D.

The plane gallery's 3D view of a lattice light-sheet z-stack, with the best plane outlined

Stack: u-track 3D example data by P. Roudot, K. Dean and W. Legant, Zenodo 6881276, CC BY 4.0.

How it runs

You ask; your agent calls mtrack's tools; you get numbers with a rating and the viewer

mtrack gives your agent its mt_* tools over MCP, with a skill that describes them. Every agent calls the same tools and gets the same numbers. mtrack runs on your own computer, on the CPU with no GPU: it reads the movie there and returns numbers, tables, and file paths to your agent, plus a picture for a kymograph, regions, a comparison, or a close look at a spot.

Without an agent, the mtrack command line and the Python package run the same pipeline:

mtrack track movie.tif -o movie.result.json --csv movie --html movie.html
import mtrack
result = mtrack.track("movie.tif", pixel_size_um=0.107, frame_interval_s=2.0)
print(result.summary["growth_rate_um_min"]["median"])

Install

You need macOS or Linux and Python 3.10 to 3.14. To connect an agent, you also need Node.js 22.12 or newer. The commands use python3.12; any supported version works in its place.

git clone https://github.com/jvogan/mtrack.git
cd mtrack

Claude Science

Keep the checkout under your home folder and run node scripts/setup_claude_science.mjs. The script builds and registers mtrack, then prints two prompts to paste into the app: one grants access to the folder, and one installs the skill. See the Claude Science quickstart.

Claude Code, Codex, and other agents

Build once:

python3.12 -m venv .venv
.venv/bin/python -m pip install -e 'python[microscope]'
node viewer/build.mjs
npm --prefix connector ci
npm --prefix connector run build

Then register mtrack with your agent:

  • Claude Code: start it with the server entry in MCP hosts, or install the plugin.
  • Codex: node scripts/setup_codex.mjs --codex-home "$HOME/.codex" prints the entry for Codex's config.toml; add --install to write it. The command line, the desktop app, and the IDE extension share that file (Codex quickstart).
  • Any other MCP agent: add one JSON entry (MCP hosts).

Without an agent

Run the first two lines of the build, then source .venv/bin/activate to put mtrack on your PATH.

First run

Start with a simulated movie whose answer is known. Ask your agent Run the synthetic demo, or run this in a terminal:

mtrack synth --preset easy -o synth-easy --html synth-easy.html

mtrack simulates 60 frames of EB comets, tracks them, and prints the true median growth rate, 15.01 µm/min, and the measured one, 14.87 µm/min.

Next, fetch the neuron movie of DMSO cell 4 into data/demo (a 45 MB download, about a minute):

.venv/bin/python scripts/fetch_demo_movies.py \
  --movie DMSO_220412_cell0004_after.ome.tif

Without --movie, the script fetches all twelve neuron movies and the z-stack (625 MB).

Then give your agent the full path to data/demo/neurons/DMSO_220412_cell0004_after.ome.tif and ask it to track the EB3 comets, or run:

mtrack track data/demo/neurons/DMSO_220412_cell0004_after.ome.tif

Expect 19.8 µm/min ±4%, rated usable.

Your own movie

Give your agent the movie's full path and the marker. If the file does not record the pixel size and frame interval, give those too:

Track /path/to/movie.nd2 as EB3 comets in mammalian cells,
at 0.107 µm/px and 2 s/frame, and show it to me.

If either value is missing, mtrack reports pixels and frames and withholds the rate in µm/min rather than guessing. Comet movies need frames seconds apart, not tens of seconds.

Input formats. mtrack reads .tif, .tiff, .ome.tif, .ome.tiff, .stk, .lsm, and .npy directly. The [microscope] install adds readers for .nd2, .czi, .lif, .oib, and .oif; .czi, .lif, .oib, and .oif need Python 3.12 or newer. For a TIFF stack or .npy file that does not record its axes, pass --axes TYX for a time series. Videos (.mp4, .avi, .mov, .mkv, .m4v, .wmv) open with the video extra (optional extras). Their compression changes intensities, so use them to look, not to measure.

Accuracy

The end-to-end check tracks a simulated movie, 60 frames of the realistic_tirf preset, and scores mtrack against the known tracks:

Check Result
End-to-end (scripts/e2e_smoke.py) 7 / 7 stages
Detection recall / precision 0.932 / 0.938
Track purity 0.938
Localisation RMSE 0.789 px = 84 nm at 107 nm/px, 0.432 px = 46 nm debiased
Growth rate recovered 14.73 µm/min against a realised true median of 14.87, 0.9% low (configured 15.00)

The ±4% after a growth rate is the error measured on simulated comets moving 1.5 to 3 px per frame (validation). For published movies, see real-data results.

The viewer playing the simulated movie

Guides

Licence and data

The code is under the MIT licence (LICENSE). The repository holds no movies: the fetch scripts download them from their sources, and third-party data records each source and licence. The neuron movies are from Schelski and Bradke, Zenodo 7114108, CC0.

Cite

Cite mtrack version 0.1.1 and the biological methods behind your analysis, as CITATION.cff describes. Record the source_tree_sha256 from your result to identify the code you used. mtrack is not MTrack, the Fiji plugin by Kapoor et al. (Sci Rep 2019).

About

AI-native microscopy analysis. Ask your AI agent to track spots, measure microtubule dynamics, analyze changes over time and across conditions, and go back and forth with tools like ImageJ.

Topics

Resources

Contributing

Security policy

Stars

6 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages