Skip to content

Commit

Permalink
malignancy networks
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasVansteenkiste committed Apr 5, 2017
1 parent b80902e commit 0fdb3bd
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions utils_lung.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,3 +348,35 @@ def log_loss(y_real, y_pred, eps=1e-15):
y_real = np.array(y_real)
losses = y_real * np.log(y_pred) + (1 - y_real) * np.log(1 - y_pred)
return - np.average(losses)


def read_luna_properties(file_path):
id2xyzp = defaultdict(list)
train_csv = open(file_path)
lines = train_csv.readlines()
i = 0
for item in lines:
if i == 0:
i = 1
continue
annotation = item.replace('\n', '').split(',')
id = annotation[0]
x = float(annotation[1])
y = float(annotation[2])
z = float(annotation[3])
d = float(annotation[4])
properties_dict = {
'diameter': d,
'calcification': float(annotation[5]),
'internalStructure': float(annotation[6]),
'lobulation': float(annotation[7]),
'malignancy': float(annotation[8]),
'margin': float(annotation[9]),
'sphericity': float(annotation[10]),
'spiculation': float(annotation[11]),
'subtlety': float(annotation[12]),
'texture': float(annotation[13]),
}

id2xyzp[id].append([z, y, x, d, properties_dict])
return id2xyzp

0 comments on commit 0fdb3bd

Please sign in to comment.