From f63043cf80d366f58f96250091f7a94beab871d0 Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Thu, 21 Sep 2023 00:29:02 +0200 Subject: [PATCH] Add the track id option to the getLabelId() method --- .../SegmentUsingEllipsoidsController.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/mastodon/mamut/segment/SegmentUsingEllipsoidsController.java b/src/main/java/org/mastodon/mamut/segment/SegmentUsingEllipsoidsController.java index 2242ded55..fc324a007 100644 --- a/src/main/java/org/mastodon/mamut/segment/SegmentUsingEllipsoidsController.java +++ b/src/main/java/org/mastodon/mamut/segment/SegmentUsingEllipsoidsController.java @@ -204,12 +204,22 @@ private static long[] addTimeDimension( long[] dimensions, int timepoints ) private int getLabelId( final Spot spot, final LabelOptions option ) { - if ( labelOptions.equals( LabelOptions.SPOT_ID ) ) + switch ( option ) + { + case SPOT_ID: return spot.getInternalPoolIndex(); - BranchSpot ref = model.getBranchGraph().vertexRef(); - int branchSpotId = model.getBranchGraph().getBranchVertex( spot, ref ).getInternalPoolIndex(); - model.getBranchGraph().releaseRef( ref ); // NB: optional, but increases performance, when this method is called often - return branchSpotId; + case BRANCH_SPOT_ID: + BranchSpot ref = model.getBranchGraph().vertexRef(); + int branchSpotId = model.getBranchGraph().getBranchVertex( spot, ref ).getInternalPoolIndex(); + model.getBranchGraph().releaseRef( ref ); // NB: optional, but increases performance, when this method is called often + return branchSpotId; + case TRACK_ID: + if ( trackIdProjection == null ) + trackIdProjection = getTrackIDFeatureProjection( context, model ); + return ( int ) trackIdProjection.value( spot ); + default: + throw new IllegalArgumentException( "Unknown label option: " + option ); + } } private static ImgPlus< IntType > createImgPlus( final Img< IntType > img )