Skip to content

Commit 9da3867

Browse files
authored
fix(resampling): Use nearest mode for extrapolating data outside image boundaries (#3453)
This PR addresses an interpolation effect when the brain signal goes right up to the edge of the image. We have used the [scipy.ndimage.map_coordinates](https://docs.scipy.org/doc/scipy/reference/generated/scipy.ndimage.map_coordinates.html) default interpolation mode of `"constant"`, which extends the input image with zeros when necessary to perform interpolation (within two voxels of the edge, for the cubic interpolation we do). This will frequently result in zeroed-out portions of edge voxels. This generally works well when the image field of view is large enough to fully contain the brain, but can cause problems for limited field-of-view scans or images where the brain tissue can be found in the edge voxels. By switching to `nearest`, the edge voxels are extended out. For images with plenty of space around the head, this should have very little impact. When brain tissue extends to the image boundary, this should avoid inducing a signal drop-off. Closes #3452.
2 parents e3ec83f + 9e59fe2 commit 9da3867

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

fmriprep/interfaces/resampling.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,15 @@ class ResampleSeriesInputSpec(TraitedSpec):
5454
num_threads = traits.Int(1, usedefault=True, desc='Number of threads to use for resampling')
5555
output_data_type = traits.Str('float32', usedefault=True, desc='Data type of output image')
5656
order = traits.Int(3, usedefault=True, desc='Order of interpolation (0=nearest, 3=cubic)')
57-
mode = traits.Str(
57+
mode = traits.Enum(
58+
'nearest',
5859
'constant',
60+
'mirror',
61+
'reflect',
62+
'wrap',
63+
'grid-constant',
64+
'grid-mirror',
65+
'grid-wrap',
5966
usedefault=True,
6067
desc='How data is extended beyond its boundaries. '
6168
'See scipy.ndimage.map_coordinates for more details.',

0 commit comments

Comments
 (0)