Skip to content

Commit

Permalink
It runs!
Browse files Browse the repository at this point in the history
  • Loading branch information
tsalo committed Apr 7, 2024
1 parent 36086ac commit ba6ebea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
6 changes: 5 additions & 1 deletion sdcflows/interfaces/fmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,11 @@ def _run_interface(self, runtime):

unwrapped_mat = phase_volume_data.reshape(-1, n_echoes).T
weights = magnitude_volume_data.reshape(-1, n_echoes).T
b0 = weighted_regression(echo_times, unwrapped_mat, weights)[0].T.reshape(*size)
b0 = weighted_regression(
echo_times[:, np.newaxis],
unwrapped_mat,
weights,
)[0].T.reshape(*size)
b0 *= 1000 / (2 * np.pi)
out_b0[:, :, :, i_vol] = b0

Expand Down
10 changes: 9 additions & 1 deletion sdcflows/interfaces/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,15 @@ def _run_interface(self, runtime):
Y = phase_unwrapped[volume_mask, :j_echo, i_vol].T

# fit model to data
coefficients, _ = weighted_regression(X[:j_echo], Y, weights_mat[:j_echo])
# XXX: Small change from warpkit:
# weights_mat[:j_echo, i_vol, :] instead of weights_mat[:j_echo]
# Otherwise, coefficients is voxels x time instead of just voxels
# Not sure what the issue is.
coefficients, _ = weighted_regression(
X[:j_echo],
Y,
weights_mat[:j_echo, i_vol, :],
)

# get the predicted values for this echo
Y_pred = coefficients * echo_times[j_echo]
Expand Down

0 comments on commit ba6ebea

Please sign in to comment.