Nibabel concatenating images

Preformatted text``Preformatted textHi,

We have an old study that involved two scans per session seperated by a task. We’re ultimately interested in dnamic connectivity which we’re going to run with conn_toolbox. However, despite the thread linked below, it doesn’t seem to accept assigning multiple image files per session.

https://www.nitrc.org/forum/forum.php?thread_id=11507&forum_id=1144

I’m therefore trying to concatenate them using nibabel. I’m unable to load them properly using

nib.Nifti1Image.from_filename(PATH)
however when I try to concatenate them using
ni.bfuncs.concat_images(imgs)
it gives the error message shown below
nibabel.spatialimages.HeaderDataError: data code 30588 not recognized

I then tried what was suggested in this thread. However, it ended up giving as error that

AttributeError: ‘str’ object has no attribute ‘shape’
in the step to load the image with the header specified and the affine specified to None (it required that the poisitonal argument be there).

Any help would be greatly appreciated, thanks.

I suppose there are a number of ways to do what you want from what I understand. For example, nilearn provides a function to directly concatenate images:

Also you could get the data and use np.concatenate: numpy.concatenate — NumPy v1.26 Manual

In order to give you more detailed help, it would be good if you post a minimal reproducible example with the exact code that you have used so far.