In [1]:
IMAGE_DIMS = (50, 34, 50, 1)

INPUT_FOLDER = '../../input/sample_images/'
OUTPUT_FOLDER = '../../output/step10/'

DATASET_NAME_SUFFIX = '-centered-rotated'
PATIENTS_FILE = '../../input/sample_dummy_submission.csv'
CNN_MODEL_FILE = '../../output/train-local/tf-checkpoint-best7826'

_model = None

In [2]:
import csv
import h5py
import numpy as np # linear algebra
import os
import logging

import tflearn
from tflearn.layers.core import *
from tflearn.layers.conv import *
from tflearn.data_utils import *
from tflearn.layers.normalization import *
from tflearn.layers.estimator import regression

from modules.logging import logger
import modules.logging
import modules.lungprepare as lungprepare
import modules.utils as utils
import modules.cnn as cnn
from modules.utils import Timer

In [3]:
def get_patient_ids(patients_file):
    patients = []
    
    file = csv.DictReader(open(patients_file))
    for row in file:
        p = row['id']
        patients.append(p)
    logger.info('found {} patients for prediction'.format(len(patients)))
    
    return patients

In [4]:
def start_processing(input_dir, patients_file, cnn_model_file, max_patients, image_dims, output_dir):
    logger.info('Predicting patients. ' + ' max_patients='+ str(max_patients) + ' input_dir=' + input_dir + ' output_dir=' + output_dir)
    
    logger.info('Preparing output dir')
    utils.mkdirs(output_dir, dirs=['images'], recreate=False)

    modules.logging.setup_file_logger(output_dir + 'out.log')

    network = cnn.net_simplest1(image_dims)
    model = cnn.prepare_cnn_model(network, output_dir, model_file=cnn_model_file)
    
    logger.info('Collect patient ids for analysis')
    patient_ids = get_patient_ids(patients_file)
    total_patients = len(patient_ids)
    logger.debug('Found ' + str(total_patients) + ' patients')

    count = 0
    for patient_id in patient_ids:
        if(count>(max_patients-1)):
            break

        y = cnn.predict_patient(input_dir, patient_id, image_dims, model, output_dir)
        logger.info("Prediction for patient " + patient_id + ' is ' + str(y))

        count = count + 1

In [5]:
logger.info('==== PROCESSING PREDICTION ====')
start_processing(INPUT_FOLDER, PATIENTS_FILE, CNN_MODEL_FILE, 9, IMAGE_DIMS, OUTPUT_FOLDER)
logger.info('==== ALL DONE ====')


2017-02-22 02:59:05,816 INFO ==== PROCESSING PREDICTION ====
2017-02-22 02:59:05,817 INFO Predicting patients.  max_patients=9 input_dir=../../input/sample_images/ output_dir=../../output/step10/
2017-02-22 02:59:05,818 INFO Preparing output dir
2017-02-22 02:59:05,936 INFO Prepare CNN
2017-02-22 02:59:05,937 INFO Preparing output dir
2017-02-22 02:59:05,938 INFO Load engine...
2017-02-22 02:59:07,438 INFO Load previous training...
2017-02-22 02:59:08,102 INFO Collect patient ids for analysis
2017-02-22 02:59:08,103 INFO found 19 patients for prediction
2017-02-22 02:59:08,104 DEBUG Found 19 patients
2017-02-22 02:59:08,105 INFO >>> Predict patient_id 0de72529c30fe642bc60dcb75c87f6bd
2017-02-22 02:59:08,106 INFO Loading pre-processed images for patient
2017-02-22 02:59:08,108 DEBUG Patient image not found in cache
2017-02-22 02:59:08,109 INFO > [started] Preparing patient scan image volume. patient_id=0de72529c30fe642bc60dcb75c87f6bd...
2017-02-22 02:59:08,110 INFO > [started] load_scan ../../input/sample_images/0de72529c30fe642bc60dcb75c87f6bd...
2017-02-22 02:59:08,513 INFO > [done]    load_scan ../../input/sample_images/0de72529c30fe642bc60dcb75c87f6bd (403.694 ms)
2017-02-22 02:59:09,187 INFO > [started] resample...
2017-02-22 02:59:22,604 INFO > [done]    resample (13417.435 ms)
2017-02-22 02:59:22,612 INFO > [started] segment_lung_mask...
/root/workspace/kaggle-lung-cancer-detection/modules/lungprepare.py:118: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  body = find_next_valid(labels[round(s[0]*0.6), round(s[1]*0.5)], bgs=bgs)
2017-02-22 02:59:26,700 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
/root/workspace/kaggle-lung-cancer-detection/modules/lungprepare.py:123: VisibleDeprecationWarning: using a non-integer number instead of an integer will result in an error in the future
  lung_label = largest_label_volume(labels[s[0]*0.2:s[0]*0.8, s[1]*0.25:s[1]*0.75, s[2]*0.25:s[2]*0.75], bgs=bgs)
