Metadata-Version: 2.5
Name: linkinpy-stardist
Version: 0.0.4
Summary: LinkinPy-compatible high-level StarDist training and inference workflows.
Author-email: "Bruno M. Saraiva" <bruno.msaraiva2@gmail.com>
License-Expression: MIT
Requires-Python: >=3.10
Requires-Dist: llvmlite>=0.42
Requires-Dist: numba>=0.59
Requires-Dist: numpy>=1.26
Requires-Dist: stardist>=0.9.2
Requires-Dist: tensorboard>=2.15
Requires-Dist: tensorflow>=2.15
Requires-Dist: tifffile>=2024.8.10
Description-Content-Type: text/markdown

# LinkinPy-StarDist

`linkinpy-stardist` provides LinkinPy-compatible StarDist 2D training and prediction
workflows. The package is intended to be installed through `Library/StarDist.yaml`, but it
can also be used directly from Python.

## Workflows

- `train_2d_with_qc`: train a custom StarDist 2D model with optional augmentation and
  held-out quality control.
- `predict_2d_custom_model`: run inference with a trained model directory.
- `predict_2d_pretrained_model`: run inference with a StarDist pretrained model.
- `batch_predict_2d_custom_model`: run custom-model prediction over an input folder.
- `batch_predict_2d_pretrained_model`: run pretrained prediction over an input folder.

## Install

```bash
uv pip install linkinpy-stardist
```

Most users should install it indirectly:

```bash
cd LinkinPy
uv run linkinpy install ../Library/StarDist.yaml --interface cli
```

## Data Layout For Training

Training expects paired raw images and instance-label masks. File names are matched by
stem:

```text
training/
  images/
    cell01.tif
    cell02.tif
  masks/
    cell01.tif
    cell02.tif
```

`images/cell01.tif` pairs with `masks/cell01.tif`.

## CLI Example Through LinkinPy

```bash
cd LinkinPy
uv run linkinpy run ../Library/StarDist.yaml "Predict 2D Pretrained Model" \
  --output-dir outputs \
  image=input.tif \
  model_name=2D_versatile_fluo
```

Prediction methods return labels as `np.ndarray` outputs. Batch methods return summary
paths that point to written batch results.

## Direct Python Example

```python
import tifffile
from linkinpy_stardist import predict_2d_pretrained_model

image = tifffile.imread("input.tif")
labels = predict_2d_pretrained_model(
    image=image,
    model_name="2D_versatile_fluo",
)
```

## Quality Control

When quality control is enabled during training, the data is split into train, validation,
and test sets. The held-out test split is used only for post-training QC metrics.

For the full LinkinPy interface tutorial, see [../../USAGE_TUTORIALS.md](../../USAGE_TUTORIALS.md).
