|
12 | 12 | class SubjectDataset(tio.data.SubjectsDataset):
|
13 | 13 | """Dataset class for the ZeroDose project."""
|
14 | 14 |
|
15 |
| - def __init__(self, mri_fnames, mask_fnames, out_fnames): |
| 15 | + def __init__(self, mri_fnames, mask_fnames, pet_fnames=None): |
16 | 16 | """Initialize the dataset."""
|
17 | 17 | transforms = self._get_augmentation_transform_val()
|
18 | 18 |
|
19 | 19 | subjects = [
|
20 |
| - self._make_subject_predict(mr_f, ma_f, ou_f) |
21 |
| - for mr_f, ma_f, ou_f in zip( # noqa |
| 20 | + self._make_subject_predict(mr_f, ma_f) |
| 21 | + for mr_f, ma_f in zip( # noqa |
22 | 22 | mri_fnames,
|
23 | 23 | mask_fnames,
|
24 |
| - out_fnames, |
25 | 24 | )
|
26 | 25 | ]
|
27 |
| - super().__init__(subjects, transforms) |
28 |
| - |
29 |
| - def _make_subject_dict(self, mr_path, mask_path) -> dict: |
30 |
| - subject_dict: Dict[Any, Any] = {} |
31 |
| - mri = mr_path |
32 |
| - mask = mask_path |
33 | 26 |
|
34 |
| - subject_dict["mr"] = tio.ScalarImage(mri) |
35 |
| - subject_dict["mask"] = tio.LabelMap(mask) |
| 27 | + if pet_fnames is not None: |
| 28 | + for sub, pet_fname in zip(subjects, pet_fnames): # noqa |
| 29 | + sub.add_image(tio.ScalarImage(pet_fname), "pet") |
36 | 30 |
|
37 |
| - return subject_dict |
| 31 | + super().__init__(subjects, transforms) |
38 | 32 |
|
39 |
| - def _make_subject_predict(self, mr_path, mask_path, out_fname) -> tio.Subject: |
40 |
| - subject_dict = self._make_subject_dict(mr_path, mask_path) |
41 |
| - subject_dict["out_fname"] = out_fname |
| 33 | + def _make_subject_predict(self, mr_path, mask_path) -> tio.Subject: |
| 34 | + subject_dict: Dict[Any, Any] = {} |
| 35 | + subject_dict["mr"] = tio.ScalarImage(mr_path) |
| 36 | + subject_dict["mask"] = tio.LabelMap(mask_path) |
42 | 37 | return tio.Subject(subject_dict)
|
43 | 38 |
|
44 | 39 | def _get_augmentation_transform_val(self) -> tio.Compose:
|
|
0 commit comments