Skip to content
Merged

N5 #3

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .pre-commit-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ci:
skip: true

2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
repos: []

37 changes: 32 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
<releaseProfiles>sign,deploy-to-scijava</releaseProfiles>

<enforcer.skip>true</enforcer.skip>
<imglib2.version>7.1.5</imglib2.version>

<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
Expand All @@ -47,11 +48,37 @@
</licenses>

<dependencies>
<dependency>
<groupId>com.bc.zarr</groupId>
<artifactId>jzarr</artifactId>
<version>0.3.5</version>
</dependency>
<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5</artifactId>
</dependency>

<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-zarr</artifactId>
</dependency>

<dependency>
<groupId>org.janelia.saalfeldlab</groupId>
<artifactId>n5-blosc</artifactId>
</dependency>

<dependency>
<groupId>net.imglib2</groupId>
<artifactId>imglib2</artifactId>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>

<!--
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</dependency>
-->

<!-- include logback-classic at test runtime -->
<dependency>
Expand Down
77 changes: 12 additions & 65 deletions src/main/java/org/mastodon/geff/Geff.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
* %%
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
Expand All @@ -28,15 +28,10 @@
*/
package org.mastodon.geff;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import com.bc.zarr.ZarrArray;
import com.bc.zarr.ZarrGroup;

import ucar.ma2.InvalidRangeException;
import org.janelia.saalfeldlab.n5.N5Exception.N5IOException;

public class Geff
{
Expand All @@ -63,18 +58,19 @@ public static void main( String[] args )
System.out.println( "Geff library version: " + VERSION );

String zarrPath = "src/test/resources/mouse-20250719.zarr/tracks";
String outputZarrPath = "src/test/resources/mouse-20250719_output.zarr/tracks";
String outputZarrPath = "src/test/resources/mouse-20250719_output.zarr/tracks";
String n5OutputZarrPath = "src/test/resources/n5-mouse-20250719_output.zarr/tracks";

try
{
// Demonstrate reading metadata
System.out.println( "\n=== Reading Metadata ===" );
GeffMetadata metadata = GeffMetadata.readFromZarr( zarrPath );
GeffMetadata metadata = GeffMetadata.readFromZarr( zarrPath );
System.out.println( "Metadata loaded:" + metadata );

// Demonstrate reading nodes
System.out.println( "\n=== Reading Nodes ===" );
List< GeffNode > nodes = GeffNode.readFromZarr( zarrPath, metadata.getGeffVersion() );
List< GeffNode > nodes = GeffNode.readFromZarr( zarrPath, metadata.getGeffVersion() );
System.out.println( "Read " + nodes.size() + " nodes:" );
for ( int i = 0; i < Math.min( 5, nodes.size() ); i++ )
{
Expand All @@ -101,21 +97,17 @@ public static void main( String[] args )
// Try to write nodes (will show what would be written)
try
{
GeffNode.writeToZarr( nodes, outputZarrPath, ZarrUtils.getChunkSize( zarrPath ) );
GeffNode.writeToZarr( nodes, outputZarrPath, GeffUtils.getChunkSize( zarrPath ) );
}
catch ( UnsupportedOperationException e )
{
System.out.println( "Note: " + e.getMessage() );
}
catch ( InvalidRangeException e )
{
System.err.println( "InvalidRangeException during node writing: " + e.getMessage() );
}

// Try to write edges (will show what would be written)
try
{
GeffEdge.writeToZarr( edges, outputZarrPath, ZarrUtils.getChunkSize( zarrPath ) );
GeffEdge.writeToZarr( edges, outputZarrPath, GeffUtils.getChunkSize( zarrPath ) );
}
catch ( UnsupportedOperationException e )
{
Expand All @@ -139,60 +131,15 @@ public static void main( String[] args )
+ " edges" );

}
catch ( IOException e )
{
System.err.println( "IOException occurred: " + e.getMessage() );
e.printStackTrace();
}
catch ( InvalidRangeException e )
catch ( N5IOException e )
{
System.err.println( "InvalidRangeException occurred: " + e.getMessage() );
System.err.println( "N5IOException occurred: " + e.getMessage() );
e.printStackTrace();
}
catch ( Exception e )
{
System.err.println( "Unexpected exception occurred: " + e.getMessage() );
e.printStackTrace();
}

// Also demonstrate the original Zarr exploration code
System.out.println( "\n=== Original Zarr Exploration ===" );
try
{
final ZarrGroup zarrTracks = ZarrGroup.open( zarrPath );
final Iterator< String > groupKeyIter = zarrTracks.getGroupKeys().iterator();
while ( groupKeyIter.hasNext() )
{
String groupKey = groupKeyIter.next();
System.out.println( "Found group: " + groupKey );
}
final Iterator< String > arrayKeyIter = zarrTracks.getArrayKeys().iterator();
while ( arrayKeyIter.hasNext() )
{
String arrayKey = arrayKeyIter.next();
System.out.println( "Found array: " + arrayKey );
}
final Iterator< String > attrKeyIter = zarrTracks.getAttributes().keySet().iterator();
while ( attrKeyIter.hasNext() )
{
String attrKey = attrKeyIter.next();
System.out.print( "Found attribute: " + attrKey );
Object attrValue = zarrTracks.getAttributes().get( attrKey );
System.out.println( " Value: " + attrValue );
}
// Example of opening an array
System.out.println( "Opening 'nodes/ids' array..." );
ZarrArray nodesIds = zarrTracks.openArray( "nodes/ids" );
double[] nodesIdsData = ( double[] ) nodesIds.read();
System.out.println( "Read nodes/ids data: " + nodesIdsData.length + " elements." );
}
catch ( IOException e )
{
e.printStackTrace();
}
catch ( InvalidRangeException e )
{
e.printStackTrace();
e.printStackTrace();
}
}

Expand Down
Loading