Valentin Boussot commited on
Commit
9b3f426
·
1 Parent(s): b22e3a0

fix(convexadam): layers_mask as a 1/0 bitmask string, like elastix

Browse files

ModelSpec.layers_mask is now a str ('1', '0000001' — one char per model layer, '1'=use) matching the elastix ModelSpec, instead of a list[bool]. The engine converts it to the bool list itk-impact's ModelConfiguration expects; '1' -> [True] keeps the current single-layer configs byte-identical.

ConvexAdam_Coarse/Model.py CHANGED
@@ -100,7 +100,7 @@ class ModelSpec:
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
- layers_mask: list[bool] = field(default_factory=lambda: [True])
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
@@ -508,7 +508,7 @@ class RegistrationNet(network.Network):
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
- [list(spec.layers_mask) for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
 
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
+ layers_mask: str = "1" # per-layer bitmask, one char per model layer ('1' = use, '0' = skip), like elastix
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
 
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
+ [[c == "1" for c in spec.layers_mask] for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
ConvexAdam_Coarse/Prediction.yml CHANGED
@@ -9,8 +9,7 @@ Predictor:
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
- layers_mask:
13
- - true
14
  layers_weight: 1.0
15
  pca: 0
16
  distance: L1
 
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
+ layers_mask: '1'
 
13
  layers_weight: 1.0
14
  pca: 0
15
  distance: L1
ConvexAdam_Coarse/__pycache__/Model.cpython-313.pyc CHANGED
Binary files a/ConvexAdam_Coarse/__pycache__/Model.cpython-313.pyc and b/ConvexAdam_Coarse/__pycache__/Model.cpython-313.pyc differ
 
ConvexAdam_Composite/Model.py CHANGED
@@ -100,7 +100,7 @@ class ModelSpec:
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
- layers_mask: list[bool] = field(default_factory=lambda: [True])
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
@@ -508,7 +508,7 @@ class RegistrationNet(network.Network):
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
- [list(spec.layers_mask) for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
 
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
+ layers_mask: str = "1" # per-layer bitmask, one char per model layer ('1' = use, '0' = skip), like elastix
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
 
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
+ [[c == "1" for c in spec.layers_mask] for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
ConvexAdam_Composite/Prediction.yml CHANGED
@@ -9,8 +9,7 @@ Predictor:
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
- layers_mask:
13
- - true
14
  layers_weight: 1.0
15
  pca: 0
16
  distance: L1
 
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
+ layers_mask: '1'
 
13
  layers_weight: 1.0
14
  pca: 0
15
  distance: L1
ConvexAdam_Composite/__pycache__/Model.cpython-313.pyc CHANGED
Binary files a/ConvexAdam_Composite/__pycache__/Model.cpython-313.pyc and b/ConvexAdam_Composite/__pycache__/Model.cpython-313.pyc differ
 
ConvexAdam_Fine/Model.py CHANGED
@@ -100,7 +100,7 @@ class ModelSpec:
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
- layers_mask: list[bool] = field(default_factory=lambda: [True])
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
@@ -508,7 +508,7 @@ class RegistrationNet(network.Network):
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
- [list(spec.layers_mask) for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
 
100
 
101
  ref: Annotated[str, Choices(registry_choices)]
102
  voxel_size: list[float] = field(default_factory=lambda: [3.0, 3.0, 3.0])
103
+ layers_mask: str = "1" # per-layer bitmask, one char per model layer ('1' = use, '0' = skip), like elastix
104
  layers_weight: float = 1.0
105
  pca: Annotated[int, Range(0, 100)] = 0
106
  distance: Literal["L1", "L2", "Dice", "Cosine", "NCC"] = "L1"
 
508
  [spec.ref for spec in specs],
509
  [list(spec.voxel_size) for spec in specs],
510
  overlap,
511
+ [[c == "1" for c in spec.layers_mask] for spec in specs],
512
  mixed_precision,
513
  grid_spacing,
514
  displacement_half_width,
ConvexAdam_Fine/Prediction.yml CHANGED
@@ -9,8 +9,7 @@ Predictor:
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
- layers_mask:
13
- - true
14
  layers_weight: 1.0
15
  pca: 0
16
  distance: L1
 
9
  - 3.0
10
  - 3.0
11
  - 3.0
12
+ layers_mask: '1'
 
13
  layers_weight: 1.0
14
  pca: 0
15
  distance: L1
ConvexAdam_Fine/__pycache__/Model.cpython-313.pyc CHANGED
Binary files a/ConvexAdam_Fine/__pycache__/Model.cpython-313.pyc and b/ConvexAdam_Fine/__pycache__/Model.cpython-313.pyc differ