test = CremiFile('test.hdf', 'r') truth = CremiFile('groundtruth.hdf', 'r') neuron_ids_evaluation = NeuronIds(truth.read_neuron_ids()) (voi_split, voi_merge) = neuron_ids_evaluation.voi(test.read_neuron_ids()) adapted_rand = neuron_ids_evaluation.adapted_rand(test.read_neuron_ids()) print "Neuron IDs" print "==========" print "\tvoi split : " + str(voi_split) print "\tvoi merge : " + str(voi_merge) print "\tadapted RAND: " + str(adapted_rand) clefts_evaluation = Clefts(test.read_clefts(), truth.read_clefts()) false_positive_count = clefts_evaluation.count_false_positives() false_negative_count = clefts_evaluation.count_false_negatives() false_positive_stats = clefts_evaluation.acc_false_positives() false_negative_stats = clefts_evaluation.acc_false_negatives() print "Clefts" print "======" print "\tfalse positives: " + str(false_positive_count) print "\tfalse negatives: " + str(false_negative_count) print "\tdistance to ground truth: " + str(false_positive_stats) print "\tdistance to proposal : " + str(false_negative_stats)
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
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) + \ ", offset " + str(raw.offset) + \ ("" if raw.comment == None else ", comment \"" + raw.comment + "\"") 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 + "\"") print "Read clefts: " + str(clefts) + \ ", resolution " + str(clefts.resolution) + \ ", offset " + str(clefts.offset) + \