Search in sources :

Example 1 with IntArray

use of net.imglib2.img.basictypeaccess.array.IntArray in project vcell by virtualcell.

the class ImportSBMLCommand method run.

@Override
public void run() {
    // Read SBML document
    SBMLDocument document = null;
    try {
        document = SBMLReader.read(file);
    } catch (XMLStreamException | IOException e) {
        e.printStackTrace();
    }
    // Get SBML geometry
    SpatialModelPlugin modelPlugin = (SpatialModelPlugin) document.getModel().getPlugin("spatial");
    Geometry geometry = modelPlugin.getGeometry();
    SampledField sampledField = geometry.getListOfSampledFields().get(0);
    // Parse pixel values to int
    String[] imgStringArray = sampledField.getSamples().split(" ");
    int[] imgArray = new int[imgStringArray.length];
    for (int i = 0; i < imgStringArray.length; i++) {
        imgArray[i] = Integer.parseInt(imgStringArray[i]);
    }
    // Create the image and display
    int width = sampledField.getNumSamples1();
    int height = sampledField.getNumSamples2();
    ArrayImg<UnsignedIntType, IntArray> img = ArrayImgs.unsignedInts(imgArray, width, height);
    displayService.createDisplay(img);
}
Also used : SBMLDocument(org.sbml.jsbml.SBMLDocument) SpatialModelPlugin(org.sbml.jsbml.ext.spatial.SpatialModelPlugin) IOException(java.io.IOException) Geometry(org.sbml.jsbml.ext.spatial.Geometry) XMLStreamException(javax.xml.stream.XMLStreamException) IntArray(net.imglib2.img.basictypeaccess.array.IntArray) SampledField(org.sbml.jsbml.ext.spatial.SampledField) UnsignedIntType(net.imglib2.type.numeric.integer.UnsignedIntType)

Aggregations

IOException (java.io.IOException)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 IntArray (net.imglib2.img.basictypeaccess.array.IntArray)1 UnsignedIntType (net.imglib2.type.numeric.integer.UnsignedIntType)1 SBMLDocument (org.sbml.jsbml.SBMLDocument)1 Geometry (org.sbml.jsbml.ext.spatial.Geometry)1 SampledField (org.sbml.jsbml.ext.spatial.SampledField)1 SpatialModelPlugin (org.sbml.jsbml.ext.spatial.SpatialModelPlugin)1