SplineDist: Automated Cell Segmentation with Spline Curves

We present SplineDist, an instance segmentation convolutional neural network for bioimages extending the popular StarDist method. While StarDist describes objects as star-convex polygons, SplineDist uses a more flexible and general representation by modelling objects as planar parametric spline curves. Based on a new loss formulation that exploits the properties of spline constructions, we can incorporate our new object model in StarDist’s architecture with minimal changes. We demonstrate in synthetic and real images that SplineDist produces segmentation outlines of equal quality than StarDist with smaller network size and accurately captures non-star-convex objects that cannot be segmented with StarDist.


INTRODUCTION
A vast amount of biological questions investigated using microscopy data rely on an initial partitioning of the image into individual objects, a task referred to as instance segmentation [1]. Dividing an image into object regions multiplies the amount of data point that can be extracted from it. Protein expression [2] and morphology [3], among many others, can then be quantified at the single-cell level, thereby moving away from population averaging. Due to the sheer amount of imaging data acquired in modern biology experiments and because segmentation is so essential, the development of automated computational segmentation methods has been at the heart of bioimage analysis since its early days [4]. In the past decade, deep learning approaches have revolutionized this field of research [5]. Convolutional neural networks (CNN) in general, and the U-net model in particular [6], have demonstrated an unprecedented capability to consistently produce excellent segmentation results in a wide range of data, massively reducing the need for manual intervention.
Recently, StarDist [7] established itself as a popular detection and instance segmentation tool in the bioimaging community due to its simplicity and efficiency. StarDist generates object outlines as star-convex polygons: it relies on a U-net architecture to predict the locations of a fixed number of points on an object's contour, and constructs the final outline by linearly interpolating between them. This object representation is reminiscent of the one used in the parametric B-spline active contour (AC) algorithm [8] and in its many variants [9,10,11]. In spline AC methods, objects are segmented with a spline interpolated curve that deforms in the image following the minimization of a handcrafted energy functional. Beyond segmentation itself, the main advantage of these approaches is to provide a continuously-defined description of the object contour as a parametric curve that can readily be used to, e.g., perform statistical shape analysis [12]. The flexibility of spline curves makes them suitable for a variety of segmentation problems, but their optimization requires domain-expertise, restricting their use in practice. In preliminary work, we proposed a first step towards circumventing this limitation by directly predicting spline interpolated outlines from an input image using a CNN regressor [13]. Our prototype was however limited to binary images featuring a single object.
Here, we introduce SplineDist, an instance segmentation algorithm that combines the capabilities of StarDist with those of spline approximation. Thus, SplineDist benefits both from the detection performance of StarDist and the segmentation quality of spline models. We show that SplineDist equals StarDist's excellent segmentation results with a smaller number of parameters. Besides, SplineDist can segment objects regardless of their star-convexity, thus lifting StarDist's main restriction. As a result, SplineDist expands the range of applicability of StarDist and offers a robust alternative to spline-based AC methods.
The paper is organized as follows. In Section 2, we recall the technical details of StarDist and describe the construction of SplineDist. We then experimentally compare the two methods and illustrate SplineDist's capabilities in Section 3. Finally, we conclude the paper in Section 4.

StarDist
Given an input image featuring one or many biological objects, StarDist [7] predicts a star-convex polygon of R vertices for every pixel. More precisely, at every pixel location (i, j) in the image, StarDist predicts the set of radial distances ..,R−1 to the boundary of the object enclosing (i, j) at R equidistant angles 2π R (Figure 1b). Because the distances d k ij are not defined for background elements, StarDist simultaneously predicts an object probability p ij for each pixel, allowing to ignore proposals from pixels with low object probability. For each pixel in the image, StarDist's loss is formulated as where p ij andp ij are the ground truth and predicted pixelwise object probabilities, and D ij andD ij are the ground truth and predicted sets of radial distances to the object contour. The first term, L BCE , is the standard binary cross entropy loss [14] and λ 1 is a regularization factor. The second term, L radii , is a mean absolute error loss weighted by ground truth object probabilities and expressed as with λ 2 a regularization factor. This loss is finally averaged over all the pixels present in the image. An important consequence of (2) is that, during training, a set of individual ground truth radial distances D ij must be generated for each individual pixel (i, j) from a reference instance labelling of the entire image. Once star-convex polygons have been predicted for all the pixels, overlapping candidates are filtered by a non-maximum suppression (NMS) step taking into account their associated object probabilities. The final set of polygons corresponds to individual object instances in the image.

