sergivalverde / nicMSlesions

Easy multiple sclerosis white matter lesion segmentation using convolutional deep neural networks.
GNU General Public License v3.0
46 stars 21 forks source link

Use of nondeterministic .keys() method when loading modalities #6

Closed jstutters closed 2 years ago

jstutters commented 5 years ago

Hi,

I believe the following two lines are problematic:

base.py#L221 base.py#L437

The order of items returned by dict.keys() cannot to be assumed to be deterministic in Python 2. If I'm reading the code correctly this then means that the mapping of image modalities to channels presented to the network is only fixed by 'luck'. This creates a challenge when using weights from a Python 2 version in my work-in-progress Python 3 version in which the key order is different. To fix this options['modalities'] list should be used to retrieve the keys in a known order. I have a pull request that does this if you agree it's a problem.

sergivalverde commented 5 years ago

Hi Jon, Thanks again for the feeback, really appreciate it. Please, can you summit a pull request to solve it?

jstutters commented 5 years ago

Hi. Happy to provide the code. I think the most sensible approach is to fix the order as it currently is and then continue to use this in the python 3 version. That will avoid breaking any existing trained weights. Could you put add a print modalities on lines 222 and 438 of base.py and let me know the order it gives you for each of:

Hopefully you get the same thing I do.