wtclarke / pymapvbvd

Python port of mapVBVD
MIT License
40 stars 25 forks source link

IndexError: shape mismatch #2

Closed wizofe closed 4 years ago

wizofe commented 4 years ago

When I am trying to use my own data file I am getting the following error. This file works fine in MATLAB and the original VBVD.

The command I am using:

twix.image.squeeze = False
out = twix.image['']

And the error:

---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
 in 
      1 # Which can be squeezed
      2 twix.image.squeeze = False
----> 3 out = twix.image['']

~/usr/local/miniconda3/envs/pytorch-latest/lib/python3.8/site-packages/mapVBVD/twix_map_obj.py in __getitem__(self, key)
    377         tmp = np.arange(0,self.fullSize[2:].prod().astype(int)).reshape(self.fullSize[2:].astype(int))
    378         #tmpSelRange = [x-1 for x in selRange] # python indexing from 0
--> 379         tmp = tmp[tuple(selRange[2:])]
    380         ixToRaw = ixToRaw[tmp]
    381         ixToRaw = ixToRaw.ravel()

IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (360,) (112,) (1,) (1,) (1,) (1,) (1,) (1,) (12,) (1,) (1,) (1,) (1,) (1,) 

Any help is appreciated.

wtclarke commented 4 years ago

Hi @wizofe, Sorry for the long delay in getting back to you. I've recently been working on this code again. Are you happy to share the bit of the data so I can take a look?

One of my colleagues has recently worked on this to make it work and test with imaging data. It might therefore be already fixed.

wizofe commented 4 years ago

Hi @wexeee thanks for your answer. Meanwhile, I discovered that I could use a different package, namely twixtools.

I can share the data but it's a very large raw file (about 2.5GB), so I am not really sure how I can sent this through :-) Let me know if you have any ideas, or ideas to make it smaller (if for example, I could somehow trim it).

Let me know if you have an updated code, I might try that!

wtclarke commented 4 years ago

Hi @wizofe v0.4.1 is now available through pypi or conda (forge). If you did have a moment to try it could you let me know if it does work on your data? Or you can send me the data through my institutions webpages: https://oxfile.ox.ac.uk/oxfile/work/extBox?id=928163F5D71D586DE0

Rather amusing to see that @pehses has made a new python reader given that this is a port of his original matlab code. I'm sure that twixtools will work very well!

wizofe commented 4 years ago

Hi @wexeee Will, thanks for your answer! I tried the new version and it works fine with my data (albeit considerably slower). I do like the graphical representation of a loading bar though, cool feature!

I didn't know that the reader was made by @pehses, funny :) Maybe you should merge it? Just an idea! Thanks for the implementation anyway!