SplineDist
Instead of representing objects as polygons, we propose to adopt the more flexible model used in spline AC algorithms, which uses spline interpolation. Essentially, SplineDist models an object outline as a two-dimensional parametric planar spline curve s defined by where c[k] = (c k x , c k y ) are two-dimensional control points, which are the parameters of the spline model. While the number M of control points is fixed, they can be located anywhere in the image. The function ϕ M (t) = m∈Z ϕ(t − M m) is the M -periodized version of a predefined spline basis ϕ, allowing to get a closed curve [9]. This object model is general Here, R = 8, M = 6, and ϕ = β 3 the cubic B-spline basis. and unifying: we can indeed consider any spline basis for ϕ, typically polynomial B-splines of any order. In the following, we denote as SplineDist β n the version of SplineDist relying on ϕ = β n , the polynomial B-spline basis of degree n [15].
Using this representation, SplineDist predicts an object probability for each image pixel (i, j) along with a set of M two-dimensional control points c ij [k] that fully define the spline curve (3). Similar to the StarDist radii, the c ij [k] are expressed in relative coordinates with respect to (i, j), in polar form. More specifically, SplineDist predicts M angles α k ij and M radial distances d k ij such that c ij [k] = (d k ij cos(α k ij ), d k ij sin(α k ij )) ( Figure 1c). This construction is more flexible than star-convex polygons: in contrast to the R scalar radii at fixed angle, the M twodimensional control point vectors can point in any direction (angle and distance) from (i, j). The continuouslydefined curve s ij generated by the control point sequence {c ij [k]} k=0,...,M −1 can be sampled at any rate. We denote as S ij = {s n ij } n=0,...,N −1 the set of N discrete points obtained by uniformly sampling s ij (t) as It is essential that we can construct a sequence S of any desired number of points N from {c ij [k]} k=0,...,M −1 for two reasons. First, reference annotations come in the form of instance pixel masks, from which discrete contours can efficiently be extracted during training using classical image processing methods such as Satoshi and Abe's algorithm [16]. Second, several control point sets may draw the same outline, so the very concept of ground truth control points does not make sense. We thus design SplineDist's loss to evaluate the similarity between S ij , the discrete object outline that {c ij [k]} k=0,...,M −1 generates, and a pixel-based ground truth object outline P ij = {p n ij } n=0,...,N −1 extracted from a reference instance mask. As a consequence, the value of N in (4) is dictated by the number of points in the ground truth P ij . In other words, SplineNet predicts the parameters of the continuous spline curve (3) that, when uniformly sampled, matches most closely the ground truth pixel outline of the object enclosing (i, j). SplineDist's loss is formally expressed as in which p ij andp ij are the ground truth and predicted pixelwise object probabilities as in (1). Because (5) involves the outline generated by the object model parameters and not the parameters themselves, a major difference with respect to StarDist is that individual pixels do not require to have their own ground truth. All pixels (i, j) enclosed in the same object O can indeed share a single ground truth outline P ij = P O for all (i, j) ∈ O expressed in absolute (image) coordinates. The individual outline S ij that each pixel predicts can also straightforwardly be expressed in absolute coordinates by shifting the spline curve s ij around (i, j). This trick relieves the need to store relative coordinates describing the ground truth for each pixel. We can then afford considering the entire ground truth contour in the loss (as opposed to only R points) while remaining computationally tractable. The rest of SplineDist's architecture is similar to StarDist, the remaining difference being the size of the final output layer (Figure 2).

