Skip to content

Commit 00519d3

Browse files
committed
fix: revision of the b-spline fitting code
1 parent bb89bdc commit 00519d3

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

sdcflows/interfaces/bspline.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,19 @@ class _BSplineApproxInputSpec(BaseInterfaceInputSpec):
5656
in_data = File(exists=True, mandatory=True, desc="path to a fieldmap")
5757
in_mask = File(exists=True, desc="path to a brain mask")
5858
bs_spacing = InputMultiObject(
59-
[DEFAULT_ZOOMS_MM],
59+
[DEFAULT_HF_ZOOMS_MM],
6060
traits.Tuple(traits.Float, traits.Float, traits.Float),
6161
usedefault=True,
6262
desc="spacing between B-Spline control points",
6363
)
6464
ridge_alpha = traits.Float(
65-
0.01, usedefault=True, desc="controls the regularization"
65+
1e-4, usedefault=True, desc="controls the regularization"
6666
)
6767
recenter = traits.Enum(
68+
False,
6869
"mode",
6970
"median",
7071
"mean",
71-
False,
7272
usedefault=True,
7373
desc="strategy to recenter the distribution of the input fieldmap",
7474
)
@@ -80,7 +80,7 @@ class _BSplineApproxInputSpec(BaseInterfaceInputSpec):
8080
zooms_min = traits.Union(
8181
traits.Float,
8282
traits.Tuple(traits.Float, traits.Float, traits.Float),
83-
default_value=4.0,
83+
default_value=1.0,
8484
usedefault=True,
8585
desc="limit minimum image zooms, set 0.0 to use the original image",
8686
)
@@ -211,9 +211,7 @@ def _run_interface(self, runtime):
211211
)
212212

213213
# Fit the model
214-
model = lm.Ridge(
215-
alpha=self.inputs.ridge_alpha, fit_intercept=False, solver="lsqr"
216-
)
214+
model = lm.Ridge(alpha=self.inputs.ridge_alpha, fit_intercept=True)
217215
for attempt in range(3):
218216
model.fit(colmat, data.reshape(-1))
219217
extreme = np.abs(model.coef_).max()
@@ -228,6 +226,8 @@ def _run_interface(self, runtime):
228226
f"Extreme value {extreme:.2e} detected in spline coefficients."
229227
)
230228

229+
LOGGER.info(f"Model fit. Intercept = {model.intercept_}")
230+
231231
# Store coefficients
232232
index = 0
233233
self._results["out_coeff"] = []

sdcflows/utils/wrangler.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ def find_estimators(
339339
"Dataset includes `B0FieldIdentifier` metadata."
340340
"Any data missing this metadata will be ignored."
341341
)
342+
342343
for b0_id in b0_ids:
343344
# Found B0FieldIdentifier metadata entries
344345
b0_entities = base_entities.copy()

sdcflows/workflows/fit/fieldmap.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ def init_fmap_wf(omp_nthreads=1, sloppy=False, debug=False, mode="phasediff", na
8686
"""
8787
from ...interfaces.bspline import (
8888
BSplineApprox,
89-
DEFAULT_LF_ZOOMS_MM,
9089
DEFAULT_HF_ZOOMS_MM,
9190
DEFAULT_ZOOMS_MM,
9291
)
@@ -115,7 +114,7 @@ def _unzip(fmap_spec):
115114
bs_filter = pe.Node(BSplineApprox(), name="bs_filter")
116115
bs_filter.interface._always_run = debug
117116
bs_filter.inputs.bs_spacing = (
118-
[DEFAULT_LF_ZOOMS_MM, DEFAULT_HF_ZOOMS_MM] if not sloppy else [DEFAULT_ZOOMS_MM]
117+
[DEFAULT_HF_ZOOMS_MM] if not sloppy else [DEFAULT_ZOOMS_MM]
119118
)
120119
bs_filter.inputs.extrapolate = not debug
121120

0 commit comments

Comments
 (0)