Skip to content

ValueError when using complex64 with cgrappa #79

@zaccharieramzi

Description

@zaccharieramzi

Hi, thanks very much for this implementation.

I tried to use cgrappa with np.complex64 data and got the following error:

ValueError                                Traceback (most recent call last)
<ipython-input-4-2802ffa5c73b> in <module>
     12 # coil_axis=-1 is default, so if coil dimension is last we don't
     13 # need to explicity provide it
---> 14 res = cgrappa(kspace, calib, kernel_size=(5, 5))
     15 sx, sy, ncoils = res.shape[:]

src/cgrappa.pyx in cgrappa.cgrappa()

ValueError: Buffer dtype mismatch, expected 'double complex' but got 'complex float'

The code to reproduce the error is the following:

from pygrappa import cgrappa 
import numpy as np 

kspace = np.random.normal(size=[640, 372, 15]) 
kspace = kspace.astype(np.complex64) 


sx, sy, ncoils = kspace.shape[:] # center 20 lines are ACS 
ctr, pd = int(sy/2), 10 
calib = kspace[:, ctr-pd:ctr+pd, :].copy() # call copy()! 

# coil_axis=-1 is default, so if coil dimension is last we don't 
# need to explicity provide it 
res = cgrappa(kspace, calib, kernel_size=(5, 5)) 
sx, sy, ncoils = res.shape[:]             

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions