AthenaEPI / dmipy

The open source toolbox for reproducible diffusion MRI-based microstructure estimation
MIT License
96 stars 30 forks source link

None delta causes error in gtab_dmipy2dipy #78

Closed matteofrigo closed 4 years ago

matteofrigo commented 4 years ago

When a gradient table is converted from dmipy to dipy format and delta is None or Delta is None, the devoted function gives the following error.

In [8]: gtab_dmipy2dipy(gtab_dmipy)                                                 
None
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-8-89848d3de32f> in <module>
----> 1 gtab_dmipy2dipy(scheme)

/home/user/dmipy/dmipy/core/acquisition_scheme.py in gtab_dmipy2dipy(dmipy_gradient_table)
    907     elif len(np.unique(delta)) == 1:
--> 908         delta = delta[0]
    909 
    910     if len(np.unique(Delta)) > 1:

TypeError: 'NoneType' object is not subscriptable

and this happens also at line 911 for Delta.

A simple hack that fixes this problem is to change the checks in lines 907 and 910 as follows:

elif delta is not None and len(np.unique(delta)) == 1:
...
elif Delta is not None and len(np.unique(Delta)) == 1:

I'll put up a PR with this in the close future.

rutgerfick commented 4 years ago

The early bird gets the worm ;-) well spotted @matteofrigo