reginabarzilaygroup / Sybil

Deep Learning for Lung Cancer Risk Prediction using LDCT
MIT License
62 stars 38 forks source link

Inference script that inputs mha slices #35

Open fennievdg opened 5 months ago

fennievdg commented 5 months ago

Hi Reginabarzilay group,

Firstly, thank you for making your code publically available! I would find it very useful to have an implementation of your Sybil code that inputs .mha slices (as well as .dcm slices). I have an inference script that inputs mha slices and I also made a few updates in serie.py to load them with SimpleITK. However when I compared the risk scores that I obtained with loading the .dcm slices with the risk scores from loading the .mha slices for the same case, I did not get the same risk scores. Perhaps you can suggest how to fix my implementation to load the mha slices?

Thank you! Fennie van der Graaf

pgmikhael commented 5 months ago

Hi Fennie,

Thanks for following up and making the PR! We had some recent updates to the repo, so many of the "changed" files in your commit are probably from an older version. It looks like the main changes are in:

Am I missing something else that's important?

In terms of figuring out the discrepancy in risk scores, do you have the same CT in both formats (DICOM/MHA or PNG/MHA)? Also, do you have a test sample that you can share so that we might take a closer look?

fennievdg commented 5 months ago

Hi,

Thanks for your quick reaction. Yes, The main changes were performed in inference_fennie.py, image_loaders.py, and in serie.py.

I am not sure yet if I can share a test case, I am waiting on my supervisor to suggest how to go about that, but for now you can replicate my inputs using a NLST mha file and the following 2 scripts:

Traceback (most recent call last): File "/data/bodyct/experiments/Sybil_Fennie/bodyct-sybil-lung-cancer-risk/inference_fennie.py", line 127, in scores = model.predict([serie]) File "/data/bodyct/experiments/Sybil_Fennie/bodyct-sybil-lung-cancer-risk/sybil/model.py", line 286, in predict pred = self._predict(sybil, series) File "/data/bodyct/experiments/Sybil_Fennie/bodyct-sybil-lung-cancer-risk/sybil/model.py", line 259, in _predict volume = serie.get_volume() File "/data/bodyct/experiments/Sybil_Fennie/bodyct-sybil-lung-cancer-risk/sybil/serie.py", line 163, in get_volume x = tio.ScalarImage( File "/usr/local/lib/python3.9/site-packages/torchio/data/image.py", line 815, in init super().init(*args, **kwargs) File "/usr/local/lib/python3.9/site-packages/torchio/data/image.py", line 158, in init affine = self._parse_affine(affine) File "/usr/local/lib/python3.9/site-packages/torchio/data/image.py", line 514, in _parse_affine raise ValueError(f'Affine shape must be (4, 4), not {bad_shape}') ValueError: Affine shape must be (4, 4), not (3, 3)

Let me know if you need further clarification! Thanks! Fennie