示例#1
0
#!/usr/bin/python

from cremi import Annotations, Volume
from cremi.io import CremiFile
import numpy as np
import random

# Open a file for reading
file = CremiFile("example.hdf", "r")

# Check the content of the datafile
print "Has raw: " + str(file.has_raw())
print "Has neuron ids: " + str(file.has_neuron_ids())
print "Has clefts: " + str(file.has_clefts())
print "Has annotations: " + str(file.has_annotations())

# Read everything there is.
#
# If you are using the padded versions of the datasets (where raw is larger to 
# provide more context), the offsets of neuron_ids, clefts, and annotations tell 
# you where they are placed in nm relative to (0,0,0) of the raw volume.
#
# In other words, neuron_ids, clefts, and annotations are exactly the same 
# between the padded and unpadded versions, except for the offset attribute.
raw = file.read_raw()
neuron_ids = file.read_neuron_ids()
clefts = file.read_clefts()
annotations = file.read_annotations()

print "Read raw: " + str(raw) + \
    ", resolution " + str(raw.resolution) + \
示例#2
0
文件: Data.py 项目: tmquan/cremi3d
def Reading(filename, isTest=False):
    # # Read the data into dataset
    # print "Filename: ", filename
    # # with h5py.File('sample_A_20160501.hdf', 'r') as f:
    # with h5py.File(filename, 'r') as f:
    # print f["volumes"]
    # imageDataSet = f["volumes/raw"][:]
    # labelDataSet = f["volumes/labels/neuron_ids"][:]

    # imageDataSet = imageDataSet.astype(np.float32)
    # labelDataSet = labelDataSet.astype(np.float32)
    # return imageDataSet, labelDataSet
    file = CremiFile(filename, "r")
    print filename
    # Check the content of the datafile
    print "Has raw			: " + str(file.has_raw())
    print "Has neuron ids	: " + str(file.has_neuron_ids())
    print "Has clefts		: " + str(file.has_clefts())
    print "Has annotations	: " + str(file.has_annotations())

    # Read everything there is.
    #
    # If you are using the padded versions of the datasets (where raw is larger to
    # provide more context), the offsets of neuron_ids, clefts, and annotations tell
    # you where they are placed in nm relative to (0,0,0) of the raw volume.
    #
    # In other words, neuron_ids, clefts, and annotations are exactly the same
    # between the padded and unpadded versions, except for the offset attribute.
    raw = file.read_raw()
    if not isTest:
        neuron_ids = file.read_neuron_ids()
        clefts = file.read_clefts()
        annotations = file.read_annotations()


    print "Read raw: 	"  + str(raw) + \
       ", resolution "  + str(raw.resolution) + \
       ", offset 	"  + str(raw.offset) + \
      ("" if raw.comment == None else ", comment \"" + raw.comment + "\"")
    if not isTest:
        print "Read neuron_ids: "  + str(neuron_ids) + \
           ", resolution "     + str(neuron_ids.resolution) + \
           ", offset " + str(neuron_ids.offset) + \
          ("" if neuron_ids.comment == None else ", comment \"" + neuron_ids.comment + "\"")
        # neuron_ids.offset will contain the starting point of neuron_ids inside the raw volume.
        # Note that these numbers are given in nm.

        # print "Read clefts: " + str(clefts) + \
        # ", resolution " + str(clefts.resolution) + \
        # ", offset " + str(clefts.offset) + \
        # ("" if clefts.comment == None else ", comment \"" + clefts.comment + "\"")

        # print "Read annotations:"
        # for (id, type, location) in zip(annotations.ids(), annotations.types(), annotations.locations()):
        # print str(id) + " of type " + type + " at " + str(np.array(location)+np.array(annotations.offset))
        # print "Pre- and post-synaptic partners:"
        # for (pre, post) in annotations.pre_post_partners:
        # print str(pre) + " -> " + str(post)
    with h5py.File(filename, 'r') as f:
        print f["volumes"]
        imageDataSet = f["volumes/raw"][:]
        if not isTest:
            labelDataSet = f["volumes/labels/neuron_ids"][:]
    imageDataSet = imageDataSet.astype(np.float32)
    if not isTest:
        labelDataSet = labelDataSet.astype(np.float32)
    if not isTest:
        return imageDataSet, labelDataSet
    return imageDataSet
示例#3
0
#!/usr/bin/python

from cremi import Annotations, Volume
from cremi.io import CremiFile
import numpy as np
import random

# Open a file for reading
file = CremiFile("example.hdf", "r")

# Check the content of the datafile
print "Has raw: " + str(file.has_raw())
print "Has neuron ids: " + str(file.has_neuron_ids())
print "Has clefts: " + str(file.has_clefts())
print "Has annotations: " + str(file.has_annotations())

# Read everything there is.
#
# If you are using the padded versions of the datasets (where raw is larger to
# provide more context), the offsets of neuron_ids, clefts, and annotations tell
# you where they are placed in nm relative to (0,0,0) of the raw volume.
#
# In other words, neuron_ids, clefts, and annotations are exactly the same
# between the padded and unpadded versions, except for the offset attribute.
raw = file.read_raw()
neuron_ids = file.read_neuron_ids()
clefts = file.read_clefts()
annotations = file.read_annotations()

print "Read raw: " + str(raw) + \
    ", resolution " + str(raw.resolution) + \