Skip to content

nibabel.concat_images returns 5D images from 4D images #207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
GaelVaroquaux opened this issue Oct 11, 2013 · 3 comments
Closed

nibabel.concat_images returns 5D images from 4D images #207

GaelVaroquaux opened this issue Oct 11, 2013 · 3 comments

Comments

@GaelVaroquaux
Copy link
Member

If I concat a list of 4D images, I get a 5D image.

I was a bit surprised by this behavior: this is not what I was expecting from the docstring.

Maybe an option to avoid this behavior, and concat along the last axis, and not the last+1 axis would be useful. Another option would be to concat along a specified axis (given as a kwarg to concat_images), that could be '4' by default.

@matthew-brett
Copy link
Member

Yes, I agree it can be confusing. An axis argument seems like a good solution.

@bcipolli
Copy link
Contributor

Is there a recommended solution to this? I couldn't find any elegant ways to eliminate the unary 4th dimension. Since my images were size 1 in the 4th dimension, I could do:

all_files = glob.glob('fM00223/*.img')
all_images = [nibabel.funcs.four_to_three(nibabel.load(f))[0] for f in all_files]
func_img = nibabel.funcs.concat_images(all_images)

@matthew-brett
Copy link
Member

I'm sorry, I just ran out of time for the 2.0 release, but I still agree that an axis keyword would be good. Do you have any time to hack that up as a pull-request? That would be the best solution. Otherwise it's pretty easy to do by hand, by adapting the code in concat_images.

grlee77 pushed a commit to grlee77/nibabel that referenced this issue Mar 15, 2016
MRG: Add an 'axis' parameter to concat_images, plus two tests

Add ability to concatenate images over given axis, with tests.

Closes nipy#207
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants