diff --git a/nnunetv2/training/dataloading/utils.py b/nnunetv2/training/dataloading/utils.py index 352d18285..7c14bd167 100644 --- a/nnunetv2/training/dataloading/utils.py +++ b/nnunetv2/training/dataloading/utils.py @@ -92,9 +92,11 @@ def _convert_to_npy(npz_file: str, unpack_segmentation: bool = True, overwrite_e try: a = np.load(npz_file) # inexpensive, no compression is done here. This just reads metadata if overwrite_existing or not isfile(npz_file[:-3] + "npy"): - np.save(npz_file[:-3] + "npy", a['data']) + if not os.path.exists(npz_file[:-3] + "npy"): + np.save(npz_file[:-3] + "npy", a['data']) if unpack_segmentation and (overwrite_existing or not isfile(npz_file[:-4] + "_seg.npy")): - np.save(npz_file[:-4] + "_seg.npy", a['seg']) + if not os.path.exists(npz_file[:-4] + "_seg.npy"): + np.save(npz_file[:-4] + "_seg.npy", a['seg']) except KeyboardInterrupt: if isfile(npz_file[:-3] + "npy"): os.remove(npz_file[:-3] + "npy") diff --git a/scripts/generate_json.ipynb b/scripts/generate_json.ipynb index 28056abe3..2b3fe1073 100755 --- a/scripts/generate_json.ipynb +++ b/scripts/generate_json.ipynb @@ -11,36 +11,22 @@ "from nnunetv2.dataset_conversion.generate_dataset_json import generate_dataset_json\n", "import os\n", "\n", - "dataset = \"/media/eolika/49755d50-5426-4672-87cc-2d1a5a3747ad/nnUNet/nnUNet_raw/Dataset103_mosaic_cardiovascular\"\n", + "dataset = \"/media/eolika/49755d50-5426-4672-87cc-2d1a5a3747ad/nnUNet/nnUNet_raw/Dataset102_mosaic_muscles\"\n", "\n", "generate_dataset_json(output_folder=dataset,\n", " channel_names={0: \"CT\"},\n", " labels={\n", " \"background\": 0,\n", - " \"heart_myocardium\": 1,\n", - " \"heart_atrium_left\": 2,\n", - " \"heart_ventricle_left\": 3,\n", - " \"heart_atrium_right\": 4,\n", - " \"heart_ventricle_right\": 5,\n", - " \"aorta\": 6,\n", - " \"pulmonary_vein\": 7,\n", - " \"pulmonary_artery\": 8,\n", - " \"brachiocephalic_trunk\": 9,\n", - " \"subclavian_artery_right\": 10,\n", - " \"subclavian_artery_left\": 11,\n", - " \"common_carotid_artery_right\": 12,\n", - " \"common_carotid_artery_left\": 13,\n", - " \"brachiocephalic_vein_left\": 14,\n", - " \"brachiocephalic_vein_right\": 15,\n", - " \"superior_vena_cava\": 16,\n", - " \"inferior_vena_cava\": 17,\n", - " \"portal_vein_and_splenic_vein\": 18,\n", - " \"iliac_artery_left\": 19,\n", - " \"iliac_artery_right\": 20,\n", - " \"iliac_vena_left\": 21,\n", - " \"iliac_vena_right\": 22,\n", - " \"liver_vessels\": 23,\n", - " \"lung_vessels\": 24\n", + " \"gluteus_maximus_left\": 1,\n", + " \"gluteus_maximus_right\": 2,\n", + " \"gluteus_medius_left\": 3,\n", + " \"gluteus_medius_right\": 4,\n", + " \"gluteus_minimus_left\": 5,\n", + " \"gluteus_minimus_right\": 6,\n", + " \"autochthon_left\": 7,\n", + " \"autochthon_right\": 8,\n", + " \"iliopsoas_left\": 9,\n", + " \"iliopsoas_right\": 10\n", " },\n", " num_training_cases=len(os.listdir(f'{dataset}/imagesTr')), \n", " file_ending='.nii.gz',\n", @@ -48,7 +34,7 @@ " reference='BlueMind AI Inc',\n", " release='1.0.0',\n", " overwrite_image_reader_writer='NibabelIOWithReorient',\n", - " description=\"cardiovascular\")" + " description=\"muscles\")" ] }, {