Train 3d nodule detector with LUNA16 dataset


In [1]:
INPUT_DIR = '../../input/lung-cancer/nodule-detector/'
INPUT_DATASET_LUNGS = '../../input/kaggle-bowl/step4-312/data-centered-rotated-312-212-312.h5'
OUTPUT_DIR = '../../output/lung-cancer/10/'
IMAGE_DIMS = (50,50,50,1)

In [2]:
%matplotlib inline
import numpy as np
import pandas as pd
import h5py
import matplotlib.pyplot as plt
import sklearn
import os
import glob

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

Look for some nodules manually

Select a lung with nodules


In [ ]:

Perform nodule scan


In [ ]:
net = cnn.net_nodule3d_swethasubramanian(IMAGE_DIMS)
model = cnn.prepare_cnn_model(net, OUTPUT_DIR, model_file=INPUT_DIR + 'nodule-classifier.tfl')

Extract nodules from lung database

Prepare output dir


In [19]:
utils.mkdirs(OUTPUT_DIR, recreate=True)
modules.logging.setup_file_logger(OUTPUT_DIR + 'out.log')
logger.info('Dir ' + OUTPUT_DIR + ' created')


2017-03-20 02:02:19,651 INFO Dir ../../output/lung-cancer/01/ created

Do some sort for windowing scan over the scans


In [ ]:
with h5py.File(INPUT_DATASET_LUNGS, 'r') as lungs_hdf5:
    X = lungs_hdf5['X']
    Y = lungs_hdf5['Y']
    logger.info('X shape ' + str(X.shape))
    logger.info('Y shape ' + str(Y.shape))

    nodules_hdf5, x_ds, y_ds = create_xy_datasets(OUTPUT_DIR, 'lung-nodules-tmp', IMAGE_DIMS, 999999)
    with hdf5:
        #TODO: IDENTIFY NODULES
        
logger.info("Nodule extraction finished!")

Show extraction statistics


In [ ]:
logger.info('Extraction statistics')
#TODO