jaeho3690/LIDC-IDRI-Preprocessing

File not found error

Closed this issue · 5 comments

I have created all the folders as mentioned but still getting this error

FileNotFoundError Traceback (most recent call last)
in
166
167 test= MakeDataSet(LIDC_IDRI_list,IMAGE_DIR,MASK_DIR,CLEAN_DIR_IMAGE,CLEAN_DIR_MASK,META_DIR,mask_threshold,padding,confidence_level)
--> 168 test.prepare_dataset()

in prepare_dataset(self)
130
131 self.save_meta(meta_list)
--> 132 np.save(patient_image_dir / nodule_name,lung_segmented_np_array)
133 np.save(patient_mask_dir / mask_name,mask[:,:,nodule_slice])
134 else:

<array_function internals> in save(*args, **kwargs)

~\Anaconda3\envs\cpu_env\lib\site-packages\numpy\lib\npyio.py in save(file, arr, allow_pickle, fix_imports)
539 if not file.endswith('.npy'):
540 file = file + '.npy'
--> 541 fid = open(file, "wb")
542 own_fid = True
543

FileNotFoundError: [Errno 2] No such file or directory: 'D:\data\Image\LIDC-IDRI-0001\LIDC-IDRI-0001\0001_NI000_slice000.npy'

Hi, it seems that you are missing some directories. The '0001_NI000_slice000.npy' file is an output file(nodule image). Thus, it is a file that is being made when you run the code. Check if you have made the \data\Image directory or have made the needed changes in the config_file_create.py file

please let me know if you have solved it

I have made the data/Image directory. The problem I am facing is the program is creating two directories with the name of LIDC-IDRI-0001 in the data/Image folder. So it is not not able to find the path.
I am getting this 'D:\data\Mask\LIDC-IDRI-0001\LIDC-IDRI-0001\0001_MA000_slice000.npy' but it should be
'D:\data\Mask\LIDC-IDRI-0001\0001_MA000_slice000.npy'
I have resolved the issue.

I will go through the codes again! thanks for letting me know

You just need to change the lines to
patient_image_dir = IMAGE_DIR #IMAGE_DIR / pid
patient_mask_dir = MASK_DIR

solved this issue by changing

nodule_name = "{}_NI{}_slice{}".format(pid[-4:],prefix[nodule_idx],prefix[nodule_slice])
mask_name = "{}_MA{}_slice{}".format(pid[-4:],prefix[nodule_idx],prefix[nodule_slice])