/nimbus-skills:nimbusimagefrom nimbus-skills
Connects to a NimbusImage server and works with scientific imaging datasets via the nimbusimage Python API. Handles authentication, listing datasets, opening images, and routing to sub-skills for annotations, analysis, and exports.
Ships in nimbus-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
The nimbusimage Python API lets you programmatically access NimbusImage scientific imaging datasets. This skill teaches you the API patterns so you can write correct code for the user.
The package follows an accessor pattern: connect → get dataset → use sub-accessors (ds.images, ds.annotations, ds.connections, ds.properties, ds.collections, ds.export, ds.history, ds.sharing).
NimbusImage also has an MCP server whose tools are named ni_* (ni_datasets_list, ni_annotations_count, ...). It exists for clients that cannot run code, such as claude.ai and Claude Desktop. When both are available, as in Claude Code or Codex with the connector added:
ni_* tools.The package must be installed first:
pip install nimbusimage
For Docker worker development (includes large_image for writing TIFF files):
pip install nimbusimage[worker]
Two snags come up often enough that they belong here:
error: externally-managed-environment (PEP 668). Homebrew Python on macOS and most distro Pythons on Linux refuse pip install into the system interpreter. Use a venv:
python3 -m venv ~/venvs/ni
source ~/venvs/ni/bin/activate
pip install nimbusimage
Phantom namespace package in the NimbusImage source repo. The repo at arjunrajlaboratory/NimbusImage contains a top-level nimbusimage/ directory (the source of the package). If you run Python from the repo root, PEP 420 namespace-package resolution will let import nimbusimage "succeed" with an empty module even when nothing is installed, so the usual python -c "import nimbusimage" smoke test is misleading. Verify with __file__:
import nimbusimage
assert nimbusimage.__file__, "nimbusimage is shadowed by a local directory"
print(nimbusimage.__file__) # should point inside a site-packages dir
If __file__ is None, either pip install nimbusimage into a venv, or cd out of the NimbusImage repo before running your script.
Before writing any connection code, check whether the user already has credentials configured. Follow this sequence:
Check whether the variables are set without printing their values:
test -n "${NI_API_URL:-}" && echo "NI_API_URL is set" || echo "NI_API_URL is missing"
test -n "${NI_API_KEY:-}" && echo "NI_API_KEY is set" || echo "NI_API_KEY is missing"
test -n "${NI_TOKEN:-}" && echo "NI_TOKEN is set" || echo "NI_TOKEN is missing"
If NI_API_URL and either credential variable are set, use ni.connect() with no arguments.
If credentials are missing, tell the user which variables to export in their local shell, then rerun the presence check. Do not ask them to paste API keys, tokens, or passwords into the conversation.
If they do not have an API key, tell them to request one from their NimbusImage administrator.
Never print, hardcode, or repeat credentials. Never guess default passwords.
import nimbusimage as ni
# Best: environment variables (NI_API_URL + NI_API_KEY) — just works
client = ni.connect()
# With explicit API key
client = ni.connect("http://localhost:8080/api/v1", api_key="your-api-key")
# With session token (expires — API key is preferred)
client = ni.connect("http://localhost:8080/api/v1", token="session-token")
# With username/password (for one-off interactive use)
client = ni.connect("http://localhost:8080/api/v1", username="...", password="...")
The recommended setup uses an API key, which is persistent and doesn't expire (unlike session tokens).
How to get an API key:
Key scope. Ask for (or create) a key that is either full access ("Allow all actions on behalf of my user") or custom-scoped with "List and read jobs" (jobs.rest.list_job) alongside Read data / Write data. Without "List and read jobs" a key can still submit workers, and they run, but it can't poll job status or read job logs. Users add the permission themselves if they can edit their keys, or ask the server's admin (support, for nimbusimage.com). See "Can't see a job's status ≠ the job didn't run" in references/gotchas.md.
# Add to ~/.zshrc or ~/.bashrc for persistence
# For nimbusimage.com:
export NI_API_URL="https://app.nimbusimage.com/girder/api/v1"
export NI_API_KEY="your-api-key-here"
# For a local server:
export NI_API_URL="http://localhost:8080/api/v1"
export NI_API_KEY="your-api-key-here"
# Optional: frontend URL for browser links
export NI_FRONTEND_URL="http://localhost:5173"
The package tries auth methods in this order:
token= parameterapi_key= parameterusername= / password= parametersNI_API_KEY environment variable (recommended)NI_TOKEN environment variable (session token, expires)| Variable | Description |
|---|---|
NI_API_URL | Girder API URL (e.g., http://localhost:8080/api/v1) |
NI_API_KEY | Girder API key (persistent, recommended) |
NI_TOKEN | Session token (expires, use API key instead) |
NI_FRONTEND_URL | Frontend URL for browser links (default: http://localhost:5173) |
# List all accessible datasets
datasets = client.list_datasets()
for d in datasets:
print(f"{d['name']} (ID: {d['_id']})")
# Get a dataset by ID
ds = client.dataset("64a1b2c3d4e5f6a7b8c9d0e1")
# Or look it up by name
ds = client.dataset(name="My Experiment")
Uploading files does not by itself make a dataset — the files are just items in a folder until they are configured into one multi-dimensional image. Three steps:
ds = client.create_dataset("My Experiment") # empty; goes in your Private folder
ds.upload("path/to/images/") # a file, a directory, or a list
ds.configure() # works out XY / Z / Time / Channel
ds.open() # opens it in the browser
upload() is not recursive and raises if the directory contains
subdirectories, so a partial upload can't be mistaken for a complete one.
configure() is the API equivalent of the web UI's configuration screen: it
derives the dimensions from filename tokens and file metadata, writes the
multi-source configuration, and (unless every file is .nd2 and at most 16
tiles are composited) schedules a transcode job.
configure(dry_run=True) computes everything and writes nothing. Do this
before a real run — when the configuration is not valid, a real run raises,
and the exception does not carry the variable list you need to fix it:
plan = ds.configure(dry_run=True)
if not plan.is_valid:
print(plan.validation_error) # e.g. "Not all variables are assigned"
for v in plan.unassigned_variables:
print(v["name"], v["source"], v["guess"], v["size"])
The common case is more variables than the four dimensions' defaults fill —
typically a filename variable left over once file metadata has claimed Z and C.
Assign it by copying the variable's source/guess onto the dimension you
want:
# dry run reported: Filename variable 1 (source='filename', guess='C', size=2)
result = ds.configure(
assignments={"XY": {"source": "filename", "guess": "C"}},
transcode=False,
)
print(result.item_id, result.job_id)
Each assignments entry is {"source", "guess"} or None (leave the
dimension unassigned); omitted dimensions keep their default. source is one
of filename, file (embedded metadata such as ND2 IndexRange), or images
(raw frame order).
A folder with one single-position .nd2 per field (e.g. Nikon's
Well1_Point1_0001_…_Seq0001.nd2) can be stitched into one image by each
file's stage position. The filename parser usually guesses the bare tile number
as C, so move it to XY:
plan = ds.configure(dry_run=True) # tile number shows up as filename/C
result = ds.configure(
assignments={"XY": {"source": "filename", "guess": "C"},
"C": {"source": "file", "guess": "C"}},
enable_compositing=True,
)
assert result.compositing # False if files lack stage positions
# or differ in tile size / pixel size
Check plan.compositing_check in the dry run: an error means two files sit
at the same stage position (the real run would fail with that message), and
a warning means the tiles cover little of the mosaic (e.g. two wells), which
is usually better left as separate XY positions. Compositing more than 16
tiles (stage positions; compositing_check["tileCount"]) transcodes by
default, whether they come from many files or one multi-position file.
| Argument | Meaning |
|---|---|
transcode | Convert to one tiled TIFF. Omit to use the UI's rule (on unless every file is .nd2, and also on when compositing more than 16 tiles, i.e. stage positions — a long job for thousands of tiles); pass False to skip. |
split_rgb_bands | Split an RGB image into three channels (default True). |
enable_compositing | Lay out ND2 files by stage position rather than as separate XY positions. Applies to one multi-position ND2, or to a folder of ND2 files (one per tile) with the same tile size once the variable that tells the files apart is on XY — result.compositing says whether it applies (XY then collapses to one position). A request that cannot be honored (files that cannot composite, or two tiles at one stage position) is the dry run's validation_error and makes a real run fail, rather than falling back to separate positions. |
create_view | Also create the collection and dataset view the web UI needs (default True). Turn it off only if you are going to create your own. |
Failures come back as girder_client.HttpError: 400 for an invalid
configuration — unassigned variables, sources with different pixel types
(every file must share a dtype), an item with zero or several files, and
filenames whose parts do not line up (a.tif alongside b_x_0.tif: the web UI
cannot configure that folder either) — and 409
if the dataset is already configured. Reconfiguring means starting from a new
dataset.
When transcode is on, configure() returns as soon as the job is queued,
so checking it is your job — and a failure is not self-healing:
result = ds.configure()
if result.job_id and not client.job(result.job_id).wait():
# The dataset is configured but its image is unusable. Configuring
# again raises 409 because the configuration item exists; delete
# result.item_id, or start from a new dataset.
...
configure() creates a collection and dataset view by default, so the dataset
behaves like one made through the web UI — it appears in
client.list_datasets() (which enumerates views) and opens straight away:
result = ds.configure()
print(result.collection_id, result.view_id)
ds.open() # opens the viewer in a browser
print(ds.view_url()) # or just the URL
The collection gets the same defaults the UI would create: one layer per channel (up to six), named after the channel and colored from the shared channel-color table, with percentile contrast, plus pixel size from the tile metadata and z-step inferred from the dimension labels.
With create_view=False none of that is created. The dataset is still fully
readable through the API (ds.channels, ds.images, annotations), but
ds.open() and ds.view_url() raise No dataset view found, and
client.list_datasets() will not list it.
print(f"Name: {ds.name}")
print(f"Shape: {ds.shape}") # (height, width)
print(f"Channels: {ds.channels}") # list of channel names
print(f"Num channels: {ds.num_channels}")
print(f"Z-slices: {ds.num_z}")
print(f"Time points: {ds.num_time}")
print(f"XY positions: {ds.num_xy}")
ps = ds.pixel_size # None when the size is unknown
print(f"Pixel size: {ps.to('um').value if ps else 'unknown'} um")
print(f"Dtype: {ds.dtype}")
print(f"Magnification: {ds.magnification}")
# Iterate all frames
for frame in ds.frames:
print(f"Frame {frame.index}: ch={frame.channel}, z={frame.z}, t={frame.time}")
# Open dataset viewer in browser
ds.open(z=3, time=0)
# Get URLs without opening
print(ds.view_url()) # Image viewer URL
print(ds.info_url()) # Dataset info page
print(ds.configuration_url()) # Configuration page
projects = client.list_projects()
project = client.project(project_id)
new_project = client.create_project("My Project", description="...")
project.open() # Open in browser
# List all available worker Docker images
workers = client.list_workers()
for image, labels in workers.items():
print(f"{image}: {labels.get('interfaceName', '')}")
# Get a worker's parameter interface
interface = client.get_worker_interface("annotations/random_squares:latest")
for param, spec in interface.items():
print(f" {param}: type={spec['type']}, default={spec.get('default', '')}")
All models are Pydantic BaseModel with to_dict() and from_dict():
ni.Annotation — shape, tags, channel, location, coordinatesni.Connection — parent_id, child_id, tagsni.Property — name, shape, image (Docker), worker_interfaceni.Location — xy, z, timeni.PixelSize — value, unit (with .to('um') conversion)ni.FrameInfo — index, xy, z, time, channel, channel_nameni.Job — status, wait(), refresh(), logFor deeper operations, route to the appropriate skill:
For full accessor signatures, read references/api-overview.md. Before using lower-level APIs or modifying access, read references/gotchas.md.
The accessors (ds.images, ds.annotations, ds.sharing, etc.) are the supported surface. client._gc is the raw girder-client and exposes every Girder endpoint, including ones that can do irreversible damage if used wrong. Specifically:
client._gc.put(f"folder/{ds.id}/access", ...) to change a dataset's ACL. Use ds.sharing.share() / ds.sharing.set_public() — share() uses the incremental dataset_view/share endpoint, which changes one user at a time. The raw endpoint replaces the whole ACL and has been the source of an in-the-wild lockout. A dataset always keeps at least one user at ADMIN: removing or demoting the last one is refused (400), so give a new owner admin before stepping down. See references/gotchas.md for the full list of _gc footguns._gc. The accessor surface is curated for a reason; adding to it is preferable to bypassing it.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
7 skills in this plugin
/analyzeCompute properties, export data, manage connections, and share NimbusImage datasets using the nimbusimage Python API. Use this skill when the user wants to compute annotation measurements, export data as JSON or CSV, create connections between annotations, share datasets with collaborators, or manage access control. Also use when you see ds.properties, ds.export, ds.connections, or ds.sharing in code, or the user mentions measurements, statistics, data export, lineage tracking, or sharing imaging datasets.
/annotationsCreate, list, filter, update, and delete annotations on NimbusImage datasets using the nimbusimage Python API. Use this skill when the user wants to work with annotations — creating points or polygons, filtering by shape or tags, bulk operations, geometry conversion (shapely, numpy masks), or programmatic annotation manipulation. Also use when you see ds.annotations in code, or the user mentions spots, cells, nuclei, ROIs, polygons, or segmentation masks in an imaging context.
/imagesFetch image data from NimbusImage datasets as numpy arrays using the nimbusimage Python API. Use this skill when the user wants to retrieve image frames, composites, z-stacks, crops, or channel data from a NimbusImage dataset. Also use when you see ds.images in code, or the user mentions getting pixel data, viewing channels, making composites, or processing image arrays from their imaging server.
npx claudepluginhub arjunrajlaboratory/nimbusimage --plugin nimbusimageOther plugins' skills for the same job