Skip to content

Commit

Permalink
ENH: Implement Jacobian attenuation during unwarp
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Oct 1, 2023
1 parent 50ace2a commit c8a4f3d
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sdcflows/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,15 @@ def _sdc_unwarp(
# Map voxel coordinates applying the VSM
# The VSM is just the displacements field given in index coordinates
# voxcoords is the deformation field, i.e., the target position of each voxel
coordinates[pe_info[0], ...] += fmap_hz * pe_info[1]
vsm = fmap_hz * pe_info[1]
coordinates[pe_info[0], ...] += vsm

# The Jacobian determinant image is the amount of stretching in the PE direction.
# Using central differences accounts for the shift in neighboring voxels.
# The full Jacobian at each voxel would be a 3x3 matrix, but because there is
# only warping in one direction, we end up with a diagonal matrix with two 1s.
# The following is the other entry at each voxel, and hence the determinant.
jacobian = 1 + np.gradient(vsm, axis=pe_info[0])

resampled = ndi.map_coordinates(
data,
Expand All @@ -102,7 +110,7 @@ def _sdc_unwarp(
mode=mode,
cval=cval,
prefilter=prefilter,
)
) * jacobian

return resampled

Expand Down

0 comments on commit c8a4f3d

Please sign in to comment.