lab-midas / TCIA_processing

autoPET TCIA pipeline
MIT License
39 stars 11 forks source link

Error message: UnboundLocalError: local variable 'ds' referenced before assignment #1

Closed SyafiqRamlee closed 1 year ago

SyafiqRamlee commented 1 year ago

Hi there,

I'm trying to convert from DICOM to NIfTI a 10-patient sample of the TCIA FDG-PET-Lesions dataset using the script provided.

I've put on the command line below as instructed, replacing the last two arguments with the paths accordingly.:

python3 tcia_dicom_to_nifti.py /folderpath/to/dicom/ /folderpath/to/nifti

On first execution of the script, no issues were raised and the files were converted to NIfTI flawlessly. However, on re-execution of the script (using the same 10-patient sample), the code breaks at the first patient directory, and I am getting the following error:

File " ", line 58, in identify_modalities
    modalities["ID"] = ds.StudyInstanceUID
UnboundLocalError: local variable 'ds' referenced before assignment

The range of the tqdm progress bar has also changed to 0/20 from 0/10 on second execution, despite still having 10 samples in the /folderpath/to/dicom/ folder. Does anyone have insight on how to resolve this?

sergiosgatidis commented 1 year ago

Thanks for your question. It is hard to identify the error source based on this information - especially as the script worked properly on the first execution. It seems however that you modified the code as line 58 in the original code is not related to this problem - can you check? Also please make sure that the output NIfTI files are not stored within the DICOM folders. Let us know if you could resolve the problem.

jy168 commented 1 year ago

Could be caused by .DS_store files in mac system