rmnldwg / lymph

Python package for statistical modelling of lymphatic metastatic spread in head & neck cancer.
https://lymph-model.readthedocs.io
MIT License
5 stars 4 forks source link

Bug in risk comp_posterior_state_dist() in unilateral #57

Closed YoelPH closed 7 months ago

YoelPH commented 7 months ago

There is an issue in the comp_diagnose_encoding function in [unilateral.py](https://github.com/rmnldwg/lymph/blob/main/lymph/models/unilateral.py.

in line 876 we have:

    diagnose_given_state = diagnose_encoding @ self.observation_matrix

This does not work as the two matrices do not have matching dimensions. After going through all the underlying code I assume that the dimensions of the self.observation_matrix are simply transposed. The following fix makes the function functional:

        diagnose_given_state = diagnose_encoding @ self.observation_matrix.T
YoelPH commented 7 months ago

Edit: there is a similar bug in bilateral.py https://github.com/rmnldwg/lymph/blob/main/lymph/models/bilateral.py in Line 522:

    diagnose_given_state = diagnose_encoding @ self.observation_matrix

I transposed the observation matrix again to fix the issue

rmnldwg commented 7 months ago

Good catch! I've fixed it in both the uni- and the bilateral model and added tests. The fixes live in the dev branch for now. Will be merged with the next release.