Skip to content

Commit 2fbabc9

Browse files
author
Yannick Schwartz
committed
Fixed concat_images so it can work on large sequences of images.
1 parent 1046c11 commit 2fbabc9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

nibabel/funcs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
from .orientations import (io_orientation, orientation_affine, flip_axis,
1313
apply_orientation, OrientationError)
14+
from .loadsave import load
1415

1516

1617
def squeeze_image(img):
@@ -92,7 +93,7 @@ def concat_images(images, check_affines=True):
9293
Parameters
9394
----------
9495
images : sequence
95-
sequence of ``SpatialImage``\s
96+
sequence of paths to be loaded as ``SpatialImage``\s
9697
check_affines : {True, False}, optional
9798
If True, then check that all the affines for `images` are nearly
9899
the same, raising a ``ValueError`` otherwise. Default is True
@@ -104,13 +105,14 @@ def concat_images(images, check_affines=True):
104105
dimension
105106
'''
106107
n_imgs = len(images)
107-
img0 = images[0]
108+
img0 = load(images[0])
108109
i0shape = img0.shape
109110
affine = img0.get_affine()
110111
header = img0.get_header()
111112
out_shape = (n_imgs, ) + i0shape
112113
out_data = np.empty(out_shape)
113114
for i, img in enumerate(images):
115+
img = load(img)
114116
if check_affines:
115117
if not np.all(img.get_affine() == affine):
116118
raise ValueError('Affines do not match')

0 commit comments

Comments
 (0)