2017-02-22 02:59:26,758 DEBUG lung_label6
2017-02-22 02:59:26,759 DEBUG remove non lung structures
2017-02-22 02:59:27,637 DEBUG fill_lung_structures
2017-02-22 02:59:27,983 INFO > [done]    segment_lung_mask (5371.131 ms)
2017-02-22 02:59:28,027 INFO > [started] apply lung mask to image volume...
2017-02-22 02:59:28,240 INFO > [done]    apply lung mask to image volume (212.331 ms)
2017-02-22 02:59:28,241 INFO > [started] rotate image for optimal pose...
2017-02-22 02:59:32,329 INFO > [done]    rotate image for optimal pose (4087.844 ms)
2017-02-22 02:59:32,330 INFO > [started] resize image volume to 50x34x50...
2017-02-22 02:59:32,386 DEBUG ratio=0.162679425837
/opt/conda/lib/python3.5/site-packages/scipy/ndimage/interpolation.py:568: UserWarning: From scipy 0.13.0, the output shape of zoom() is calculated with round() instead of int() - for these inputs the size of the returned array has changed.
  "the returned array has changed.", UserWarning)
2017-02-22 02:59:32,921 INFO > [done]    resize image volume to 50x34x50 (590.778 ms)
2017-02-22 02:59:32,922 INFO > [started] translate to center...
/opt/conda/lib/python3.5/site-packages/numpy/core/numeric.py:301: FutureWarning: in the future, full((50, 34, 50), 0) will return an array of dtype('int64')
  format(shape, fill_value, array(fill_value).dtype), FutureWarning)
