XBRAIN Demo Notebook

Last Update: 10/12/2017


In [1]:
# Imports 
import numpy as np
import scipy.io as sio
from PIL import Image
import ndparse as ndp
import xbrain
import time
import os
import intern
from intern.remote.dvid import DVIDRemote

Initialize

  • Path of files
  • Parameters for ilastik
  • Parameters for cell detection
  • Parameters for blood vessel segmentation

In [2]:
# Set folder where data is stored
current_dir = os.path.abspath(os.getcwd())
folder = next(os.walk('.'))[1][0]
#print(os.path.exists(folder)) # testing

# ilastik parameters
classifier_file = folder + '/xbrain_vessel_seg_v7.ilp'
#print(classifier_file)                 # testing
#print(os.path.exists(classifier_file)) # testing

# testing ground truth
image_file = folder + '/V3_imgdata_gt.npy'
#print(image_file)                 # testing
#print(os.path.exists(image_file)) # testing


# Dictate the processing power
ram_size = 4000 # 4000 MB                                                                            
no_of_threads = 8 # 8 threads

# Cell detection parameters                                                                         
cell_probability_threshold  = 0.2
stopping_criterion = 0.47
initial_template_size = 18
dilation_size = 8
max_no_cells = 500

# Vessel segmentation parameters                                                                    
vessel_probability_threshold = .68
dilation_size = 3
minimum_size = 4000

Load in the data


In [18]:
# load data

dvid = DVIDRemote({ "protocol": "http",
                    "host": "172.19.248.41:8000/",
                  })
chan = dvid.get_channel('a3afee0bf807466c9b7c3b0bbfd1acbd','grayscale')
print(chan)
input_data = dvid.get_cutout(chan,0,[0,2],[0,64],[390,454])#DVID here -- np.load(image_file)

# plot the 50th slice
#ndp.plot(input_data, 50)

# get the shape of the data
print(input_data.shape) # (200, 200, 200)


eneuro17/grayscale/
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-18-85bcb6837455> in <module>()
      6 chan = dvid.get_channel('eneuro17','grayscale')
      7 print(chan)
----> 8 input_data = dvid.get_cutout(chan,0,[0,2],[0,64],[390,454])#DVID here -- np.load(image_file)
      9 
     10 # plot the 50th slice

