Comments (3)
Example in two classes:
Class that saves a model with an added feature:
package org.mastodon.revised.mamut;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.mastodon.features.DoubleFeature;
import org.mastodon.revised.model.mamut.Model;
import org.mastodon.revised.model.mamut.Spot;
import mpicbg.spim.data.SpimDataException;
public class TestSaveFeature
{
public static final String KEY = "TEST_FEATURE";
public static final File TEST_FILE = new File( "samples/test_features.raw" );
public static void main( final String[] args ) throws IOException, SpimDataException, InvocationTargetException, InterruptedException
{
final String bdvFile = "samples/datasethdf5.xml";
final String modelFile = "samples/model_revised.raw";
final MamutProject project = new MamutProject( new File( "." ), new File( bdvFile ), new File( modelFile ) );
/*
* Load Model
*/
final Model model = new Model();
if ( project.getRawModelFile() != null )
model.loadRaw( project.getRawModelFile() );
System.out.println( String.format( "Loaded a graph with %d vertices and %d edges.",
model.getGraph().vertices().size(), model.getGraph().edges().size() ) );
final DoubleFeature< Spot > test = new DoubleFeature<>( KEY, 10. );
for ( final Spot s : model.getGraph().vertices() )
s.feature( test ).set( 3.14 );
model.saveRaw( TEST_FILE );
System.out.println( "Saved to " + TEST_FILE );
}
}
Class that reloads this model:
package org.mastodon.revised.mamut;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import org.mastodon.features.Feature;
import org.mastodon.features.FeatureRegistry;
import org.mastodon.revised.model.mamut.Model;
import org.mastodon.revised.model.mamut.Spot;
import mpicbg.spim.data.SpimDataException;
public class TestLoadFeatures
{
public static void main( final String[] args ) throws IOException, SpimDataException, InvocationTargetException, InterruptedException
{
/*
* Load Model
*/
final Model model = new Model();
model.loadRaw( TestSaveFeature.TEST_FILE );
System.out.println( String.format( "Loaded a graph with %d vertices and %d edges.",
model.getGraph().vertices().size(), model.getGraph().edges().size() ) );
final Feature feature = FeatureRegistry.getFeature( TestSaveFeature.KEY );
System.out.println( "Feature with key " + TestSaveFeature.KEY + " is " + feature );
for ( final Spot s : model.getGraph().vertices() )
System.out.println( s + " feature " + s.feature( feature ).get() );
}
}
Results of the latest:
UndoRecorder.graphRebuilt()
TODO!!!!
Loaded a graph with 3087 vertices and 2981 edges.
Feature with key TEST_FEATURE is null
Exception in thread "main" java.lang.NullPointerException
at org.mastodon.graph.ref.AbstractVertexWithFeatures.feature(AbstractVertexWithFeatures.java:50)
at org.mastodon.revised.mamut.TestLoadFeatures.main(TestLoadFeatures.java:32)
from mastodon.
A solution would be maybe to change the way features are handled via static methods, and have a Model
carry with it declarations of the features it has and their type.
These declarations could be saved and deserialized before the actual features are deserialized.
The application could modify these declarations at runtime, adding or removing features at will.
from mastodon.
This is fixed by #36 (among others).
from mastodon.
Related Issues (20)
- Mastodon Exceptions Occurred During Plugin Discovery HOT 1
- Add timepoint and number of spots info to BDV View HOT 1
- Saving and Reloading BranchSpot Feature in Table does not work HOT 1
- Compute features option not working in Mastodon HOT 6
- BDV Brightness Settings dialog cannot be opened anymore HOT 9
- Tags are not shown in Edit Window of Data Table HOT 1
- Remove KeyMap binding for Brightness dialog
- bugs in Mastodon launcher HOT 2
- displaying bug in TrackScheme HOT 1
- project with .xml pointing on TIFF series is not opening HOT 5
- Adding new spots fails after deleting all spots HOT 11
- Mastodon may freeze with overlay visibility track of focused vertex HOT 7
- Backup of Mastodon files HOT 4
- Expected behaviour of Bdv Branch View HOT 2
- Show Branch Feature in TrackScheme and Bdv
- Provide textual way to search and run commands in Mastodon HOT 13
- Increase File integrity during file saving HOT 3
- Make font size of TrackScheme adjustable
- Selection Table for BranchSpots and BranchLinks
- Show Spot Id in TrackScheme based on User settings
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mastodon.