BBillot / SynthSeg

Contrast-agnostic segmentation of MRI scans
Apache License 2.0
374 stars 94 forks source link

lab2im version errors #85

Closed htregidgo closed 7 months ago

htregidgo commented 8 months ago

Hi Benjamin,

I've been having some issues with training_group where the RandomSpatialDeformation layer doesn't understand the parameter prob_deform giving errors like the following.

File "/cluster/project7/synthsegInfant/SynthSeg_infant/SynthSeg/training_group.py", line 470, in labels_to_image_model_group
    prob_deform=0.9)(grouped_labels)
  File "/path/to/ext/lab2im/layers.py", line 125, in __init__
    super(RandomSpatialDeformation, self).__init__(**kwargs)
  File "/path/to/env/lib/python3.6/site-packages/keras/engine/base_layer.py", line 147, in __init__
    raise TypeError('Keyword argument not understood:', kwarg)
TypeError: ('Keyword argument not understood:', 'prob_deform')

These also pop up in the SynthSR code so I'd guess the syntax changed in lab2im at some point but the synthseg/sr training variants weren't all updated.

To get around this I've just added prob_deform=None, to the RandomSpatialDeformation layer arguments around this line and modified the self.prob assignment at this line to

self.prob = prob if prob_deform is None else prob_deform

This seems to effectively overload the layer arguments and handle anywhere the old calls haven't been updated. If this is likely to cause other issues let me know, otherwise I thought you might like to know.

Satob95 commented 7 months ago

I had almost the exact same error. It was caused by a mismatch between variable names (when calling RandomSpatialDeformation in labels_to_image_model.py, line 128-144) and the actual expected variable names (layers.py, ln 87 to 97). The wrong variable names were interpreted as unknown keyword arguments, i believe

BBillot commented 7 months ago

Hi Henry! prob and prob_deform are indeed the same variable, I probably forgot to update it in the training_group script. Good spot :) the new commit should fix this issue. Thanks!