ccraddock / cluster_roi

Python script to perform the spatially constrained parcellation of functional MRI data as described in Craddock et al., Human Brain Mapp., 33 (9) 2012
http://ccraddock.github.io/cluster_roi/
39 stars 26 forks source link

Bug in make_local_connectivity_ones.py #7

Open xychen-ION opened 7 years ago

xychen-ION commented 7 years ago

I have installed numpy, scipy and nibabel with python version 2.7 and I am trying to test the code on the test data. But I meet an error when I run make_local_connectivity_ones. The error shows below:

" sparse_w=append(sparse_w,R[nzndx],1) Traceback (most recent call last):

File "", line 1, in sparse_w=append(sparse_w,R[nzndx],1)

File "/home/fbip018/anaconda3/envs/cxy_image_3/lib/python2.7/site-packages/numpy/lib/function_base.py", line 5003, in append return concatenate((arr, values), axis=axis)

IndexError: axis 1 out of bounds [0, 1) "

This error happens in line 155 in make_local_connectivity_ones.py which is the code "sparse_w=append(sparse_w,R[nzndx],1)". I don't know how to deal with it and I am sure the numpy is installed.

Thank you

mehrshadg commented 7 years ago

append function in older versions of scipy (I suspect this package is written with older versions of scipy) ignored the wrong dimension passed as the third argument and when I read the code for make_local_connectivity_ones the matrix dimension is wrong. So, I think if you pass zero as the third argument the code must work: sparse_w=append(sparse_w,R[nzndx],0)

xychen-ION commented 7 years ago

Thanks mehrshadg! Yes, I have tried it and it works. But I am not sure if it is exactly what author means. Because the code in line 153 is "sparse_i=append(sparse_i,ondx1d[nzndx]-1,0)", it makes no sense that the mistake you said could happen. I also found more bugs when I tried other function with test data and no function can pass. Can you have all function passed? I have the same suspect that this package is written with older versions of scipy. I have tried an older version of scipy (0.16.1) but it still can not work.

kelmok commented 5 years ago

Hi @mehrshadg @xychen-ION @ccraddock,

I got the same issue running the code (scipy 1.2.1, numpy 1.16.4, python 2.7).

   if not os.path.isfile('rm_ones_connectivity.npy'): make_local_connectivity_ones(maskname, 'rm_ones_connectivity.npy')
  File "make_local_connectivity_ones.py", line 155, in make_local_connectivity_ones
    sparse_i=append(sparse_i,(ondx1d[nzndx-1]-1),0)
  File "..anaconda3/envs/example_env2/lib/python2.7/site-packages/numpy/lib/function_base.py", line 4694, in append
    return concatenate((arr, values), axis=axis)
AxisError: axis 1 is out of bounds for array of dimension 1

does anyone have an update, or know which numpy/scipy version is compatible?

Thanks

caludia96 commented 5 years ago

I am getting the same AxisError. Please let me know of any updates. @ccraddock @kelmok

AlexLZM commented 3 years ago

Same error here. I changed 1 to 0 as @mehrshadg said and I have to change 'dtype' of variable 'a' to 'int' in binfile_parcellation.py to run all the scripts.

But unfortunately, all spatial correlation or time correlation output seems wrong. Tested with COBRE data subject 40046, n_cluster = 50. image

But random clustering works fine. image