Skip to content
Snippets Groups Projects
Commit 84bd4950 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Adjust matrix correctly (again) for >3D images. Adjust pixdims of higher

dimensions
parent 7d2a83e6
No related branches found
No related tags found
No related merge requests found
......@@ -196,6 +196,19 @@ def main(argv=None):
xform = None
resampled = fslimage.Image(resampled, xform=xform, header=hdr)
# Adjust the pixdims of the
# higher dimensions if they
# have been resampled
if len(resampled.shape) > 3:
oldPixdim = args.input.pixdim[3:]
oldShape = args.input.shape[ 3:]
newShape = resampled .shape[ 3:]
for i, (p, o, n) in enumerate(zip(oldPixdim, oldShape, newShape), 4):
resampled.header['pixdim'][i] = p * o / n
resampled.save(args.output)
return 0
......
......@@ -210,7 +210,12 @@ def resample(image,
# might not return a 4x4 matrix, so we
# make sure it is valid.
if matrix.shape != (4, 4):
matrix = np.vstack((matrix[:3, :4], [0, 0, 0, 1]))
rotmat = matrix[:3, :3]
offsets = matrix[:3, -1]
matrix = np.eye(4)
matrix[:3, :3] = rotmat
matrix[:3, -1] = offsets
matrix = transform.concat(image.voxToWorldMat, matrix)
return data, matrix
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment