Skip to content

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

@SyafiqRamlee

Description

@SyafiqRamlee

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions