SebastianoF/bruker2nifti

numpy 1.12.0 rejects floats as reshape arguments

gdevenyi opened this issue · 8 comments

This section of code
https://github.com/SebastianoF/bruker2nifti/blob/master/bruker2nifti/_getters.py#L161-L166

Dies on numpy 1.12.0 with the following error:

/home/cic/desgab/Desktop/bruker2nifti_qa-master/raw/McGill_Orientation/a20130329_APM_DEV_Orient.j71
started:


Converting experiment 1:

pdata/
   1/
       d3proc
       id
       meta
       roi
       2dseq
       visu_pars
       procs
       reco
Traceback (most recent call last):
 File "test_b2n.py", line 9, in <module>
   bru.convert()
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 185, in convert
   nifti_file_name=scan_name)
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 137, in convert_scan
   get_reco=self.get_reco,
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_cores.py", line 150, in scan2struct
   consider_subject_position=consider_subject_position
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_getters.py", line 166, in nifti_getter
   vol_data = img_data_vol.reshape(vol_pre_shape, order='F')
TypeError: 'numpy.float64' object cannot be interpreted as an integer

Thanks! Maybe solved on the dev branch.
Can you please check if it works on your side, as I could not reproduce the error with my current dataset.

Still bugged, now with a reshape problem

/home/cic/desgab/Desktop/bruker2nifti_qa-master/raw/McGill_Orientation/a20130329_APM_DEV_Orient.j71
started:


Converting experiment 1:

pdata/
   1/
       d3proc
       id
       meta
       roi
       2dseq
       visu_pars
       procs
       reco
Traceback (most recent call last):
 File "test_b2n.py", line 9, in <module>
   bru.convert()
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 185, in convert
   nifti_file_name=scan_name)
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 137, in convert_scan
   get_reco=self.get_reco,
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_cores.py", line 150, in scan2struct
   consider_subject_position=consider_subject_position
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_getters.py", line 167, in nifti_getter
   vol_data = img_data_vol.reshape(vol_pre_shape, order='F')
ValueError: cannot reshape array of size 66 into shape (256,256,15,0)

Uhm... It seems that the information in the Bruker parameters files does not match the dimension of the array. Try to copy your data in a new place, erase folder 1 and see if the other experiments are converted correctly. So I will know how much do I have to worry :-) ! Let me know.

BTW, this is the test data from the repo....

Study conversion
/home/cic/desgab/Desktop/bruker2nifti_qa-master/raw/McGill_Orientation/a20130329_APM_DEV_Orient.j71
started:


Converting experiment 2:

pdata/
   1/
       d3proc
       meta
       2dseq
       procs
       visu_pars
       roi
       id
       reco
Traceback (most recent call last):
 File "test_b2n.py", line 9, in <module>
   bru.convert()
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 185, in convert
   nifti_file_name=scan_name)
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/converter.py", line 137, in convert_scan
   get_reco=self.get_reco,
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_cores.py", line 150, in scan2struct
   consider_subject_position=consider_subject_position
 File "/home/cic/desgab/Desktop/bruker2nifti/bruker2nifti/_getters.py", line 167, in nifti_getter
   vol_data = img_data_vol.reshape(vol_pre_shape, order='F')
ValueError: cannot reshape array of size 65 into shape (64,64,32,0)

Hi, sorry I had time to look into it only now.
The odd thing is, I could not reproduce the error with the same dataset (bruker2nifti_qa-master downloaded 30 Mar 2015).

With python3, numpy==1.12.0, bruker2nifti installed in development mode, on a mac the error I get is:

File "/Applications/python_virtualenvs/clean3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 774, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'numpy>=1.12.1' distribution was not found and is required by bruker2nifti

With numpy==1.12.1 no errors are raised.
Idem if using python2.

I am unable to reproduce my user's errors in a clean environment, so I'm considering the original bug fixed and closed. Thanks.

Followup: error due to user not having git-lfs when getting a copy of the QA repo.