nyuad-cai / MedFuse

68 stars 19 forks source link

'None' data issue when executing sh ./scripts/radiology/uni_cxr.sh #3

Closed shkeum21 closed 1 year ago

shkeum21 commented 1 year ago

when executing sh ./scripts/radiology/uni_cxr.sh, error occurs. Below are the details: File "/mnt/gsai/brain/MedFuse/datasets/fusion.py", line 202, in x = [item[0] for item in batch] TypeError: 'NoneType' object is not subscriptable

In datasets/fusion.py, there is a def my_colate() ,used for dataloader. I debugged with following code"

` def my_collate(batch):

for loop for debugging

for item in batch:

    if item is not None:

        ehr_data, cxr_data, labels_ehr, labels_cxr = item

        print(ehr_data.shape, cxr_data.shape, labels_ehr.shape, labels_cxr.shape)

    else:

        print(item)`

It prints 'None' for every item in batch. Can you figure it out what's the problem?

farahshamout commented 1 year ago

Hi @shkeum21 I am trying to replicate your error but my script is running fine with the same arguments as in uni_cxr.sh. Can you provide more information? Did you download the chest X-ray dataset and resize it? Are you able to load it elsewhere?

Also please check that this part that retrieves the paths to the chest X-ray images is working fine: https://github.com/nyuad-cai/MedFuse/blob/30c68c0acd359e313f3e5fb3e18c49ac26cb8ba0/datasets/cxr_dataset.py#L96

Let me know.

shkeum21 commented 1 year ago

Thanks for the reply. I solved my problem and the cause was arguments 'data_pairs' don't have option 'paired'. So, I changed 'paired' -> 'radiology' as it seems more proper. Am I doing right? Hope you to check on this problem :)

farahshamout commented 1 year ago

Hi @shkeum21 yes that's true actually. The other thing that I had to do was to modify how the predictions are handled in the validate function in fusion_trainer.py: https://github.com/nyuad-cai/MedFuse/blob/6f827589afd89562813cc5aa915762d054c29efc/trainers/fusion_trainer.py#L149

Thanks for pointing this out and let me know if you have any other questions!