Implementation Details
We use the high-quality StarDist codebase (github.com/ mpicbg-csbd/stardist) and mainly modify modules associated with ground truth generation and loss computations. For technical reason, our implementation sets N as the number of points in the largest ground truth contour in the training set, and carries out subpixel interpolation to expand all shorter ground truth contours to this size. Hence, all pixels can be processed in a single tensor in the loss without unpacking, which critically speeds up training time. Like StarDist, SplineDist is implemented in TensorFlow [17] and is available at gitlab.ebi.ac.uk/smandal/splinedist.

Benchmarking
We compare the segmentation performance of SplineDist against StarDist on the image set BBBC038v1 (also known as Kaggle 2018 Data Science Bowl dataset), available from the Broad Bioimage Benchmark Collection [18]. It is composed of a diverse collection of images of cell nuclei which faithfully reflects the variability of object appearance and image types in bioimaging. BBBC038v1 is designed to challenge the generalization capabilities of a method across these variations and is therefore widely used for benchmarking. We employ the curated subset of BBBC038v1 provided in StarDist's github repository and already used in [7] to benchmark StarDist against state-of-the-art alternatives. This dataset is composed of 447 training images and 50 testing images.
Acknowledging the good approximation properties of cubic B-splines [19], we consider SplineDist β 3 in our experiments. For a fair comparison, we use StarDist's default network hyperparameters, data augmentation strategy, and training settings both in StarDist and SplineDist β 3 (decaying learning rate of 0.0003, 400 epochs, batch size of 4). We also use StarDist's default NMS and object probability thresholds for both methods. We report the classical Intersection over Union (IoU) metric, also referred to as Jaccard index [20], to quantify instance segmentation quality.
In Figure 3, we quantitatively compare the performance of StarDist and SplineDist β 3 with increasing equal number of points (R = M ). As expected from spline approximation theory [21], both methods eventually converge to the same results as the number of points grows larger since StarDist can be seen as SplineDist β 1 with control points at fixed angles. The performance plateau, reached by StarDist from R = 16 onward, is already attained by SplineDist β 3 at M = 6. The

Segmentation of non-star-convex objects
Because it can predict control points anywhere around the object and doesn't rely on predefined angles, SplineDist can generate non-star-convex outlines. There is indeed no restriction imposing that all control points should have different angles. To explore this difference, we compare the performance of StarDist and SplineDist on a set of synthetic images containing mostly star-convex and some non-star convex cell-like objects. In that way, StarDist can still converge and we do not explicitly enforce SplineDist to learn how to represent nonstar-convex objects. Our synthetic dataset is composed of 500 grayscale (8-bit) 512 × 512 images featuring from 1 to 20 randomly-shaped, non-overlapping deformed binary blobs that are subsequently degraded by non-uniform illumination, additive Poisson-Gaussian noise, and Gaussian blurring. We randomly split the dataset in 450 images for training and 50 for testing. We compare the vanilla StarDist (R = 32) against SplineDist β 1 with M = 32 (also a polygon of 32 vertices, but without the star-convex restriction) and SplineDist β 3 with M = 8. The performance of SplineDist β 1 reflects what could be expected from StarDist if radii angles were not fixed, while those obtained with SplineDist β 3 illustrate the advantage brought by a smoother spline basis. While the average IoU of the three methods do not significantly differ since most objects in the dataset have pure or nearly star-convex shapes, a more in-depth assessment of the results ( Figure 5) reveals a clear difference in performance on non-star-convex objects. StarDist either misses parts of non-star-convex objects or breaks them into several instances. We also note that SplineDist β 3 achieves quantitatively equivalent and less noisy results than SplineDist β 1 with 4× fewer points.

CONCLUSIONS
We have introduced SplineDist, a modification of StarDist in which objects are represented as planar spline curves. SplineDist produces segmentation outlines of equally good quality as StarDist with an object model involving fewer parameters. Additionally, SplineDist generalises StarDist by lifting the star-convex polygon limitation. SplineDist therefore combines the detection performance of StarDist with the segmentation quality of spline curve models as traditionally used in parametric AC, while alleviating the weaknesses of either of these methods alone.