0
import nibabel
nibabel.processing.resample_to_output(input_img, voxel_size)
AttributeError: module 'nibabel' has no attribute 'processing'
import nibabel
import nibabel.processing
nibabel.processing.resample_to_output(input_img, voxel_size)

Why does the first code fail but the second code work?

asked Apr 8, 2020 at 2:26
2
  • 1
    Because, as the error states, the module nibabel doesn't have a .processing attribute. The module nibabel.processing exists, but that doesn't mean that it is an attribute on nibabel. Commented Apr 8, 2020 at 2:28
  • @Crispy13. Do see my answer and let me know if it helps Commented Apr 8, 2020 at 18:32

1 Answer 1

1

Expanding on @juanpa answer in the comments, you can simply consider these as two different modules.

For this

import nibabel

You get the error which suggests that this module does not have an attribute named processing

But for this

import nibabel.processing

It works fine since itself can be considered a module and thus means that processing is not an attribute of nibabel.

So it looks the code that you are trying to run only requires the 2nd import and not the first.

answered Apr 8, 2020 at 3:04
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.