From 1d3f791a2611efc4128e9f254c6baaa1351a7015 Mon Sep 17 00:00:00 2001 From: Stefan Hahmann Date: Mon, 26 Aug 2024 14:55:54 +0200 Subject: [PATCH] Rename mother id to parent id --- .../mastodon/mamut/io/csv/CSVImporter.java | 28 +++++++-------- .../io/csv/plugin/ui/CSVImporterPanel.java | 34 +++++++++---------- .../plugin/ui/CSVImporterUIController.java | 8 ++--- .../mamut/io/csv/CSVImporterTest.java | 4 +-- ...csv => TestCSVImportTagParentIdRadius.csv} | 2 +- 5 files changed, 38 insertions(+), 38 deletions(-) rename src/test/resources/org/mastodon/mamut/io/csv/{TestCSVImportTagMotherIdRadius.csv => TestCSVImportTagParentIdRadius.csv} (93%) diff --git a/src/main/java/org/mastodon/mamut/io/csv/CSVImporter.java b/src/main/java/org/mastodon/mamut/io/csv/CSVImporter.java index b994097..d0cc3c4 100644 --- a/src/main/java/org/mastodon/mamut/io/csv/CSVImporter.java +++ b/src/main/java/org/mastodon/mamut/io/csv/CSVImporter.java @@ -99,7 +99,7 @@ public class CSVImporter extends ModelImporter implements Algorithm private final String idColumnName; - private final String motherIdColumnName; + private final String parentIdColumnName; private final String labelColumnName; @@ -129,7 +129,7 @@ private CSVImporter( final String qualityColumName, final String radiusColumnName, final String idColumnName, - final String motherIdColumnName, + final String parentIdColumnName, final String labelColumnName, final String tagColumnName, final double xOrigin, @@ -148,7 +148,7 @@ private CSVImporter( this.qualityColumnName = qualityColumName; this.radiusColumnName = radiusColumnName; this.idColumnName = idColumnName; - this.motherIdColumnName = motherIdColumnName; + this.parentIdColumnName = parentIdColumnName; this.labelColumnName = labelColumnName; this.tagColumnName = tagColumnName; this.xOrigin = xOrigin; @@ -303,9 +303,9 @@ public boolean process() ? null : OriginalIdFeature.getOrRegister( model.getFeatureModel(), graph.vertices().getRefPool() ); - Integer motherIdcol = null; - if ( null != motherIdColumnName && !motherIdColumnName.isEmpty() ) - motherIdcol = headerMap.get( motherIdColumnName ); + Integer parentIdcol = null; + if ( null != parentIdColumnName && !parentIdColumnName.isEmpty() ) + parentIdcol = headerMap.get( parentIdColumnName ); Integer labelcol = null; if ( null != labelColumnName && !labelColumnName.isEmpty() ) @@ -359,7 +359,7 @@ public boolean process() { final int id = Integer.parseInt( record[ idcol ].trim() ); originalIdFeature.set( spot, id ); - if ( null != motherIdcol ) + if ( null != parentIdcol ) spotMap.put( id, spot ); if ( null == labelcol ) spot.setLabel( "" + id ); @@ -378,10 +378,10 @@ public boolean process() qualityFeature.set( spot, q ); } - if ( null != motherIdcol ) + if ( null != parentIdcol ) { - final int motherId = Integer.parseInt( record[ motherIdcol ].trim() ); - final Spot mother = spotMap.get( motherId, motherVertexRef ); + final int parentId = Integer.parseInt( record[ parentIdcol ].trim() ); + final Spot mother = spotMap.get( parentId, motherVertexRef ); if ( mother != null ) model.getGraph().addEdge( mother, spot, edgeRef ).init(); } @@ -563,7 +563,7 @@ public static class Builder private String idColumnName; - private String motherIdColumnName; + private String parentIdColumnName; private String labelColumnName; @@ -637,9 +637,9 @@ public Builder idColumnName( final String idColumnName ) return this; } - public Builder motherIdColumnName( final String motherIdColumnName ) + public Builder parentIdColumnName( final String parentIdColumnName ) { - this.motherIdColumnName = motherIdColumnName; + this.parentIdColumnName = parentIdColumnName; return this; } @@ -746,7 +746,7 @@ public CSVImporter get() qualityColumnName, radiusColumnName, idColumnName, - motherIdColumnName, + parentIdColumnName, labelColumnName, tagColumnName, xOrigin, diff --git a/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterPanel.java b/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterPanel.java index 45de685..6e0c6ee 100644 --- a/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterPanel.java +++ b/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterPanel.java @@ -75,7 +75,7 @@ public class CSVImporterPanel extends JPanel final JComboBox< String > comboBoxIDCol; - final JComboBox< String > comboBoxMotherIdCol; + final JComboBox< String > comboBoxParentIdCol; final JComboBox< String > comboBoxTagCol; @@ -360,22 +360,22 @@ public CSVImporterPanel() gbc_comboBoxID.gridy = 17; panelControl.add( comboBoxIDCol, gbc_comboBoxID ); - final JLabel lblMotherIdColumn = new JLabel( "Mother ID column:" ); - final GridBagConstraints gbc_lblMotherIdColumn = new GridBagConstraints(); - gbc_lblMotherIdColumn.anchor = GridBagConstraints.EAST; - gbc_lblMotherIdColumn.insets = new Insets( 5, 5, 5, 5 ); - gbc_lblMotherIdColumn.gridx = 0; - gbc_lblMotherIdColumn.gridy = 18; - panelControl.add( lblMotherIdColumn, gbc_lblMotherIdColumn ); - - comboBoxMotherIdCol = new JComboBox<>(); - final GridBagConstraints gbc_comboBoxMotherID = new GridBagConstraints(); - gbc_comboBoxMotherID.insets = new Insets( 5, 5, 5, 0 ); - gbc_comboBoxMotherID.gridwidth = 4; - gbc_comboBoxMotherID.fill = GridBagConstraints.HORIZONTAL; - gbc_comboBoxMotherID.gridx = 1; - gbc_comboBoxMotherID.gridy = 18; - panelControl.add( comboBoxMotherIdCol, gbc_comboBoxMotherID ); + final JLabel lblParentIdColumn = new JLabel( "Parent ID column:" ); + final GridBagConstraints gbc_lblParentIdColumn = new GridBagConstraints(); + gbc_lblParentIdColumn.anchor = GridBagConstraints.EAST; + gbc_lblParentIdColumn.insets = new Insets( 5, 5, 5, 5 ); + gbc_lblParentIdColumn.gridx = 0; + gbc_lblParentIdColumn.gridy = 18; + panelControl.add( lblParentIdColumn, gbc_lblParentIdColumn ); + + comboBoxParentIdCol = new JComboBox<>(); + final GridBagConstraints gbc_comboBoxParentID = new GridBagConstraints(); + gbc_comboBoxParentID.insets = new Insets( 5, 5, 5, 0 ); + gbc_comboBoxParentID.gridwidth = 4; + gbc_comboBoxParentID.fill = GridBagConstraints.HORIZONTAL; + gbc_comboBoxParentID.gridx = 1; + gbc_comboBoxParentID.gridy = 18; + panelControl.add( comboBoxParentIdCol, gbc_comboBoxParentID ); final JLabel lblTagColumn = new JLabel( "Tag column:" ); final GridBagConstraints gbc_lblTagColumn = new GridBagConstraints(); diff --git a/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterUIController.java b/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterUIController.java index f06a9f6..b58a4eb 100644 --- a/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterUIController.java +++ b/src/main/java/org/mastodon/mamut/io/csv/plugin/ui/CSVImporterUIController.java @@ -115,7 +115,7 @@ public void run() .qualityColumnName( ( String ) view.comboBoxQualityCol.getSelectedItem() ) .radiusColumnName( ( String ) view.comboBoxRadiusCol.getSelectedItem() ) .idColumnName( ( String ) view.comboBoxIDCol.getSelectedItem() ) - .motherIdColumnName( ( String ) view.comboBoxMotherIdCol.getSelectedItem() ) + .parentIdColumnName( ( String ) view.comboBoxParentIdCol.getSelectedItem() ) .tagColumnName( ( String ) view.comboBoxTagCol.getSelectedItem() ) .get(); @@ -293,7 +293,7 @@ private boolean readHeaders() view.comboBoxRadiusCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); view.comboBoxNameCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); view.comboBoxIDCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); - view.comboBoxMotherIdCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); + view.comboBoxParentIdCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); view.comboBoxTagCol.setModel( new DefaultComboBoxModel<>( nonMandatory ) ); int idcol = headers.indexOf( NONE_COLUMN ); @@ -327,7 +327,7 @@ private boolean readHeaders() } view.comboBoxIDCol.setSelectedIndex( idcol ); - view.comboBoxMotherIdCol.setSelectedIndex( motheridcol ); + view.comboBoxParentIdCol.setSelectedIndex( motheridcol ); view.comboBoxTagCol.setSelectedIndex( tagcol ); view.comboBoxQualityCol.setSelectedIndex( qualitycol ); view.comboBoxRadiusCol.setSelectedIndex( radiuscol ); @@ -353,7 +353,7 @@ private void clearComboBoxes() comboBoxes.add( view.comboBoxRadiusCol ); comboBoxes.add( view.comboBoxNameCol ); comboBoxes.add( view.comboBoxIDCol ); - comboBoxes.add( view.comboBoxMotherIdCol ); + comboBoxes.add( view.comboBoxParentIdCol ); comboBoxes.add( view.comboBoxTagCol ); comboBoxes.add( view.comboBoxTrackCol ); for ( final JComboBox< String > cb : comboBoxes ) diff --git a/src/test/java/org/mastodon/mamut/io/csv/CSVImporterTest.java b/src/test/java/org/mastodon/mamut/io/csv/CSVImporterTest.java index 2c227af..c446134 100644 --- a/src/test/java/org/mastodon/mamut/io/csv/CSVImporterTest.java +++ b/src/test/java/org/mastodon/mamut/io/csv/CSVImporterTest.java @@ -94,7 +94,7 @@ public void test() throws IOException, SpimDataException @Test public void testImportWithRadiusTagsLinks() { - final URL urlCSV = CSVImporterTest.class.getResource( "TestCSVImportTagMotherIdRadius.csv" ); + final URL urlCSV = CSVImporterTest.class.getResource( "TestCSVImportTagParentIdRadius.csv" ); assertNotNull( urlCSV ); final Model model = new Model(); @@ -110,7 +110,7 @@ public void testImportWithRadiusTagsLinks() .frameColumnName( "FRAME" ) .idColumnName( "ID" ) .tagColumnName( "TAG" ) - .motherIdColumnName( "MOTHER_ID" ) + .parentIdColumnName( "PARENT_ID" ) .radiusColumnName( "RADIUS" ) .get(); if ( !importer.checkInput() || !importer.process() ) diff --git a/src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagMotherIdRadius.csv b/src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagParentIdRadius.csv similarity index 93% rename from src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagMotherIdRadius.csv rename to src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagParentIdRadius.csv index 9e6bed3..2fa20c4 100644 --- a/src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagMotherIdRadius.csv +++ b/src/test/resources/org/mastodon/mamut/io/csv/TestCSVImportTagParentIdRadius.csv @@ -1,4 +1,4 @@ -ID;QUALITY;POSITION_X;POSITION_Y;POSITION_Z;FRAME;RADIUS;MEDIAN_INTENSITY;TAG;MOTHER_ID +ID;QUALITY;POSITION_X;POSITION_Y;POSITION_Z;FRAME;RADIUS;MEDIAN_INTENSITY;TAG;PARENT_ID 0; 50.943; 11.000; 11.000; 5.000; 0; 5.73; 51; tag1; -1 1; 206.877; 30.000; 31.000; 6.000; 0; 4.; 119; tag1; -1 2; 130.664; 36.000; 12.000; 7.000; 0; 2; 197; tag2; -1