Project-MONAI / model-zoo

MONAI Model Zoo that hosts models in the MONAI Bundle format.
Apache License 2.0
194 stars 68 forks source link

Lung Nodule detection (Inference) #166

Closed Asma-Alkhaldi closed 2 years ago

Asma-Alkhaldi commented 2 years ago

I have followed the instructions to do the inference but I have three questions: 1- The output I got having three main things:

2- The inference is working only on the raw data (The unprocessed images), while when I infer the model on the resampled data it is not working!?

3- The inference uses the ground truth and calculates the label score, what if I want to do the inference on a different dataset that has no ground truth? I want to see the performance of the model on another dataset.

Nic-Ma commented 2 years ago

Hi @Can-Zhao ,

Could you please help share some details about this question?

Thanks in advance.

Can-Zhao commented 2 years ago

I have followed the instructions to do the inference but I have three questions: 1- The output I got having three main things:

  • the ground truth coordinates
  • label
  • image name I’m wondering why the label is always zero? but some images have two zeros and some have more? can you please elaborate more on this part?

2- The inference is working only on the raw data (The unprocessed images), while when I infer the model on the resampled data it is not working!?

3- The inference uses the ground truth and calculates the label score, what if I want to do the inference on a different dataset that has no ground truth? I want to see the performance of the model on another dataset.

Thank you for reaching out.

  1. The label is always zero because 0 represents lung nodule. This is the only foreground class. The coordinates you got is not ground truth. Instead it is the predicted coordinates of nodules. When there are more than one 0, it means it predicts more than one nodules.

  2. I was wondering if you did resampling following the description in Sec. 3.1 of https://github.com/Project-MONAI/tutorials/tree/main/detection. If not, it may cause some issue. I added inference_raw.json in https://github.com/Project-MONAI/model-zoo/pull/167 that might help. Please let me know if it works.

  3. The inference did not use the ground truth. If you look at the "preprocessing" in the config file, you can see only "image" is used. Simply delete the box and label in the data list json, and it will produce the result

Asma-Alkhaldi commented 2 years ago

Thank you for your fast response

1- clear.

2- Yes I did the same preprocessing in 3.1 and the inference didn't work, I also check "affine_lps_to_ras": true and make sure it is true, I also added this line "affine_lps_to_ras": true in "target": "LoadImaged" and still the the inference is not working :/ ! The error message: RuntimeError: Could not create IO object for reading file /data/1.3.6.1.4.1.14519.5.2.1.6279.6001.281489753704424911132261151767.mhd

3- Where are you referring exactly when you said “preprocessing in the config file” ? Config directory has only five files which are:

I did as you said I deleted the box and label in the data list json in (annotation folder) since the data is being read from that folder, and I modified the name of the image to the new image I want to read, but it didn’t work because as I mentioned it is structured to read the ground truth. This is the error message I got: ValueError: Data list validation not specified in "/annotation/dataset_fold0 copy.json"

Can you please guide me how to to do the inference without ground truth? Sorry for being annoying, but I really interested to see MONAI results in another dataset :)

Can-Zhao commented 2 years ago

Thank you for your fast response

1- clear.

2- Yes I did the same preprocessing in 3.1 and the inference didn't work, I also check "affine_lps_to_ras": true and make sure it is true, I also added this line "affine_lps_to_ras": true in "target": "LoadImaged" and still the the inference is not working :/ ! The error message: RuntimeError: Could not create IO object for reading file /data/1.3.6.1.4.1.14519.5.2.1.6279.6001.281489753704424911132261151767.mhd

3- Where are you referring exactly when you said “preprocessing in the config file” ? Config directory has only five files which are:

  • evaluate.json
  • inference.json
  • metadata.json
  • train.json
  • logging.conf

I did as you said I deleted the box and label in the data list json in (annotation folder) since the data is being read from that folder, and I modified the name of the image to the new image I want to read, but it didn’t work because as I mentioned it is structured to read the ground truth. This is the error message I got: ValueError: Data list validation not specified in "/annotation/dataset_fold0 copy.json"

Can you please guide me how to to do the inference without ground truth? Sorry for being annoying, but I really interested to see MONAI results in another dataset :)

No worries, I'm happy to get feedback and answer the questions.

  1. From the error message, I can see the image is very likely to be the raw image, not the resampled image...Because the resampled image should be nifti. I updated the json files in https://github.com/Can-Zhao/model-zoo/tree/detection/models/lung_nodule_ct_detection/configs Could you try inference.json for resampled nifti images or inference_raw.json on original images?

  2. In inference.json, the very first transform of "preprocessing" is "DeleteItemsd", which deletes "box" and "label". I need some time to figure out how to change the code for datalist json without groud truth. For now, maybe you could try to replace the image filename with your new dataset as a workround.

Thank you! Please feel free to ask more questions

Asma-Alkhaldi commented 2 years ago

2- The images are resamples, but I explicitly convert them from nifti to mhd after doing the resampling because your code is only reading mhd format. did you test the inference ?

3- I added the name of the new data and I have the same issue. ValueError: Data list validation not specified in "/annotation/dataset_fold0.json".

Also, I noticed in the inference.json line 8 ("output_dir") it should put only the inference output in "eval" directory, but what is actually happening is, the code expected that the json annotations files are located in "eval directory". So, I needed to add a copy of the annotations files in eval directory to be able to run the code

Can-Zhao commented 2 years ago

2- The images are resamples, but I explicitly convert them from nifti to mhd after doing the resampling because your code is only reading mhd format. did you test the inference ?

3- I added the name of the new data and I have the same issue. ValueError: Data list validation not specified in "/annotation/dataset_fold0.json".

Also, I noticed in the inference.json line 8 ("output_dir") it should put only the inference output in "eval" directory, but what is actually happening is, the code expected that the json annotations files are located in "eval directory". So, I needed to add a copy of the annotations files in eval directory to be able to run the code

2- Yes, I tested it with nifti. The code should be able to read nifti.

3- This is weird...I created an empty ./eval folder, and it works. Also, I just removed the "box" and "label" in the data list json file and tested the code. It works well. The code is not structured to read the ground truth. In your "/annotation/dataset_fold0.json", is there a key called "validation"? (ctrl +F validation)

Could you try a json file with the following content?

{
    "validation": [
        {
            "image": "1.3.6.1.4.1.14519.5.2.1.6279.6001.281489753704424911132261151767/1.3.6.1.4.1.14519.5.2.1.6279.6001.281489753704424911132261151767.nii.gz"
        },
        {
            "image": "1.3.6.1.4.1.14519.5.2.1.6279.6001.313334055029671473836954456733/1.3.6.1.4.1.14519.5.2.1.6279.6001.313334055029671473836954456733.nii.gz"
        }
    ]
}