Data collection tutorials can be found at https://github.com/openconnectome/ndio-demos.git. Detailed documentation also exists at https://github.com/openconnectome/ndio. Data collected from ndio and saved as a numpy file with the name 'nXp_data.npy' can be run through our watershed process when placed in the same folder .
The data used for our watershed process can be found at https://www.dropbox.com/s/95rsvfdhkiodq1x/nXp_data.npy?dl=0. The rest of the necessary programs are located on our github repo at https://github.com/Connectomics-Classes/NeuroXplorer to compare results.
The complete watershed file can be found in our github repo in the folder 'testing' under the name 'gala_shed.py'. As long as the 'nxp_data.np' file is in the same folder, the program can be immediately run from terminal using the command 'python gala_shed.py'. The following steps deconstruct the program on a very basic level.
First launch python and import the following packages. If an error states that a certain module does not exist simply use 'pip install insert package name here' in order to download the package. Detailed instructions on using pip can be found at https://pip.pypa.io/en/stable/installing/.
In [ ]:
### Watershed segmentation imports
from gala import classify, morpho, features, agglo, evaluate as ev, optimized
import numpy as np
from skimage.morphology import closing
from skimage.morphology import binary_dilation
from skimage.morphology import binary_erosion
from skimage.filters.rank import threshold
import matplotlib.pyplot as plt
###
print "Done importing packages"
In [ ]:
# Gather images from nXp_data.npy file
print "Getting images"
membrane_images = np.load('nXp_data.npy')
# Assigning one image from array to variable pre_image
pre_image = 255 * membrane_images[0]
min_seed_size = 5 #2
connectivity = 2 #2
smooth_thresh = 0.02 #0.02
In [ ]:
########
# Watershed segmentation
########
print "Running watershed"
ws_train = morpho.watershed(pre_image,
connectivity=connectivity, smooth_thresh=smooth_thresh,
override_skimage=1,minimum_seed_size=min_seed_size) + 1
#ws_train = ws_train
fig, axes = plt.subplots(ncols=1, figsize=(8, 2.7), sharex=True, sharey=True, subplot_kw={'adjustable':'box-forced'})
ax0 = axes
ax0.imshow(ws_train)#, cmap=plt.cm.spectral, interpolation='nearest')
ax0.set_title('Overlapping objects')
In [ ]:
fig.subplots_adjust(hspace=0.01, wspace=0.01, top=0.9, bottom=0, left=0,
right=1)
plt.show()