How can I fix the error, "FileNotFoundError: [Errno 2] No such file or directory" in this tool?

47 Views Asked by At

I installed all requirements for this tool and I run it too but as soon as I click on Open Exam... and give it the path to the dicom files and then when I click on Calculate Volume after some seconds the program gets closed and in CMD I see this error:

C:\Users\Lenovo\Downloads\HARTA-main>C:\Users\Lenovo\Downloads\HARTA-main\harta.py
Traceback (most recent call last):
  File "C:\Users\Lenovo\Downloads\HARTA-main\harta.py", line 486, in generateVolume
    patient_id, no_slices, vol = _automatic_.segmentEpicardialFat(DICOM_DATASET=dir, OUTPUT_FOLDER='aux_img/')
  File "C:\Users\Lenovo\Downloads\HARTA-main\_automatic_.py", line 61, in segmentEpicardialFat
    images_png = np.stack([convert_image_to_rgb(dicom, f'slices/{patient_id}_{i}', OUTPUT_FOLDER) for dicom, i in zip(median, range(0,no_slices))])
  File "C:\Users\Lenovo\Downloads\HARTA-main\_automatic_.py", line 61, in <listcomp>
    images_png = np.stack([convert_image_to_rgb(dicom, f'slices/{patient_id}_{i}', OUTPUT_FOLDER) for dicom, i in zip(median, range(0,no_slices))])
  File "C:\Users\Lenovo\Downloads\HARTA-main\algorithm\basicOperations.py", line 9, in convert_image_to_rgb
    plt.imsave(f'{output_folder}{filename}.png', image, cmap='gray')
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\pyplot.py", line 2251, in imsave
    return matplotlib.image.imsave(fname, arr, **kwargs)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\image.py", line 1611, in imsave
    image.save(fname, **pil_kwargs)
  File "C:\Users\Lenovo\AppData\Local\Programs\Python\Python38\lib\site-packages\PIL\Image.py", line 2161, in save
    fp = builtins.open(filename, "w+b")
FileNotFoundError: [Errno 2] No such file or directory: 'aux_img/slices/21227013_0.png'

The error says No such file or directory: 'aux_img/slices/21227013_0.png' and here is the line 486 and some lines under it:

def generateVolume(self):
    global patient_id
    global no_slices
    patient_id, no_slices, vol = _automatic_.segmentEpicardialFat(DICOM_DATASET=dir, OUTPUT_FOLDER='aux_img/')
    self.volume.setText(str(round(vol, 1)))
    self.refreshAfterAutomatic()

def generateNewVolume(self):
    patient_id, no_slices, vol = _semiautomatic_.segmentEpicardialFat(DICOM_DATASET=dir, OUTPUT_FOLDER='aux_img/')
    self.volume_2.setText(str(round(vol, 1)))
    self.refreshAfterSemiAutomatic()

'INTERFACE MANAGER'

def updateImage(self, slice_id):
    "Show container"
    self.manual_intervention.show()
    self.semiLabel.show()
    self.afterEditionBox.hide()
    self.slice_id = slice_id
    self.editionHandler()

    'Show the image with new contour'
    self.imageHeart.setPixmap(QtGui.QPixmap(':/aux/edited_successfully_bg.png'))

And this is the link to the file.

Can you enlighten me how to fix this problem?

0

There are 0 best solutions below