Chris Oswald
commited on
Commit
•
b949ef2
1
Parent(s):
1c9918d
debugging
Browse files
SPIDER.py
CHANGED
@@ -431,15 +431,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
431 |
k:v for k,v in item.items() if k not in exclude_vars
|
432 |
}
|
433 |
|
434 |
-
# Merge patient records for radiological gradings data
|
435 |
-
grades_dict = {}
|
436 |
-
for patient_id in patient_ids:
|
437 |
-
patient_grades = [
|
438 |
-
x for x in grades_data if x['Patient'] == str(patient_id)
|
439 |
-
]
|
440 |
-
if patient_grades:
|
441 |
-
grades_dict[str(patient_id)] = patient_grades
|
442 |
-
|
443 |
# # Determine maximum number of radiological gradings per patient
|
444 |
# max_ivd = 0
|
445 |
# for temp_dict_1 in grades_dict.values():
|
@@ -447,6 +438,31 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
447 |
# if int(temp_dict_2['IVD label']) > max_ivd:
|
448 |
# max_ivd = int(temp_dict_2['IVD label'])
|
449 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
450 |
# Import image and mask data
|
451 |
image_files = [
|
452 |
file for file in os.listdir(os.path.join(paths_dict['images'], 'images'))
|
@@ -525,23 +541,6 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
525 |
if k not in ['Patient', 'IVD label']
|
526 |
}
|
527 |
patient_grades_dict[key] = value
|
528 |
-
|
529 |
-
print(example, patient_grades_dict)
|
530 |
-
# Pad patient radiological gradings so that data for all patients
|
531 |
-
# have the same dimensions
|
532 |
-
if len(patient_grades_dict) < MAX_IVD:
|
533 |
-
for i in range(len(patient_grades_dict) + 1, MAX_IVD + 1):
|
534 |
-
print(i)
|
535 |
-
patient_grades_dict[f'IVD{i}'] = {
|
536 |
-
"Modic": "",
|
537 |
-
"UP endplate": "",
|
538 |
-
"LOW endplate": "",
|
539 |
-
"Spondylolisthesis": "",
|
540 |
-
"Disc herniation": "",
|
541 |
-
"Disc narrowing": "",
|
542 |
-
"Disc bulging": "",
|
543 |
-
"Pfirrman grade": "",
|
544 |
-
}
|
545 |
|
546 |
# Prepare example return dict
|
547 |
return_dict = {'patient_id':patient_id, 'scan_type':scan_type}
|
|
|
431 |
k:v for k,v in item.items() if k not in exclude_vars
|
432 |
}
|
433 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
434 |
# # Determine maximum number of radiological gradings per patient
|
435 |
# max_ivd = 0
|
436 |
# for temp_dict_1 in grades_dict.values():
|
|
|
438 |
# if int(temp_dict_2['IVD label']) > max_ivd:
|
439 |
# max_ivd = int(temp_dict_2['IVD label'])
|
440 |
|
441 |
+
# Merge patient records for radiological gradings data
|
442 |
+
grades_dict = {}
|
443 |
+
for patient_id in patient_ids:
|
444 |
+
patient_grades = [
|
445 |
+
x for x in grades_data if x['Patient'] == str(patient_id)
|
446 |
+
]
|
447 |
+
# Pad radiological gradings so that data for all patients have
|
448 |
+
# the same dimensions
|
449 |
+
if len(patient_grades) < MAX_IVD:
|
450 |
+
for i in range(len(patient_grades) + 1, MAX_IVD + 1):
|
451 |
+
patient_grades.append({
|
452 |
+
"Patient": f"{patient_id}",
|
453 |
+
"IVD label": f"{i}",
|
454 |
+
"Modic": "",
|
455 |
+
"UP endplate": "",
|
456 |
+
"LOW endplate": "",
|
457 |
+
"Spondylolisthesis": "",
|
458 |
+
"Disc herniation": "",
|
459 |
+
"Disc narrowing": "",
|
460 |
+
"Disc bulging": "",
|
461 |
+
"Pfirrman grade": "",
|
462 |
+
})
|
463 |
+
assert len(patient_grades) == MAX_IVD, "Rad. gradings not padded correctly"
|
464 |
+
grades_dict[str(patient_id)] = patient_grades
|
465 |
+
|
466 |
# Import image and mask data
|
467 |
image_files = [
|
468 |
file for file in os.listdir(os.path.join(paths_dict['images'], 'images'))
|
|
|
541 |
if k not in ['Patient', 'IVD label']
|
542 |
}
|
543 |
patient_grades_dict[key] = value
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
544 |
|
545 |
# Prepare example return dict
|
546 |
return_dict = {'patient_id':patient_id, 'scan_type':scan_type}
|