sergivalverde / nicMSlesions

Easy multiple sclerosis white matter lesion segmentation using convolutional deep neural networks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use of nondeterministic .keys() method when loading modalities

jstutters opened this issue · comments

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.

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

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:

  • FLAIR + T1
  • FLAIR + T1 + MOD3
  • FLAIR + T1 + MOD3 + MOD4

Hopefully you get the same thing I do.