Skip to content

Commit

Permalink
Rename mother id to parent id
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanhahmann committed Aug 26, 2024
1 parent fedc5d2 commit 1d3f791
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 38 deletions.
28 changes: 14 additions & 14 deletions src/main/java/org/mastodon/mamut/io/csv/CSVImporter.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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() )
Expand Down Expand Up @@ -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 );
Expand All @@ -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();
}
Expand Down Expand Up @@ -563,7 +563,7 @@ public static class Builder

private String idColumnName;

private String motherIdColumnName;
private String parentIdColumnName;

private String labelColumnName;

Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -746,7 +746,7 @@ public CSVImporter get()
qualityColumnName,
radiusColumnName,
idColumnName,
motherIdColumnName,
parentIdColumnName,
labelColumnName,
tagColumnName,
xOrigin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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 );
Expand Down Expand Up @@ -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 );
Expand All @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/mastodon/mamut/io/csv/CSVImporterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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() )
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 1d3f791

Please sign in to comment.