~/.local/lib/python3.6/site-packages/intern-0.9.6-py3.6.egg/intern/remote/dvid/remote.py in get_cutout(self, chan, res, xspan, yspan, zspan)
     93                                 (KeyError): if given invalid version.
     94 		"""
---> 95                 return DvidResource.get_cutout(api, chan, res, xspan, yspan, zspan)
     96 
     97         def get_cutoutI(self, chan, res, xspan, yspan, zspan):

~/.local/lib/python3.6/site-packages/intern-0.9.6-py3.6.egg/intern/resource/dvid/resource.py in get_cutout(self, api, chan, res, xspan, yspan, zspan)
    108 
    109         #Specifies the 3 dimensional shape of the numpy array of the size given by the user
--> 110         volumeOut =  block.reshape(zpix,ypix,xpix)
    111 
    112         #Returns a 3-dimensional numpy array to the user

ValueError: cannot reshape array of size 127 into shape (64,64,2)

Ingest data and classifer into ilastik


In [87]:
# Compute time required for processing
start = time.time()

# Process the data to probability maps
probability_maps = xbrain.classify_pixel(input_data, classifier_file, threads=no_of_threads, ram=ram_size)

end = time.time()
print("\nElapsed time: %f minutes" % ((end - start)/60))


WARNING default_config.py(243): ResourceWarning: unclosed file <_io.TextIOWrapper name='/opt/conda/ilastik-meta/ilastik/ilastik/ilastik_logging/logging_config.json' mode='r' encoding='UTF-8'>
INFO ilastik_main: Starting ilastik from "/opt/conda".
INFO ilastik_main: Starting ilastik from "/opt/conda".
Starting ilastik from "/opt/conda".
INFO ilastik_main: Resetting lazyflow thread pool with 8 threads.
INFO ilastik_main: Resetting lazyflow thread pool with 8 threads.
INFO ilastik_main: Configuring lazyflow RAM limit to 3.9GiB
INFO ilastik_main: Configuring lazyflow RAM limit to 3.9GiB
INFO lazyflow.utility.memory: Available memory set to 3.9GiB
INFO lazyflow.utility.memory: Available memory set to 3.9GiB
INFO ilastik.shell.projectManager: Opening Project: public_data/xbrain_vessel_seg_v7.ilp
INFO ilastik.shell.projectManager: Opening Project: public_data/xbrain_vessel_seg_v7.ilp
WARNING bind.py(27): DeprecationWarning: inspect.getargspec() is deprecated, use inspect.signature() or inspect.getfullargspec()
input_data.shape (200, 200, 200)
label_names, label_colors, probability_colors ['Background', 'Blood Vessel', 'Cell Body'] [(255, 0, 0), (0, 255, 0), (0, 0, 255)] [(255, 0, 0), (0, 255, 0), (0, 0, 255)]
INFO ilastik.applets.batchProcessing.batchProcessingApplet: Exporting to in-memory array.
INFO ilastik.applets.batchProcessing.batchProcessingApplet: Exporting to in-memory array.
INFO lazyflow.utility.bigRequestStreamer: Estimated RAM usage per pixel is 216.0B * safety factor (2.0)
INFO lazyflow.utility.bigRequestStreamer: Estimated RAM usage per pixel is 216.0B * safety factor (2.0)
INFO lazyflow.utility.bigRequestStreamer: determining blockshape assuming available_ram is 2.9GiB, split between 8 threads
INFO lazyflow.utility.bigRequestStreamer: determining blockshape assuming available_ram is 2.9GiB, split between 8 threads
INFO lazyflow.utility.bigRequestStreamer: Chose blockshape: (97, 97, 96, 3)
INFO lazyflow.utility.bigRequestStreamer: Chose blockshape: (97, 97, 96, 3)
INFO lazyflow.utility.bigRequestStreamer: Estimated RAM usage per block is 372.1MiB
INFO lazyflow.utility.bigRequestStreamer: Estimated RAM usage per block is 372.1MiB
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 00% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 01% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 01% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 01% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 01% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 06% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 07% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 07% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 07% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 07% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 08% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 09% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 09% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 09% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 09% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 10% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 10% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 10% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 10% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 11% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 12% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 13% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 13% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 13% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 13% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 14% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 14% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 14% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 14% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 15% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 15% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 19% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 19% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 19% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 19% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 24% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 24% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 24% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 24% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 25% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 26% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 26% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 26% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 26% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 27% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 27% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 27% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 27% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 28% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 28% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 28% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 28% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 29% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 30% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 30% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 30% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 30% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 31% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 31% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 31% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 31% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 35% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 35% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 36% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 36% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 36% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 36% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 37% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 37% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 37% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 37% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 38% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 39% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 40% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 40% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 40% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 40% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 41% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 41% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 41% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 41% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 42% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 42% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 46% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 47% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 47% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 47% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 47% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 48% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 48% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 48% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 48% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 49% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 49% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 49% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 49% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 50% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 50% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 50% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 50% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 52% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 52% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 57% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 57% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 57% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 57% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 62% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 62% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 63% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 63% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 64% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 64% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 65% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 65% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 68% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 68% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 71% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 71% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 74% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 74% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 76% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 76% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 79% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 79% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 82% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 82% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 85% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 87% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 85% (Computing features)DEBUG lazyflow.operators.classifierOperators: Training: 90% (Computing features)

DEBUG lazyflow.operators.classifierOperators: Training: 87% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 90% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 93% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 93% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 95% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 95% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 100% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training: 100% (Computing features)
DEBUG lazyflow.operators.classifierOperators: Training new classifier: Parallel Vigra Random Forest Factory (100 trees total)
DEBUG lazyflow.operators.classifierOperators: Training new classifier: Parallel Vigra Random Forest Factory (100 trees total)
INFO lazyflow.classifiers.parallelVigraRfLazyflowClassifier: Training took, 76.951454 seconds
INFO lazyflow.classifiers.parallelVigraRfLazyflowClassifier: Training took, 76.951454 seconds
INFO lazyflow.classifiers.parallelVigraRfLazyflowClassifier: Training complete. Average OOB: 0.004711156803620543
INFO lazyflow.classifiers.parallelVigraRfLazyflowClassifier: Training complete. Average OOB: 0.004711156803620543
DEBUG lazyflow.operators.classifierOperators: Training: 100% (Complete)
DEBUG lazyflow.operators.classifierOperators: Training: 100% (Complete)
DEBUG lazyflow.operators.classifierOperators: Features took 0.462364 seconds, Prediction took 5.166527 seconds for roi: [0, 194, 96, 0] : [97, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.462364 seconds, Prediction took 5.166527 seconds for roi: [0, 194, 96, 0] : [97, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.112315 seconds, Prediction took 1.996415 seconds for roi: [0, 194, 192, 0] : [97, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.112315 seconds, Prediction took 1.996415 seconds for roi: [0, 194, 192, 0] : [97, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 6.613042 seconds, Prediction took 39.659538 seconds for roi: [0, 0, 192, 0] : [97, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 6.613042 seconds, Prediction took 39.659538 seconds for roi: [0, 0, 192, 0] : [97, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 7.403248 seconds, Prediction took 38.923568 seconds for roi: [97, 0, 0, 0] : [194, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 7.403248 seconds, Prediction took 38.923568 seconds for roi: [97, 0, 0, 0] : [194, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.656612 seconds, Prediction took 2.751093 seconds for roi: [97, 0, 192, 0] : [194, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.656612 seconds, Prediction took 2.751093 seconds for roi: [97, 0, 192, 0] : [194, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 11.446755 seconds, Prediction took 74.249256 seconds for roi: [0, 0, 96, 0] : [97, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 11.446755 seconds, Prediction took 74.249256 seconds for roi: [0, 0, 96, 0] : [97, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 8.202614 seconds, Prediction took 81.712184 seconds for roi: [0, 0, 0, 0] : [97, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 8.202614 seconds, Prediction took 81.712184 seconds for roi: [0, 0, 0, 0] : [97, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 6.489501 seconds, Prediction took 40.753256 seconds for roi: [97, 0, 96, 0] : [194, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 6.489501 seconds, Prediction took 40.753256 seconds for roi: [97, 0, 96, 0] : [194, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.656944 seconds, Prediction took 3.156047 seconds for roi: [97, 194, 0, 0] : [194, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.656944 seconds, Prediction took 3.156047 seconds for roi: [97, 194, 0, 0] : [194, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.95721 seconds, Prediction took 3.145358 seconds for roi: [97, 194, 96, 0] : [194, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.95721 seconds, Prediction took 3.145358 seconds for roi: [97, 194, 96, 0] : [194, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.182204 seconds, Prediction took 0.212055 seconds for roi: [97, 194, 192, 0] : [194, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.182204 seconds, Prediction took 0.212055 seconds for roi: [97, 194, 192, 0] : [194, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.961157 seconds, Prediction took 2.780955 seconds for roi: [194, 0, 0, 0] : [200, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.961157 seconds, Prediction took 2.780955 seconds for roi: [194, 0, 0, 0] : [200, 97, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.014618 seconds, Prediction took 2.483491 seconds for roi: [194, 0, 96, 0] : [200, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.014618 seconds, Prediction took 2.483491 seconds for roi: [194, 0, 96, 0] : [200, 97, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.130745 seconds, Prediction took 0.180711 seconds for roi: [194, 0, 192, 0] : [200, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.130745 seconds, Prediction took 0.180711 seconds for roi: [194, 0, 192, 0] : [200, 97, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 7.668929 seconds, Prediction took 46.631891 seconds for roi: [97, 97, 0, 0] : [194, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 7.668929 seconds, Prediction took 46.631891 seconds for roi: [97, 97, 0, 0] : [194, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.72389 seconds, Prediction took 3.630623 seconds for roi: [194, 97, 0, 0] : [200, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.72389 seconds, Prediction took 3.630623 seconds for roi: [194, 97, 0, 0] : [200, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.204491 seconds, Prediction took 0.285064 seconds for roi: [194, 97, 192, 0] : [200, 194, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.204491 seconds, Prediction took 0.285064 seconds for roi: [194, 97, 192, 0] : [200, 194, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.153668 seconds, Prediction took 0.172545 seconds for roi: [194, 194, 0, 0] : [200, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.153668 seconds, Prediction took 0.172545 seconds for roi: [194, 194, 0, 0] : [200, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.3811689999999999 seconds, Prediction took 3.434207 seconds for roi: [194, 97, 96, 0] : [200, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 1.3811689999999999 seconds, Prediction took 3.434207 seconds for roi: [194, 97, 96, 0] : [200, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.066417 seconds, Prediction took 0.023978 seconds for roi: [194, 194, 192, 0] : [200, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.066417 seconds, Prediction took 0.023978 seconds for roi: [194, 194, 192, 0] : [200, 200, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.123421 seconds, Prediction took 0.260477 seconds for roi: [194, 194, 96, 0] : [200, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 0.123421 seconds, Prediction took 0.260477 seconds for roi: [194, 194, 96, 0] : [200, 200, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 45.973719 seconds, Prediction took 80.184277 seconds for roi: [0, 97, 0, 0] : [97, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 45.973719 seconds, Prediction took 80.184277 seconds for roi: [0, 97, 0, 0] : [97, 194, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 121.178586 seconds, Prediction took 2.972022 seconds for roi: [0, 97, 192, 0] : [97, 194, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 121.178586 seconds, Prediction took 2.972022 seconds for roi: [0, 97, 192, 0] : [97, 194, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 120.902669 seconds, Prediction took 2.9984070000000003 seconds for roi: [0, 194, 0, 0] : [97, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 120.902669 seconds, Prediction took 2.9984070000000003 seconds for roi: [0, 194, 0, 0] : [97, 200, 96, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 81.755613 seconds, Prediction took 45.021161 seconds for roi: [0, 97, 96, 0] : [97, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 81.755613 seconds, Prediction took 45.021161 seconds for roi: [0, 97, 96, 0] : [97, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 13.3868 seconds, Prediction took 34.698372 seconds for roi: [97, 97, 96, 0] : [194, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 13.3868 seconds, Prediction took 34.698372 seconds for roi: [97, 97, 96, 0] : [194, 194, 192, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 34.137253 seconds, Prediction took 1.9132479999999998 seconds for roi: [97, 97, 192, 0] : [194, 194, 200, 3]
DEBUG lazyflow.operators.classifierOperators: Features took 34.137253 seconds, Prediction took 1.9132479999999998 seconds for roi: [97, 97, 192, 0] : [194, 194, 200, 3]
predictions.dtype, predictions.shape float32 (200, 200, 200, 3)
DONE.

Elapsed time: 4.041957 minutes

Display the results of ilastik


In [89]:
# pull down the coorisponding matricies
cell_prob_map = probability_maps[:, :, :, 2]
vessel_prob_map = probability_maps[:, :, :, 1]

print("cell_prob_map shape", cell_prob_map.shape)
ndp.plot(cell_prob_map, slice=50, cmap1='jet', alpha=0.5)


print("vessel_prob_map shape", vessel_prob_map.shape)
ndp.plot(vessel_prob_map, slice=50, cmap1='jet')


cell_prob_map shape (200, 200, 200)
vessel_prob_map shape (200, 200, 200)

Running different package for testing new algorithm


In [90]:
# reload packages for testing new algorithms
# import importlib
# importlib.reload(xbrain)

# Compute time required for processing
start = time.time()

# cell detection
centroids, cell_map = xbrain.detect_cells(cell_prob_map, cell_probability_threshold, stopping_criterion, initial_template_size, dilation_size, max_no_cells)
print(centroids)

end = time.time()
print("\nElapsed time: %f minutes" % ((end - start)/60))


WARNING _bootstrap.py(205): ImportWarning: can't resolve package from __spec__ or __package__, falling back on __name__ and __path__
Iteration remaining =  499 Correlation =  [[ 0.95168388]]
Iteration remaining =  489 Correlation =  [[ 0.91369426]]
Iteration remaining =  479 Correlation =  [[ 0.88610667]]
Iteration remaining =  469 Correlation =  [[ 0.86151671]]
Iteration remaining =  459 Correlation =  [[ 0.85078424]]
Iteration remaining =  449 Correlation =  [[ 0.84014732]]
Iteration remaining =  439 Correlation =  [[ 0.82743627]]
Iteration remaining =  429 Correlation =  [[ 0.81597131]]
Iteration remaining =  419 Correlation =  [[ 0.80801356]]
Iteration remaining =  409 Correlation =  [[ 0.79984474]]
Iteration remaining =  399 Correlation =  [[ 0.78171575]]
Iteration remaining =  389 Correlation =  [[ 0.76294184]]
Iteration remaining =  379 Correlation =  [[ 0.74776268]]
Iteration remaining =  369 Correlation =  [[ 0.72482878]]
Iteration remaining =  359 Correlation =  [[ 0.70334792]]
Iteration remaining =  349 Correlation =  [[ 0.69173962]]
Iteration remaining =  339 Correlation =  [[ 0.67132163]]
Iteration remaining =  329 Correlation =  [[ 0.6294108]]
Iteration remaining =  319 Correlation =  [[ 0.60435903]]
Iteration remaining =  309 Correlation =  [[ 0.56057721]]
Iteration remaining =  299 Correlation =  [[ 0.54622215]]
Iteration remaining =  289 Correlation =  [[ 0.52344346]]
Iteration remaining =  279 Correlation =  [[ 0.49780256]]
Iteration remaining =  269 Correlation =  [[ 0.47445858]]
Cell Detection is done
[[  12.           53.          182.            0.95168388]
 [ 157.           45.           91.            0.9488734 ]
 [  17.           55.           73.            0.93695861]
 [  75.           64.          147.            0.93604696]
 [ 166.           97.           20.            0.93418789]
 [  78.           67.           21.            0.93325639]
 [ 138.           17.           16.            0.93160027]
 [  50.           66.          116.            0.92342353]
 [ 180.           60.           67.            0.91539407]
 [  86.          147.          148.            0.91476911]
 [ 178.           42.          115.            0.91369426]
 [ 126.           33.           67.            0.90950239]
 [ 168.          117.          103.            0.90849125]
 [ 109.           33.           49.            0.9077906 ]
 [  84.           50.           13.            0.90565288]
 [  61.           78.           28.            0.90070063]
 [ 129.          174.          162.            0.89882964]
 [  47.          104.           38.            0.89395303]
 [ 192.           84.           17.            0.89375401]
 [ 107.           79.          116.            0.88733679]
 [ 143.           83.           14.            0.88610667]
 [  22.          153.           19.            0.88525873]
 [  65.          186.           89.            0.8842954 ]
 [  87.           83.           92.            0.88342351]
 [ 153.           89.          140.            0.88256764]
 [  56.          158.          156.            0.87451035]
 [ 184.          126.          187.            0.86917591]
 [  39.          151.          108.            0.86369431]
 [ 181.          119.          145.            0.86266714]
 [ 138.           91.           95.            0.8620621 ]
 [ 119.          154.           29.            0.86151671]
 [ 160.          126.          161.            0.85955811]
 [  26.           14.          106.            0.85906452]
 [  28.          177.           30.            0.85816884]
 [  36.           36.          146.            0.85710186]
 [  25.           29.          173.            0.85675555]
 [  55.          142.           86.            0.85406452]
 [   8.          160.          154.            0.85390127]
 [ 104.           19.          117.            0.85337579]
 [ 136.          186.           46.            0.85263538]
 [ 118.           45.          134.            0.85078424]
 [ 156.           10.           31.            0.85039014]
 [ 173.           99.          147.            0.84972531]
 [ 150.          126.           87.            0.8493551 ]
 [ 144.           64.          147.            0.84827632]
 [   8.          114.           47.            0.84684718]
 [ 152.           96.          121.            0.84479696]
 [ 133.           53.          106.            0.84463769]
 [ 168.          130.          180.            0.84350318]
 [ 125.           99.           46.            0.84016716]
 [ 132.           22.           38.            0.84014732]
 [ 151.          186.          186.            0.83855498]
 [  85.           59.           72.            0.83664411]
 [  95.            6.           18.            0.8365804 ]
 [ 184.           41.           91.            0.83387738]
 [  87.          113.           92.            0.83271897]
 [  38.           78.          160.            0.8298527 ]
 [ 135.          125.           31.            0.82984477]
 [ 114.          130.            8.            0.82972133]
 [  67.          100.          108.            0.8281011 ]
 [ 170.          152.           70.            0.82743627]
 [  12.            8.          168.            0.82501596]
 [  16.          113.          147.            0.82449442]
 [  66.           38.           90.            0.82426351]
 [  18.            9.           20.            0.82404459]
 [  96.          139.           84.            0.82367039]
 [ 180.          173.           56.            0.82362258]
 [ 139.          124.          125.            0.8234992 ]
 [   8.          176.           50.            0.820207  ]
 [  16.          184.           99.            0.81984073]
 [  69.           51.          170.            0.81597131]
 [  72.          170.           67.            0.81488055]
 [   8.          153.           96.            0.81468952]
 [  96.           49.          183.            0.81421977]
 [ 180.          171.          118.            0.81304538]
 [  23.          137.           53.            0.81164008]
 [  43.           63.            8.            0.81097132]
 [ 167.          103.           76.            0.8107245 ]
 [  45.          123.           92.            0.80923569]
 [ 152.          161.          127.            0.80901277]
 [  81.          172.           36.            0.80801356]
 [  84.          134.           66.            0.80772299]
 [ 108.           60.          107.            0.80767912]
 [ 108.          116.          188.            0.8063615 ]
 [  87.           96.          128.            0.80574042]
 [  35.           60.           92.            0.80558521]
 [ 179.           43.          182.            0.80277067]
 [ 188.          192.          158.            0.80152464]
 [  84.          159.            8.            0.80075234]
 [  33.           41.          124.            0.80059314]
 [  56.          192.          159.            0.79984474]
 [  79.          115.            8.            0.7959435 ]
 [ 134.          120.          174.            0.79377788]
 [ 126.           55.           11.            0.79017913]
 [   7.           15.           57.            0.79006767]
 [  42.          178.           98.            0.78765923]
 [ 146.           11.          167.            0.78508359]
 [  20.           48.          151.            0.78486866]
 [  91.           28.           60.            0.78368229]
 [ 177.          135.           64.            0.78230888]
 [ 137.           66.          191.            0.78171575]
 [  67.          133.           31.            0.78097135]
 [  95.          168.           81.            0.78076029]
 [  61.          117.          178.            0.77951431]
 [  54.           44.           40.            0.77567673]
 [ 106.          108.           45.            0.77369428]
 [  78.           83.           62.            0.77232885]
 [  40.          193.           70.            0.76599127]
 [ 109.          173.           38.            0.76476508]
 [ 157.           70.           35.            0.76447845]
 [  37.          110.          154.            0.76294184]
 [ 175.           62.            9.            0.76266319]
 [ 180.           66.          146.            0.76122212]
 [ 116.          192.          181.            0.7611903 ]
 [ 108.           57.          128.            0.75646496]
 [ 166.          185.          107.            0.75608283]
 [  32.           72.           37.            0.75450236]
 [ 128.          149.           90.            0.75253975]
 [  89.          179.           12.            0.7511664 ]
 [ 154.           11.           19.            0.74959791]
 [  65.          145.          122.            0.74776268]
 [ 142.          193.          113.            0.74381363]
 [ 191.          112.          187.            0.74157643]
 [ 194.           10.           86.            0.73810506]
 [ 117.           61.          160.            0.73513538]
 [ 159.          166.           76.            0.73274684]
 [  52.          194.           92.            0.7319029 ]
 [ 131.           87.          191.            0.73132962]
 [ 193.          153.           31.            0.72922367]
 [  40.           74.          116.            0.72898883]
 [ 175.          131.           87.            0.72482878]
 [   8.          139.          118.            0.72333997]
 [   9.          190.           31.            0.72259951]
 [  35.          129.          158.            0.72048968]
 [ 134.           24.          166.            0.71958196]
 [   7.          131.          186.            0.71571654]
 [ 148.          186.          170.            0.71541798]
 [ 101.          134.          138.            0.71306926]
 [  65.          194.          183.            0.71070462]
 [  44.          141.          138.            0.70396495]
 [  75.          128.           51.            0.70334792]
 [ 144.           84.           36.            0.70311701]
 [  42.           92.          140.            0.69875795]
 [  26.            8.          157.            0.69842756]
 [  64.          124.          101.            0.69786227]
 [ 148.           10.          193.            0.6965127 ]
 [  97.          171.          108.            0.69570059]
 [ 142.          191.           89.            0.69550955]
 [  97.            8.           47.            0.69536221]
 [ 175.          165.           41.            0.69189882]
 [  94.          113.           30.            0.69173962]
 [ 149.          132.          139.            0.69089568]
 [  40.           10.            5.            0.69009155]
 [  51.           99.          174.            0.68993628]
 [ 137.          110.           58.            0.68693864]
 [ 161.          152.          134.            0.68484873]
 [ 195.          141.          100.            0.68157244]
 [ 170.           26.          143.            0.68133754]
 [ 146.           84.          151.            0.67826033]
 [   8.          150.           48.            0.67352706]
 [ 142.          160.           67.            0.67132163]
 [  95.          195.          125.            0.66791004]
 [  94.          134.          123.            0.66669184]
 [  13.          174.          133.            0.66459394]
 [  69.           91.           82.            0.65728104]
 [ 194.          120.          162.            0.64690286]
 [   8.          103.          173.            0.64678347]
 [  64.           19.          143.            0.64238054]
 [ 127.          134.           92.            0.64077234]
 [  79.          160.           60.            0.64071256]
 [ 126.            9.          168.            0.6294108 ]
 [  31.          106.          106.            0.62874603]
 [ 160.           31.            4.            0.62644506]
 [ 182.          195.           87.            0.61454618]
 [  43.          134.          105.            0.61292595]
 [ 187.          151.            6.            0.61162019]
 [ 158.          147.           58.            0.61100316]
 [  87.          140.          112.            0.60947454]
 [  77.           76.          194.            0.6084156 ]
 [  75.          196.          119.            0.60578424]
 [ 108.          102.           22.            0.60435903]
 [  25.          128.            6.            0.60410827]
 [  96.          195.          148.            0.60203421]
 [  66.           51.            6.            0.600824  ]
 [ 175.          194.           34.            0.59742433]
 [  18.          163.           56.            0.59701431]
 [  89.           25.           50.            0.58889729]
 [  21.           68.          194.            0.5750199 ]
 [ 123.           67.          102.            0.57133359]
 [  80.          175.            5.            0.56263936]
 [  42.           16.          196.            0.56057721]
 [ 189.          194.           13.            0.55930734]
 [   4.          114.          108.            0.55701834]
 [  55.          104.           75.            0.55648887]
 [   5.           71.           52.            0.55586779]
 [  56.          107.          104.            0.55505574]
 [   6.          147.           11.            0.55483282]
 [ 128.           23.           16.            0.55356288]
 [  63.           91.          177.            0.55053741]
 [ 192.            5.          107.            0.54811704]
 [  64.          101.          197.            0.54622215]
 [ 139.          124.          193.            0.54526275]
 [  22.           83.          188.            0.54464573]
 [ 115.          196.           44.            0.54359472]
 [  92.          186.          176.            0.54035825]
 [ 129.          139.          196.            0.54022288]
 [   5.          117.          148.            0.53437102]
 [ 175.           47.          174.            0.52721733]
 [ 102.          196.           92.            0.52522296]
 [  41.          192.           51.            0.52455413]
 [  50.          180.            4.            0.52344346]
 [  85.           94.          121.            0.52134156]
 [ 184.            4.          133.            0.51175159]
 [  30.           29.            4.            0.51149285]
 [ 162.          173.          159.            0.50619823]
 [ 159.          192.            6.            0.50583994]
 [ 136.           88.          106.            0.505418  ]
 [ 142.          101.          122.            0.50068468]
 [  26.          175.           23.            0.49946257]
 [ 160.          118.          101.            0.49912024]
 [  74.          195.           51.            0.49780256]
 [ 132.          195.           82.            0.49447054]
 [  84.          165.           32.            0.48992836]
 [  20.          182.          111.            0.48929536]
 [  33.          143.          145.            0.48859078]
 [ 184.          113.          179.            0.48837975]
 [ 111.           58.           14.            0.48816481]
 [  71.          110.          177.            0.48660827]
 [ 134.          188.           38.            0.48623806]
 [  97.          127.           91.            0.47779459]
 [ 123.          109.          158.            0.47445858]
 [  18.            8.           32.            0.4731887 ]
 [ 137.           13.           11.            0.47169983]
 [  27.           62.          102.            0.47125399]]

In [91]:
# find vessels

vessel_map = xbrain.segment_vessels(vessel_prob_map, vessel_probability_threshold, dilation_size, minimum_size)

Display results of new algorithm


In [95]:
# show results

print("Vessel Segmentation")
ndp.plot(input_data, vessel_map, slice = 50, alpha = 0.5)

print("Cell Segmentation")
ndp.plot(input_data, cell_map, slice = 50, alpha = 0.5)


WARNING assess.py(299): MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
WARNING __init__.py(917): UserWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
WARNING rcsetup.py(152): UserWarning: axes.hold is deprecated, will be removed in 3.0
Vessel Segmentation
Cell Segmentation

Thank you for going throught the XBRAIN tutorial! For more information about the lab, please visit: dyerlab.gatech.edu


In [ ]: