<jupyter_start><jupyter_text>For later use...per Prof. Voytek's<jupyter_code>data_dir = '../data/luna16/'
img_filename = '1.3.6.1.4.1.14519.5.2.1.6279.6001.112767175295249119452142211437.mhd'
itk_img = sitk.ReadImage(data_dir + img_filename) 

# img_filename1 = '1.3.6.1.4.1.14519.5.2.1.6279.6001.278660284797073139172446973682.mhd'
# itk_img1 = sitk.ReadImage(data_dir + img_filename1) 
# scan_df = class1_df[ (class1_df.seriesuid == '1.3.6.1.4.1.14519.5.2.1.6279.6001.112767175295249119452142211437') ]
# scan_df
img_np_array = sitk.GetArrayFromImage(itk_img)
#img_np_array.shape
def plot_lung_mesh(image, threshold=-200):
    p1 = img_np_array.transpose(2,1,0)
    p1 = p1[:,:,::-1]
    verts, faces, normals, values = measure.marching_cubes_lewiner(p1, -200)
    
    fig = plt.figure(figsize=(10, 10))
    ax = fig.add_subplot(111, projection='3d')
    mesh = Poly3DCollection(verts[faces], alpha=0.1)
    face_color = [0.5, 0.5, 1]
    mesh.set_facecolor(face_color)

    ax.add_collection3d(mesh)

    ax.set_xlabel("x-axis, range 0 to 512")
    ax.set_ylabel("y-axis, range 0 to 512")
    ax.set_zlabel("z-axis, range 0 to 117")
    ax.set_xlim(0, p1.shape[0])
    ax.set_ylim(0, p1.shape[1])
    ax.set_zlim(0, p1.shape[2])

    plt.title("Reconstructed CT scan mesh-view for Nodule centriods")
    plt.show()

plot_lung_mesh(img_np_array, -200);
#%timeit plot_lung_mesh(img_np_array, -200);<jupyter_output><empty_output><jupyter_text>Todo - To parallize later from HDFS data sets (AL)<jupyter_code># from joblib import Parallel, delayed
# def joblib_loop():
#     Parallel(n_jobs=4)(delayed(plot_3d)(i) for i in images)

# %timeit joblib_loop()

# for i in range(0, len(df)):
#     print df.iloc[i]['c1'], df.iloc[i]['c2']<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16004540295119182, 'fraction_numerical': 0.1282633371169126, 'mean_word_length': 4.544025157232705, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '151998', 'license': 'MIT', 'n_tokens_mistral': 895, 'n_tokens_neox': 779, 'n_words': 116, 'path': 'src/EDA/class1_heatmap_mesh_viewer.ipynb', 'repo_name': 'kshannon/lung-nodule-localization', 'size': '1762'}