Chris Oswald
commited on
Commit
·
9c6a8c8
1
Parent(s):
de0408c
debugging
Browse files
SPIDER.py
CHANGED
@@ -59,7 +59,6 @@ def standardize_3D_image(
|
|
59 |
|
60 |
|
61 |
# Define constants
|
62 |
-
N_PATIENTS = 218
|
63 |
MIN_IVD = 0
|
64 |
MAX_IVD = 9
|
65 |
DEFAULT_SCAN_TYPES = ['t1', 't2', 't2_SPACE']
|
@@ -329,16 +328,18 @@ class SPIDER(datasets.GeneratorBasedBuilder):
|
|
329 |
]
|
330 |
|
331 |
# Generate train/validate/test partitions of patient IDs
|
|
|
|
|
|
|
332 |
partition = np.random.choice(
|
333 |
['train', 'dev', 'test'],
|
334 |
p=[train_share, validate_share, test_share],
|
335 |
-
size=
|
336 |
)
|
337 |
-
patient_ids = (np.arange(N_PATIENTS) + 1)
|
338 |
train_ids = set(patient_ids[partition == 'train'])
|
339 |
validate_ids = set(patient_ids[partition == 'dev'])
|
340 |
test_ids = set(patient_ids[partition == 'test'])
|
341 |
-
assert len(train_ids.union(validate_ids, test_ids)) ==
|
342 |
|
343 |
|
344 |
print(f'# of training ids: {len(train_ids)}')
|
|
|
59 |
|
60 |
|
61 |
# Define constants
|
|
|
62 |
MIN_IVD = 0
|
63 |
MAX_IVD = 9
|
64 |
DEFAULT_SCAN_TYPES = ['t1', 't2', 't2_SPACE']
|
|
|
328 |
]
|
329 |
|
330 |
# Generate train/validate/test partitions of patient IDs
|
331 |
+
patient_ids = np.unique([file.split('_')[0] for file in image_files])
|
332 |
+
print(f'Number of patients: {len(patient_ids)}')
|
333 |
+
|
334 |
partition = np.random.choice(
|
335 |
['train', 'dev', 'test'],
|
336 |
p=[train_share, validate_share, test_share],
|
337 |
+
size=len(patient_ids),
|
338 |
)
|
|
|
339 |
train_ids = set(patient_ids[partition == 'train'])
|
340 |
validate_ids = set(patient_ids[partition == 'dev'])
|
341 |
test_ids = set(patient_ids[partition == 'test'])
|
342 |
+
assert len(train_ids.union(validate_ids, test_ids)) == len(patient_ids)
|
343 |
|
344 |
|
345 |
print(f'# of training ids: {len(train_ids)}')
|