In [2]:
from matplotlib.pyplot import imshow
import matplotlib.pyplot as plt
%matplotlib inline
import cPickle as pickle
import os; import sys; sys.path.append('..')
import gp
import gp.nets as nets
import numpy as np
import mahotas as mh
import h5py
In [3]:
# create a hdf5 file for the full cylinder volume
import glob
golds = np.zeros((300,2048,2048), dtype=np.uint64)
path = '/home/d/data/cylinderNEW/'
for z in range(0,300):
gold = sorted(glob.glob(os.path.join(path, 'gold', '*'+str(z)+'.png')))
gold = mh.imread(gold[0])
gold_single = np.zeros((gold.shape[0], gold.shape[1]), dtype=np.uint64)
gold_single[:, :] = gold[:,:,0]*256*256 + gold[:,:,1]*256 + gold[:,:,2]
golds[z] = gold_single
with h5py.File('/home/d/data/cylinder_gold.h5', 'w') as hf:
hf.create_dataset('volumes/labels/neuron_ids', data=golds)
In [13]:
# images = np.zeros((300,2048,2048), dtype=np.uint8)
masks = np.zeros((300,2048,2048), dtype=np.bool)
for z in range(0,300):
mask = sorted(glob.glob(os.path.join(path, 'mask', '*'+str(z)+'.png')))
# image, prob, mask, gold, rhoana = gp.Util.read_section('/home/d/data/cylinderNEW/', z)
mask = mh.imread(mask[0]).astype(np.bool)
print z
masks[z] = mask
with h5py.File('/home/d/data/cylinder_mask.h5', 'w') as hf:
hf.create_dataset('volumes/raw', data=masks)
In [8]:
with h5py.File('/home/d/data/raveler_dojo/stack.h5', 'r') as hf:
list_of_names = []
hf.visit(list_of_names.append)
print hf['body_index'].value
In [14]:
test = np.load('/tmp/IPMLBtrain.npz')
In [15]:
targets = np.load('/tmp/IPMLBtrain_targets.npz')
In [17]:
test['rgba'].shape
Out[17]:
In [83]:
imshow(test['rgba'][43][0], cmap='gray')
Out[83]:
In [82]:
imshow(test['rgba'][43][1])
Out[82]:
In [81]:
imshow(test['rgba'][43][2])
Out[81]:
In [80]:
imshow(test['rgba'][43][3])
Out[80]:
In [79]:
targets['targets'][43]
Out[79]:
In [ ]: