Commit fa135035 authored by sjromuel's avatar sjromuel
Browse files

d

parent e4fa4640
......@@ -253,8 +253,8 @@ class dbscan_clustering(BaseNetwork):
for i in range(len(cluster)):
patientslices.append([cluster[i][1:]])
#print(patientslices)
if i < 25:
fig.add_subplot(5, 5, i+1)
if i < 20:
fig.add_subplot(4, 5, i+1)
plt.axis("off")
plt.imshow(self.loadimg_frompatientslices(patientslices[i]), cmap=plt.cm.bone)
plt.show()
......@@ -503,14 +503,14 @@ def main():
optimizer = tf.optimizers.Adam(learning_rate=1e-4)
newSize = (512, 512)
save_weights = True
tasks = ['encode', 'cluster'] # encode for loading slices and computing latent vectors
tasks = ['cluster'] # encode for loading slices and computing latent vectors
num_epochs = 50
showplots = False
remote = False
remotefilepath = "/home/pv/saves/ae_3conv1024seg"
augment = ['normal', 'fliplr', 'flipud', 'rotate']
mrt = False
cross_val = False
cross_val = True
###############################
parser = argparse.ArgumentParser()
......
......@@ -252,8 +252,9 @@ class dbscan_clustering(BaseNetwork):
for i in range(len(cluster)):
patientslices.append([cluster[i][1:]])
#print(patientslices)
if i < 25:
fig.add_subplot(5, 5, i+1)
if i < 20:
fig.add_subplot(4, 5, i+1)
plt.axis("off")
plt.imshow(self.loadimg_frompatientslices(patientslices[i]), cmap=plt.cm.bone)
plt.show()
#########################################################################################################
......@@ -501,7 +502,7 @@ def main():
optimizer = tf.optimizers.Adam(learning_rate=1e-4)
newSize = (512, 512)
save_weights = True
tasks = ['encode', 'cluster'] # encode for loading slices and computing latent vectors
tasks = ['cluster'] # encode for loading slices and computing latent vectors
num_epochs = 50
showplots = False
remote = False
......@@ -550,7 +551,7 @@ def main():
if not os.path.exists("saves/" + modelname):
os.makedirs("saves/" + modelname)
specificmodels = [4]
specificmodels = [0]
#specificmodels = [4, 5, 6, 7]
if cross_val:
log = open("logs_clusterclassnet" + modelname + ".txt", "w+")
......
......@@ -100,7 +100,7 @@ def main():
y_true3d = np.append(np.reshape(y_true_np, newshape=(1, 512, 512)), y_true3d, axis=0)
except:
pass
hdd_16.append(np.mean(patient_hdd))
try:
hausdorff_distance_filter = sitk.HausdorffDistanceImageFilter()
hausdorff_distance_filter.Execute(sitk.GetImageFromArray(y_true3d),
......@@ -120,6 +120,7 @@ def main():
print("Dice-Score std: ", np.std(dice_Score16))
print("HDD mean: ", np.mean(all3dhdds))
print("HDD std: ", np.std(all3dhdds))
print("All 2d HDDs for", gt_type, ": ", hdd_16)
else:
file_path = "data/npy/"
gt_types = ['ctfgt2', 'thresh']
......@@ -179,7 +180,7 @@ def main():
else:
y_pred3d = np.append(np.reshape(pred_np, newshape=(1, 512, 512)), y_pred3d, axis=0)
y_true3d = np.append(np.reshape(y_true_np, newshape=(1, 512, 512)), y_true3d, axis=0)
hdd_16.append(np.mean(patient_hdd))
try:
hausdorff_distance_filter = sitk.HausdorffDistanceImageFilter()
hausdorff_distance_filter.Execute(sitk.GetImageFromArray(y_true3d),
......@@ -195,6 +196,8 @@ def main():
print("HDD mean: ", np.mean(all3dhdds))
print("HDD std: ", np.std(all3dhdds))
print("All 2d HDDs for", gt_type, ": ", hdd_16)
......
......@@ -19,7 +19,7 @@ from nets.Unet import *
def main():
models = ["12", "34", "56", "78", "910", "1112", "1314", "1516"]
folder_path = "finalResults/complete_segmr/mr_unet_cv_unetpred/"
folder_path = "finalResults/complete_seg/unet_cv_seg/"
#modeltype = "Cluster_"
#modeltype = "Class_"
#modeltype = "Cluster_class_"
......
......@@ -21,7 +21,7 @@ def main():
root = tk.Tk()
root.withdraw()
file_path = filedialog.askopenfilename(initialdir="saves/mr_unet_cv_unetpred")
file_path = filedialog.askopenfilename(initialdir="finalResults/")
file_path = file_path[:-9]
print(file_path)
......@@ -177,7 +177,7 @@ def main():
###################################################################################
detailed_images = False
detailed_images = True
npys3d = True
###################################################################################
......
import numpy as np
from nets.Unet import dice_loss
from sklearn.cluster import DBSCAN
import tensorflow as tf
import tkinter as tk
......@@ -9,12 +10,19 @@ import matplotlib.pyplot as plt
from scipy import ndimage
from datetime import datetime
predseg = np.load("finalResults/3dnpys/ctfgt2/unet_cv_ctfgt2/P01_pred3D.npy")
ytrueimg = np.load("data/npy_thresh/P02_seg.gipl.npy")
ytrainimg = np.load("data/npy_thresh/P02_400_thresh.gipl.npy")
print(np.shape(predseg))
trueslice = tf.convert_to_tensor(np.reshape(ytrueimg[18, :, :], newshape=(1, 512, 512, 1)))
trainslice = tf.convert_to_tensor(np.reshape(ytrainimg[18, :, :], newshape=(1, 512, 512, 1)))
plt.imshow(predseg[5, :, :], cmap=plt.cm.bone)
plt.imshow(ytrueimg[18, :, :], cmap=plt.cm.bone)
plt.show()
print(1 - dice_loss(trueslice, trainslice))
'''pat = "06"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment