Skip to content

Commit 50ace2a

Browse files
authored
Merge pull request #396 from effigies/fix/mask-bs-filter
FIX: Mask fieldmap before fitting spline field
2 parents 71a9ae3 + d518851 commit 50ace2a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

sdcflows/interfaces/bspline.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ def _run_interface(self, runtime):
195195
center = np.mean(data[mask])
196196

197197
data -= center
198+
data[~mask] = 0
198199

199200
# Calculate collocation matrix from (possibly resized) image and knot grids
200201
colmat = sparse_hstack(
@@ -214,7 +215,7 @@ def _run_interface(self, runtime):
214215
alpha=self.inputs.ridge_alpha, fit_intercept=False, solver="lsqr"
215216
)
216217
for attempt in range(3):
217-
model.fit(colmat[mask.reshape(-1), :], data[mask])
218+
model.fit(colmat, data.reshape(-1))
218219
extreme = np.abs(model.coef_).max()
219220
LOGGER.debug(f"Model fit attempt {attempt}: max(|coeffs|) = {extreme}")
220221
# Normal values seem to be ~1e2, bad ~1e8. May want to tweak this if

0 commit comments

Comments
 (0)