Skip to content

Commit cde47ce

Browse files
committed
Do not re-export common TrackMate features values and declaration.
Without this commit, they are exported twice with different names.
1 parent 78dda48 commit cde47ce

2 files changed

Lines changed: 57 additions & 2 deletions

File tree

src/main/java/org/mastodon/mamut/io/importer/trackmate/CommonTrackMateFeatureDeclarations.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import static org.mastodon.mamut.io.importer.trackmate.TrackMateXMLKeys.FEATURE_TAG;
99

1010
import java.util.Arrays;
11+
import java.util.Collections;
1112
import java.util.List;
1213

1314
import org.jdom2.Element;
@@ -67,4 +68,27 @@ public Element toElement()
6768
return fel;
6869
}
6970
}
71+
72+
/**
73+
* List of Mastodon spot projection keys, translated to the TrackMate export
74+
* name, that are not needed in the exported XML file, as they are already
75+
* exported via TrackMate builtin features.
76+
*/
77+
public static final List< String > redundantSpotProjectionKeys = Arrays.asList(
78+
"Spot_position_X", "Spot_position_Y", "Spot_position_Z", "Spot_radius", "Spot_frame" );
79+
80+
/**
81+
* List of Mastodon link projection keys, translated to the TrackMate export
82+
* name, that are not needed in the exported XML file, as they are already
83+
* exported via TrackMate builtin features.
84+
*/
85+
public static final List< String > redundantLinkProjectionKeys = Arrays.asList(
86+
"Link_target_IDs_Source_spot_id", "Link_target_IDs_Target_spot_id" );
87+
88+
/**
89+
* List of Mastodon track projection keys, translated to the TrackMate
90+
* export name, that are not needed in the exported XML file, as they are
91+
* already exported via TrackMate builtin features.
92+
*/
93+
public static final List< String > redundantTrackProjectionKeys = Collections.emptyList();
7094
}

src/main/java/org/mastodon/mamut/io/importer/trackmate/MamutExporter.java

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,15 @@ private Element edgeToXml( final Link edge, final int sourceSpotID, final int ta
540540
// Link features.
541541
for ( final ExportFeatureProjection< Link > p : linkFeatureProjections )
542542
{
543-
final String attName;
544543
final String origName = p.attributeName;
544+
/*
545+
* Do not export link features that are common TrackMate features
546+
* and that we already exported above.
547+
*/
548+
if ( CommonTrackMateFeatureDeclarations.redundantLinkProjectionKeys.contains( origName ) )
549+
continue;
550+
551+
final String attName;
545552
/*
546553
* If the model to export was imported from a TrackMate or a MaMuT
547554
* file, it will already contain features with the same name that
@@ -634,8 +641,15 @@ private Element spotToXml( final Spot spot )
634641

635642
for (final ExportFeatureProjection< Spot > p : spotFeatureProjections )
636643
{
637-
final String attName;
638644
final String origName = p.attributeName;
645+
/*
646+
* Do not export spot features that are common TrackMate features
647+
* and that we already exported above.
648+
*/
649+
if ( CommonTrackMateFeatureDeclarations.redundantSpotProjectionKeys.contains( origName ) )
650+
continue;
651+
652+
final String attName;
639653
/*
640654
* If the model to export was imported from a TrackMate or a MaMuT
641655
* file, it will already contain features with the same name that
@@ -710,16 +724,33 @@ private < T > void appendFeaturesDeclarationOfClass( final Class< T > clazz, fin
710724
final String classFeatureDeclarationTag )
711725
{
712726
final List< ExportFeatureProjection< T > > projections;
727+
List< String > redundantFeatures;
713728
if ( clazz.equals( Spot.class ) )
729+
{
714730
projections = ( List ) spotFeatureProjections;
731+
redundantFeatures = CommonTrackMateFeatureDeclarations.redundantSpotProjectionKeys;
732+
}
715733
else if ( clazz.equals( Link.class ) )
734+
{
716735
projections = ( List ) linkFeatureProjections;
736+
redundantFeatures = CommonTrackMateFeatureDeclarations.redundantLinkProjectionKeys;
737+
}
717738
else
739+
{
718740
projections = Collections.emptyList();
741+
redundantFeatures = CommonTrackMateFeatureDeclarations.redundantTrackProjectionKeys;
742+
}
719743

720744
final Element classFeaturesElement = getOrAddChild( featuresElement, classFeatureDeclarationTag );
721745
for ( final ExportFeatureProjection< T > p : projections )
722746
{
747+
/*
748+
* Do not export features that are common TrackMate features and
749+
* that we already declared.
750+
*/
751+
if ( redundantFeatures.contains( p.attributeName ) )
752+
continue;
753+
723754
final String isint = ( p.projection instanceof IntFeatureProjection )
724755
? "true"
725756
: "false";

0 commit comments

Comments
 (0)