I am using the nibabel package to load an image with 7 parcellations in it. It is a .nii.gz file and when I try to load it with nibable.load('image_file') I get the following error:

File "<ipython-input-8-ef77bd97a272>", line 1
SyntaxError: invalid syntax

I downloaded the file from here: http://surfer.nmr.mgh.harvard.edu/fswiki/CerebellumParcellation_Buckner2011

How can I load this file in nibabel and view it?

  • $\begingroup$ Is this Q in any way related to Psych&Neurosci? $\endgroup$ – AliceD Nov 7 at 23:00
  • $\begingroup$ It's concerning a tool used for fMRI analysis so yeah It is obviously relevant. $\endgroup$ – Angus Campbell Nov 8 at 5:50
  • 1
    $\begingroup$ Why do you have nib.load(r'string')? When you get a syntax error, check your syntax. Use an editor with syntax highlighting. $\endgroup$ – Bryan Krause Nov 8 at 5:59
  • $\begingroup$ On windows OS the backslash will be treated as escape characters so the r is necessary for the string to be treated as a raw sting. See here:stackoverflow.com/questions/42654934/… $\endgroup$ – Angus Campbell Nov 8 at 8:32
  • $\begingroup$ Also my question was answered on stack overflow, the variable name can't start with a number. I'm using spyder as my editor, it is a perfectly respectable datascience ODE. $\endgroup$ – Angus Campbell Nov 8 at 8:33

Turns out my variable name cannot start with a number, the 7 must be removed from 7net_Buckner_img.

Here is the post on stackoverflow https://stackoverflow.com/questions/58761152/unzipping-a-nii-gz-file-in-python?noredirect=1#comment103811127_58761152

  • 1
    $\begingroup$ As Alice asked above, how is this related to psychology & co.? $\endgroup$ – Quora Feans Nov 8 at 13:27
  • $\begingroup$ It concerns a question about an issue I had using nibabel which is a comonnonly used python library for fMRI analysis. I'm sorry its not some vague philosophical question as 90% of the questions on here are and is instead about a tool for actually doing research on the brain. I posted it here because I believed a stackexchange devoted to neuroscience would have better knowledge concerning a library designed for analyzing fMRI. But apparently not, not only was no help given I have been berated by people who seem ignorant of their own field. $\endgroup$ – Angus Campbell Nov 8 at 16:41
  • 1
    $\begingroup$ Sound like a programming in a boat kind of question: meta.stackexchange.com/questions/14470/… SyntaxError is not specific to any package. $\endgroup$ – Quora Feans Nov 8 at 17:13
  • $\begingroup$ 90% of the questions on here are related to psychology and neuroscience rather than the programming related to brain research. Imagine if you are a clinical psychologist or a neuroscientist that work on animals, this question would be very off topic for them and very alienating as well. Not only have you not got answers for your programming question, it is really discouraging for those of us who are not programmers or brain research scientists. You have the option of deleting this question. $\endgroup$ – Poidah Nov 11 at 23:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.