Nipype SpecifySparseModel error

Hi nipype gurus!

I was having a problem with SpecifySparseModel and found a fix, but I’d like to make sure I’m not messing something up down the line. I’d previously been using nipype v 0.10.0 with no problem, and recently upgraded to v 0.12.1

When using SpecifySparseModel, I get the error on line 655 of modelgen.py

boxcar = np.zeros((50.0 * 1e3 / dt))
TypeError: 'float' object cannot be interpreted as an index

Earlier in the modelgen.py script, I noticed that in the newer version (line 643) explicitly declares variable dt to be a float, i.e.:

`dt = float(gcd(dttemp, dt))`

In the older version of nipype, there was no explicit declaration. Since it seems my version of python doesn’t seem to like a float as an index, I changed the float declaration to int, and everything works just fine.

So my question is: Was there a reason for the explicit float declaration? Am I messing something up further down the pipeline with this change? (Clearly python is not my forte, so apologies if there is an obvious answer.)

Thanks very much!
Jenn Segawa

@jenns this error has to do with another python package we depend on - numpy - upgrading their code. We’ve since then patched the problem in our latest master branch on github, and will be releasing v0.13.0 shortly. Hope this helps!

Fantastic…thanks for your help!

Jenn

Hello,

I seem to having a similar problem, but the above suggestion does not seem to be working for me. For reference, I am using Python 2.7.13, nipype 0.12.1, and numpy 1.13.0

When I change line 643 to “int” i.e.,
dt = int(gcd(dttemp, dt))

I get the following error, which is the same error I got when I left it as “float”
TypeError: 'float' object cannot be interpreted as an index

When I change line 643 to:
dt = gcd(dttemp, dt)

I get the following error:
TypeError:'numpy.float64' object cannot be interpreted as an index

Any suggestions for what to try next? Thanks in advance for the help! I am pretty new to python and nipype in general, so apologies if this is a really obvious answer.

Thanks!
Liz Heller Murray

The latest version of nipype is 0.13.1. Can you try upgrading and see if the problem persists?