itasc.cellpose.cellpose_runner¶
Local Cellpose-SAM runner, Qt-free, used by the napari Cellpose widget.
Functions
Lazy-load the cpsam model once per process; cached at module level. |
|
|
Best-effort layout from array ndim. |
|
|
|
|
|
Single 2D-slice cell inference. |
|
Process a (T, Z, Y, X) stack slice-by-slice in 2D. |
|
Single-frame nucleus inference. |
|
Process a (T, Z, Y, X) stack frame-by-frame. |
|
Normalize an input array to canonical |
|
Write the two canonical TIFFs under output_dir. |
Classes
|
|
|
Exceptions
Raised by run_*_stack when cancel_cb returns True between frames. |
- itasc.cellpose.cellpose_runner.infer_layout_from_ndim(ndim)[source]¶
Best-effort layout from array ndim.
2 -> "2D"and4 -> "3D+t"are unambiguous;3is ambiguous (2D+tvs3D) so returnsNoneand the caller keeps the user’s explicit choice.
- itasc.cellpose.cellpose_runner.to_tzyx(arr, layout)[source]¶
Normalize an input array to canonical
(T, Z, Y, X)for its layout.Singleton
Tand/orZaxes are inserted so 2D/2D+t/3D/3D+t inputs all become 4-D; the runner then iterates uniformly over frames and z-slices.
- class itasc.cellpose.cellpose_runner.NucleusParams(do_3d, anisotropy, diameter, min_size, gamma, cellprob_threshold=0.0, flow_threshold=0.4, niter=0)[source]¶
Bases:
object- Parameters:
- itasc.cellpose.cellpose_runner.get_model()[source]¶
Lazy-load the cpsam model once per process; cached at module level.
- itasc.cellpose.cellpose_runner.run_nucleus_frame(frame, z, params)[source]¶
Single-frame nucleus inference.
If
zis None, runs full 3D over (Z, Y, X) and returns prob with shape (Z, Y, X) and dp with shape (3, Z, Y, X). Ifzis an integer, runs 2D on frame[z] and returns prob with shape (Y, X) and dp with shape (2, Y, X).
- exception itasc.cellpose.cellpose_runner.CancelledError[source]¶
Bases:
RuntimeErrorRaised by run_*_stack when cancel_cb returns True between frames.
- itasc.cellpose.cellpose_runner.run_cell_frame(frame, z, params)[source]¶
Single 2D-slice cell inference. Returns (prob (Y,X), dp (2,Y,X)).
- itasc.cellpose.cellpose_runner.run_nucleus_stack(stack, params, *, progress_cb=None, cancel_cb=None)[source]¶
Process a (T, Z, Y, X) stack frame-by-frame.
Returns (prob_3dt, dp_3dt). For do_3d=True dp has shape (T, 3, Z, Y, X); for do_3d=False dp has shape (T, Z, 2, Y, X).
- itasc.cellpose.cellpose_runner.run_cell_stack(stack, params, *, progress_cb=None, cancel_cb=None)[source]¶
Process a (T, Z, Y, X) stack slice-by-slice in 2D.
Returns (prob_3dt (T, Z, Y, X), dp_3dt (T, Z, 2, Y, X)).
- itasc.cellpose.cellpose_runner.write_outputs(prob_3dt, dp_3dt, output_dir, channel)[source]¶
Write the two canonical TIFFs under output_dir.
Writes
{channel}_prob.tifand{channel}_dp.tif. Axis labels are recorded as metadata so singletonT/Zaxes (2D / 2D+t / single 3D-stack inputs) survive the TIFF round-trip and are not misread downstream.