2017-02-22 02:59:32,967 INFO > [done]    translate to center (44.765 ms)
2017-02-22 02:59:32,968 INFO > [started] pixel normalization...
2017-02-22 02:59:32,969 DEBUG mean pixels=0.571559403361
2017-02-22 02:59:32,970 INFO > [done]    pixel normalization (2.155 ms)
2017-02-22 02:59:32,977 DEBUG Storing patient image in cache
2017-02-22 02:59:32,979 INFO > [done]    Preparing patient scan image volume. patient_id=0de72529c30fe642bc60dcb75c87f6bd (24870.075 ms)
2017-02-22 02:59:32,981 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 02:59:33,522 INFO PATIENT 0de72529c30fe642bc60dcb75c87f6bd PREDICT=[[0.904554009437561, 0.095445916056633]]
2017-02-22 02:59:38,623 INFO > [done]    Predicting result on CNN (forward) (5642.188 ms)
2017-02-22 02:59:38,628 INFO Prediction for patient 0de72529c30fe642bc60dcb75c87f6bd is [[0.904554009437561, 0.095445916056633]]
2017-02-22 02:59:38,628 INFO >>> Predict patient_id 0ddeb08e9c97227853422bd71a2a695e
2017-02-22 02:59:38,629 INFO Loading pre-processed images for patient
2017-02-22 02:59:38,630 DEBUG Patient image not found in cache
2017-02-22 02:59:38,631 INFO > [started] Preparing patient scan image volume. patient_id=0ddeb08e9c97227853422bd71a2a695e...
2017-02-22 02:59:38,632 INFO > [started] load_scan ../../input/sample_images/0ddeb08e9c97227853422bd71a2a695e...
2017-02-22 02:59:39,221 INFO > [done]    load_scan ../../input/sample_images/0ddeb08e9c97227853422bd71a2a695e (589.150 ms)
2017-02-22 02:59:39,507 INFO > [started] resample...
2017-02-22 03:00:04,376 INFO > [done]    resample (24868.766 ms)
2017-02-22 03:00:04,381 INFO > [started] segment_lung_mask...
2017-02-22 03:00:10,901 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:00:11,031 DEBUG lung_label59
2017-02-22 03:00:11,032 DEBUG remove non lung structures
2017-02-22 03:00:12,774 DEBUG fill_lung_structures
2017-02-22 03:00:13,403 INFO > [done]    segment_lung_mask (9022.801 ms)
2017-02-22 03:00:13,441 INFO > [started] apply lung mask to image volume...
2017-02-22 03:00:13,853 INFO > [done]    apply lung mask to image volume (411.796 ms)
2017-02-22 03:00:13,854 INFO > [started] rotate image for optimal pose...
2017-02-22 03:00:21,708 INFO > [done]    rotate image for optimal pose (7854.306 ms)
2017-02-22 03:00:21,709 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:00:21,814 DEBUG ratio=0.14409221902
2017-02-22 03:00:22,771 INFO > [done]    resize image volume to 50x34x50 (1061.652 ms)
2017-02-22 03:00:22,772 INFO > [started] translate to center...
2017-02-22 03:00:22,809 INFO > [done]    translate to center (36.042 ms)
2017-02-22 03:00:22,810 INFO > [started] pixel normalization...
2017-02-22 03:00:22,811 DEBUG mean pixels=0.582669655462
2017-02-22 03:00:22,812 INFO > [done]    pixel normalization (2.247 ms)
2017-02-22 03:00:22,818 DEBUG Storing patient image in cache
2017-02-22 03:00:22,820 INFO > [done]    Preparing patient scan image volume. patient_id=0ddeb08e9c97227853422bd71a2a695e (44188.787 ms)
2017-02-22 03:00:22,821 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:00:23,234 INFO PATIENT 0ddeb08e9c97227853422bd71a2a695e PREDICT=[[0.8958240151405334, 0.10417598485946655]]
2017-02-22 03:00:28,263 INFO > [done]    Predicting result on CNN (forward) (5442.184 ms)
2017-02-22 03:00:28,265 INFO Prediction for patient 0ddeb08e9c97227853422bd71a2a695e is [[0.8958240151405334, 0.10417598485946655]]
2017-02-22 03:00:28,266 INFO >>> Predict patient_id 0d19f1c627df49eb223771c28548350e
2017-02-22 03:00:28,267 INFO Loading pre-processed images for patient
2017-02-22 03:00:28,268 DEBUG Patient image not found in cache
2017-02-22 03:00:28,269 INFO > [started] Preparing patient scan image volume. patient_id=0d19f1c627df49eb223771c28548350e...
2017-02-22 03:00:28,270 INFO > [started] load_scan ../../input/sample_images/0d19f1c627df49eb223771c28548350e...
2017-02-22 03:00:28,800 INFO > [done]    load_scan ../../input/sample_images/0d19f1c627df49eb223771c28548350e (530.192 ms)
2017-02-22 03:00:29,126 INFO > [started] resample...
2017-02-22 03:00:53,133 INFO > [done]    resample (24006.148 ms)
2017-02-22 03:00:53,139 INFO > [started] segment_lung_mask...
2017-02-22 03:00:58,670 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:00:58,797 DEBUG lung_label189
2017-02-22 03:00:58,798 DEBUG remove non lung structures
2017-02-22 03:01:00,583 DEBUG fill_lung_structures
2017-02-22 03:01:01,225 INFO > [done]    segment_lung_mask (8086.023 ms)
2017-02-22 03:01:01,242 INFO > [started] apply lung mask to image volume...
2017-02-22 03:01:01,638 INFO > [done]    apply lung mask to image volume (395.352 ms)
2017-02-22 03:01:01,639 INFO > [started] rotate image for optimal pose...
2017-02-22 03:01:09,408 INFO > [done]    rotate image for optimal pose (7769.645 ms)
2017-02-22 03:01:09,410 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:01:09,514 DEBUG ratio=0.151975683891
2017-02-22 03:01:10,280 INFO > [done]    resize image volume to 50x34x50 (870.630 ms)
2017-02-22 03:01:10,282 INFO > [started] translate to center...
2017-02-22 03:01:10,318 INFO > [done]    translate to center (35.751 ms)
2017-02-22 03:01:10,320 INFO > [started] pixel normalization...
2017-02-22 03:01:10,321 DEBUG mean pixels=0.580777789916
2017-02-22 03:01:10,323 INFO > [done]    pixel normalization (3.139 ms)
2017-02-22 03:01:10,329 DEBUG Storing patient image in cache
2017-02-22 03:01:10,331 INFO > [done]    Preparing patient scan image volume. patient_id=0d19f1c627df49eb223771c28548350e (42062.421 ms)
2017-02-22 03:01:10,334 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:01:10,766 INFO PATIENT 0d19f1c627df49eb223771c28548350e PREDICT=[[0.8983542323112488, 0.1016458049416542]]
2017-02-22 03:01:15,977 INFO > [done]    Predicting result on CNN (forward) (5643.563 ms)
2017-02-22 03:01:15,979 INFO Prediction for patient 0d19f1c627df49eb223771c28548350e is [[0.8983542323112488, 0.1016458049416542]]
2017-02-22 03:01:15,980 INFO >>> Predict patient_id 0c0de3749d4fe175b7a5098b060982a1
2017-02-22 03:01:15,981 INFO Loading pre-processed images for patient
2017-02-22 03:01:15,982 DEBUG Patient image not found in cache
2017-02-22 03:01:15,982 INFO > [started] Preparing patient scan image volume. patient_id=0c0de3749d4fe175b7a5098b060982a1...
2017-02-22 03:01:15,983 INFO > [started] load_scan ../../input/sample_images/0c0de3749d4fe175b7a5098b060982a1...
2017-02-22 03:01:16,548 INFO > [done]    load_scan ../../input/sample_images/0c0de3749d4fe175b7a5098b060982a1 (565.110 ms)
2017-02-22 03:01:16,742 INFO > [started] resample...
2017-02-22 03:01:35,853 INFO > [done]    resample (19110.989 ms)
2017-02-22 03:01:35,859 INFO > [started] segment_lung_mask...
2017-02-22 03:01:40,216 DEBUG bgs[0, 1, 1, 6, 6, 1, 1, 6, 6, 2]
2017-02-22 03:01:40,332 DEBUG lung_label35
2017-02-22 03:01:40,333 DEBUG remove non lung structures
2017-02-22 03:01:41,725 DEBUG fill_lung_structures
2017-02-22 03:01:42,261 INFO > [done]    segment_lung_mask (6401.981 ms)
2017-02-22 03:01:42,274 INFO > [started] apply lung mask to image volume...
2017-02-22 03:01:42,569 INFO > [done]    apply lung mask to image volume (294.883 ms)
2017-02-22 03:01:42,570 INFO > [started] rotate image for optimal pose...
2017-02-22 03:01:48,619 INFO > [done]    rotate image for optimal pose (6049.471 ms)
2017-02-22 03:01:48,620 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:01:48,703 DEBUG ratio=0.161290322581
2017-02-22 03:01:49,273 INFO > [done]    resize image volume to 50x34x50 (652.718 ms)
2017-02-22 03:01:49,274 INFO > [started] translate to center...
2017-02-22 03:01:49,308 INFO > [done]    translate to center (33.323 ms)
2017-02-22 03:01:49,309 INFO > [started] pixel normalization...
2017-02-22 03:01:49,310 DEBUG mean pixels=0.589882630252
2017-02-22 03:01:49,311 INFO > [done]    pixel normalization (2.402 ms)
2017-02-22 03:01:49,317 DEBUG Storing patient image in cache
2017-02-22 03:01:49,320 INFO > [done]    Preparing patient scan image volume. patient_id=0c0de3749d4fe175b7a5098b060982a1 (33337.612 ms)
2017-02-22 03:01:49,321 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:01:49,762 INFO PATIENT 0c0de3749d4fe175b7a5098b060982a1 PREDICT=[[0.8896860480308533, 0.11031387001276016]]
2017-02-22 03:01:54,636 INFO > [done]    Predicting result on CNN (forward) (5315.064 ms)
2017-02-22 03:01:54,645 INFO Prediction for patient 0c0de3749d4fe175b7a5098b060982a1 is [[0.8896860480308533, 0.11031387001276016]]
2017-02-22 03:01:54,646 INFO >>> Predict patient_id 0ca943d821204ceb089510f836a367fd
2017-02-22 03:01:54,647 INFO Loading pre-processed images for patient
2017-02-22 03:01:54,648 DEBUG Patient image not found in cache
2017-02-22 03:01:54,648 INFO > [started] Preparing patient scan image volume. patient_id=0ca943d821204ceb089510f836a367fd...
2017-02-22 03:01:54,649 INFO > [started] load_scan ../../input/sample_images/0ca943d821204ceb089510f836a367fd...
2017-02-22 03:01:55,608 INFO > [done]    load_scan ../../input/sample_images/0ca943d821204ceb089510f836a367fd (958.951 ms)
2017-02-22 03:01:56,040 INFO > [started] resample...
2017-02-22 03:02:10,237 INFO > [done]    resample (14197.004 ms)
2017-02-22 03:02:10,242 INFO > [started] segment_lung_mask...
2017-02-22 03:02:13,211 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:02:13,284 DEBUG lung_label21
2017-02-22 03:02:13,285 DEBUG remove non lung structures
2017-02-22 03:02:14,298 DEBUG fill_lung_structures
2017-02-22 03:02:14,645 INFO > [done]    segment_lung_mask (4402.293 ms)
2017-02-22 03:02:14,654 INFO > [started] apply lung mask to image volume...
2017-02-22 03:02:14,864 INFO > [done]    apply lung mask to image volume (209.939 ms)
2017-02-22 03:02:14,865 INFO > [started] rotate image for optimal pose...
2017-02-22 03:02:18,947 INFO > [done]    rotate image for optimal pose (4081.928 ms)
2017-02-22 03:02:18,948 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:02:19,004 DEBUG ratio=0.175257731959
2017-02-22 03:02:19,422 INFO > [done]    resize image volume to 50x34x50 (473.958 ms)
2017-02-22 03:02:19,423 INFO > [started] translate to center...
2017-02-22 03:02:19,458 INFO > [done]    translate to center (34.205 ms)
2017-02-22 03:02:19,459 INFO > [started] pixel normalization...
2017-02-22 03:02:19,460 DEBUG mean pixels=0.58975905042
2017-02-22 03:02:19,461 INFO > [done]    pixel normalization (2.312 ms)
2017-02-22 03:02:19,464 DEBUG Storing patient image in cache
2017-02-22 03:02:19,466 INFO > [done]    Preparing patient scan image volume. patient_id=0ca943d821204ceb089510f836a367fd (24817.690 ms)
2017-02-22 03:02:19,467 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:02:19,873 INFO PATIENT 0ca943d821204ceb089510f836a367fd PREDICT=[[0.8944178223609924, 0.10558219999074936]]
2017-02-22 03:02:24,611 INFO > [done]    Predicting result on CNN (forward) (5144.125 ms)
2017-02-22 03:02:24,617 INFO Prediction for patient 0ca943d821204ceb089510f836a367fd is [[0.8944178223609924, 0.10558219999074936]]
2017-02-22 03:02:24,618 INFO >>> Predict patient_id 0d06d764d3c07572074d468b4cff954f
2017-02-22 03:02:24,619 INFO Loading pre-processed images for patient
2017-02-22 03:02:24,621 DEBUG Patient image not found in cache
2017-02-22 03:02:24,622 INFO > [started] Preparing patient scan image volume. patient_id=0d06d764d3c07572074d468b4cff954f...
2017-02-22 03:02:24,624 INFO > [started] load_scan ../../input/sample_images/0d06d764d3c07572074d468b4cff954f...
2017-02-22 03:02:27,040 INFO > [done]    load_scan ../../input/sample_images/0d06d764d3c07572074d468b4cff954f (2416.071 ms)
2017-02-22 03:02:27,732 INFO > [started] resample...
2017-02-22 03:03:00,876 INFO > [done]    resample (33143.882 ms)
2017-02-22 03:03:00,891 INFO > [started] segment_lung_mask...
2017-02-22 03:03:06,619 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:03:06,750 DEBUG lung_label3
2017-02-22 03:03:06,751 DEBUG remove non lung structures
2017-02-22 03:03:08,598 DEBUG fill_lung_structures
2017-02-22 03:03:09,313 INFO > [done]    segment_lung_mask (8422.636 ms)
2017-02-22 03:03:09,331 INFO > [started] apply lung mask to image volume...
2017-02-22 03:03:09,757 INFO > [done]    apply lung mask to image volume (426.184 ms)
2017-02-22 03:03:09,758 INFO > [started] rotate image for optimal pose...
2017-02-22 03:03:17,772 INFO > [done]    rotate image for optimal pose (8013.372 ms)
2017-02-22 03:03:17,773 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:03:17,881 DEBUG ratio=0.155963302752
2017-02-22 03:03:18,461 INFO > [done]    resize image volume to 50x34x50 (687.852 ms)
2017-02-22 03:03:18,462 INFO > [started] translate to center...
2017-02-22 03:03:18,492 INFO > [done]    translate to center (30.895 ms)
2017-02-22 03:03:18,493 INFO > [started] pixel normalization...
2017-02-22 03:03:18,495 DEBUG mean pixels=0.61085912605
2017-02-22 03:03:18,496 INFO > [done]    pixel normalization (2.279 ms)
2017-02-22 03:03:18,507 DEBUG Storing patient image in cache
2017-02-22 03:03:18,508 INFO > [done]    Preparing patient scan image volume. patient_id=0d06d764d3c07572074d468b4cff954f (53886.636 ms)
2017-02-22 03:03:18,510 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:03:18,921 INFO PATIENT 0d06d764d3c07572074d468b4cff954f PREDICT=[[0.8555088043212891, 0.14449121057987213]]
2017-02-22 03:03:23,809 INFO > [done]    Predicting result on CNN (forward) (5299.533 ms)
2017-02-22 03:03:23,823 INFO Prediction for patient 0d06d764d3c07572074d468b4cff954f is [[0.8555088043212891, 0.14449121057987213]]
2017-02-22 03:03:23,824 INFO >>> Predict patient_id 0d941a3ad6c889ac451caf89c46cb92a
2017-02-22 03:03:23,825 INFO Loading pre-processed images for patient
2017-02-22 03:03:23,826 DEBUG Patient image not found in cache
2017-02-22 03:03:23,827 INFO > [started] Preparing patient scan image volume. patient_id=0d941a3ad6c889ac451caf89c46cb92a...
2017-02-22 03:03:23,828 INFO > [started] load_scan ../../input/sample_images/0d941a3ad6c889ac451caf89c46cb92a...
2017-02-22 03:03:25,039 INFO > [done]    load_scan ../../input/sample_images/0d941a3ad6c889ac451caf89c46cb92a (1211.218 ms)
2017-02-22 03:03:25,353 INFO > [started] resample...
2017-02-22 03:03:38,594 INFO > [done]    resample (13240.775 ms)
2017-02-22 03:03:38,601 INFO > [started] segment_lung_mask...
2017-02-22 03:03:41,081 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:03:41,133 DEBUG lung_label10
2017-02-22 03:03:41,134 DEBUG remove non lung structures
2017-02-22 03:03:41,898 DEBUG fill_lung_structures
2017-02-22 03:03:42,194 INFO > [done]    segment_lung_mask (3593.079 ms)
2017-02-22 03:03:42,202 INFO > [started] apply lung mask to image volume...
2017-02-22 03:03:42,377 INFO > [done]    apply lung mask to image volume (175.917 ms)
2017-02-22 03:03:42,379 INFO > [started] rotate image for optimal pose...
2017-02-22 03:03:45,988 INFO > [done]    rotate image for optimal pose (3608.958 ms)
2017-02-22 03:03:45,989 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:03:46,040 DEBUG ratio=0.166666666667
2017-02-22 03:03:46,527 INFO > [done]    resize image volume to 50x34x50 (537.232 ms)
2017-02-22 03:03:46,528 INFO > [started] translate to center...
2017-02-22 03:03:46,560 INFO > [done]    translate to center (31.668 ms)
2017-02-22 03:03:46,561 INFO > [started] pixel normalization...
2017-02-22 03:03:46,562 DEBUG mean pixels=0.585094537815
2017-02-22 03:03:46,563 INFO > [done]    pixel normalization (2.123 ms)
2017-02-22 03:03:46,572 DEBUG Storing patient image in cache
2017-02-22 03:03:46,573 INFO > [done]    Preparing patient scan image volume. patient_id=0d941a3ad6c889ac451caf89c46cb92a (22746.425 ms)
2017-02-22 03:03:46,575 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:03:47,000 INFO PATIENT 0d941a3ad6c889ac451caf89c46cb92a PREDICT=[[0.8928446769714355, 0.10715530067682266]]
2017-02-22 03:03:52,222 INFO > [done]    Predicting result on CNN (forward) (5646.973 ms)
2017-02-22 03:03:52,223 INFO Prediction for patient 0d941a3ad6c889ac451caf89c46cb92a is [[0.8928446769714355, 0.10715530067682266]]
2017-02-22 03:03:52,224 INFO >>> Predict patient_id 0c59313f52304e25d5a7dcf9877633b1
2017-02-22 03:03:52,225 INFO Loading pre-processed images for patient
2017-02-22 03:03:52,226 DEBUG Patient image not found in cache
2017-02-22 03:03:52,226 INFO > [started] Preparing patient scan image volume. patient_id=0c59313f52304e25d5a7dcf9877633b1...
2017-02-22 03:03:52,227 INFO > [started] load_scan ../../input/sample_images/0c59313f52304e25d5a7dcf9877633b1...
2017-02-22 03:03:53,353 INFO > [done]    load_scan ../../input/sample_images/0c59313f52304e25d5a7dcf9877633b1 (1125.813 ms)
2017-02-22 03:03:53,808 INFO > [started] resample...
2017-02-22 03:04:18,232 INFO > [done]    resample (24424.013 ms)
2017-02-22 03:04:18,239 INFO > [started] segment_lung_mask...
2017-02-22 03:04:23,724 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:04:23,843 DEBUG lung_label68
2017-02-22 03:04:23,844 DEBUG remove non lung structures
2017-02-22 03:04:25,526 DEBUG fill_lung_structures
2017-02-22 03:04:26,212 INFO > [done]    segment_lung_mask (7973.059 ms)
2017-02-22 03:04:26,228 INFO > [started] apply lung mask to image volume...
2017-02-22 03:04:26,618 INFO > [done]    apply lung mask to image volume (390.733 ms)
2017-02-22 03:04:26,620 INFO > [started] rotate image for optimal pose...
2017-02-22 03:04:33,688 INFO > [done]    rotate image for optimal pose (7068.311 ms)
2017-02-22 03:04:33,689 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:04:33,785 DEBUG ratio=0.147186147186
2017-02-22 03:04:34,370 INFO > [done]    resize image volume to 50x34x50 (680.681 ms)
2017-02-22 03:04:34,371 INFO > [started] translate to center...
2017-02-22 03:04:34,403 INFO > [done]    translate to center (31.949 ms)
2017-02-22 03:04:34,404 INFO > [started] pixel normalization...
2017-02-22 03:04:34,405 DEBUG mean pixels=0.613682344538
2017-02-22 03:04:34,406 INFO > [done]    pixel normalization (2.289 ms)
2017-02-22 03:04:34,414 DEBUG Storing patient image in cache
2017-02-22 03:04:34,416 INFO > [done]    Preparing patient scan image volume. patient_id=0c59313f52304e25d5a7dcf9877633b1 (42189.528 ms)
2017-02-22 03:04:34,417 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:04:34,857 INFO PATIENT 0c59313f52304e25d5a7dcf9877633b1 PREDICT=[[0.8619314432144165, 0.1380685418844223]]
2017-02-22 03:04:39,718 INFO > [done]    Predicting result on CNN (forward) (5300.193 ms)
2017-02-22 03:04:39,725 INFO Prediction for patient 0c59313f52304e25d5a7dcf9877633b1 is [[0.8619314432144165, 0.1380685418844223]]
2017-02-22 03:04:39,726 INFO >>> Predict patient_id 0c37613214faddf8701ca41e6d43f56e
2017-02-22 03:04:39,727 INFO Loading pre-processed images for patient
2017-02-22 03:04:39,728 DEBUG Patient image not found in cache
2017-02-22 03:04:39,728 INFO > [started] Preparing patient scan image volume. patient_id=0c37613214faddf8701ca41e6d43f56e...
2017-02-22 03:04:39,729 INFO > [started] load_scan ../../input/sample_images/0c37613214faddf8701ca41e6d43f56e...
2017-02-22 03:04:40,780 INFO > [done]    load_scan ../../input/sample_images/0c37613214faddf8701ca41e6d43f56e (1051.384 ms)
2017-02-22 03:04:41,079 INFO > [started] resample...
2017-02-22 03:05:00,730 INFO > [done]    resample (19651.003 ms)
2017-02-22 03:05:00,737 INFO > [started] segment_lung_mask...
2017-02-22 03:05:05,185 DEBUG bgs[0, 1, 1, 1, 1, 1, 1, 1, 1, 2]
2017-02-22 03:05:05,288 DEBUG lung_label32
2017-02-22 03:05:05,290 DEBUG remove non lung structures
2017-02-22 03:05:06,729 DEBUG fill_lung_structures
2017-02-22 03:05:07,243 INFO > [done]    segment_lung_mask (6506.287 ms)
2017-02-22 03:05:07,257 INFO > [started] apply lung mask to image volume...
2017-02-22 03:05:07,581 INFO > [done]    apply lung mask to image volume (323.404 ms)
2017-02-22 03:05:07,582 INFO > [started] rotate image for optimal pose...
2017-02-22 03:05:13,842 INFO > [done]    rotate image for optimal pose (6260.321 ms)
2017-02-22 03:05:13,843 INFO > [started] resize image volume to 50x34x50...
2017-02-22 03:05:13,929 DEBUG ratio=0.158139534884
2017-02-22 03:05:14,519 INFO > [done]    resize image volume to 50x34x50 (675.747 ms)
2017-02-22 03:05:14,520 INFO > [started] translate to center...
2017-02-22 03:05:14,556 INFO > [done]    translate to center (36.355 ms)
2017-02-22 03:05:14,557 INFO > [started] pixel normalization...
2017-02-22 03:05:14,559 DEBUG mean pixels=0.578048344538
2017-02-22 03:05:14,560 INFO > [done]    pixel normalization (2.609 ms)
2017-02-22 03:05:14,566 DEBUG Storing patient image in cache
2017-02-22 03:05:14,570 INFO > [done]    Preparing patient scan image volume. patient_id=0c37613214faddf8701ca41e6d43f56e (34841.795 ms)
2017-02-22 03:05:14,572 INFO > [started] Predicting result on CNN (forward)...
2017-02-22 03:05:14,984 INFO PATIENT 0c37613214faddf8701ca41e6d43f56e PREDICT=[[0.9049966931343079, 0.09500331431627274]]
2017-02-22 03:05:19,930 INFO > [done]    Predicting result on CNN (forward) (5357.772 ms)
2017-02-22 03:05:19,931 INFO Prediction for patient 0c37613214faddf8701ca41e6d43f56e is [[0.9049966931343079, 0.09500331431627274]]
2017-02-22 03:05:19,932 INFO ==== ALL DONE ====

In [ ]:


In [ ]: