Exemplo n.º 1
0
 def calculate(self, acqs):
     if acqs.is_sorted() is False:
         print('WARNING: acquisitions may be in a wrong order')
     if self.handle is not None:
         pygadgetron.deleteObject(self.handle)
     self.handle = pygadgetron.cGT_CoilSensitivities('')
     _check_status(self.handle)
     _set_int_par\
         (self.handle, 'coil_sensitivity', 'smoothness', self.smoothness)
     handle = pygadgetron.cGT_computeCoilSensitivities\
         (self.handle, acqs.handle)
     _check_status(handle)
     pygadgetron.deleteDataHandle(handle)
Exemplo n.º 2
0
 def calculate(self, data, method=None):
     '''
     Calculates coil sensitivity maps from coil images or sorted 
     acquisitions.
     data  : either AcquisitionData or CoilImages
     method: either SRSS (Square Root of the Sum of Squares, default) or 
             Inati
     '''
     if isinstance(data, AcquisitionData):
         if data.is_sorted() is False:
             print('WARNING: acquisitions may be in a wrong order')
     if self.handle is not None:
         pyiutil.deleteDataHandle(self.handle)
     self.handle = pygadgetron.cGT_CoilSensitivities('')
     check_status(self.handle)
     if method is not None:
         method_name, parm_list = name_and_parameters(method)
         parm = parse_arglist(parm_list)
     else:
         method_name = 'SRSS'
         parm = {}
     if isinstance(data, AcquisitionData):
         assert data.handle is not None
         _set_int_par\
             (self.handle, 'coil_sensitivity', 'smoothness', self.smoothness)
         try_calling(pygadgetron.cGT_computeCoilSensitivities\
             (self.handle, data.handle))
     elif isinstance(data, CoilImageData):
         assert data.handle is not None
         if method_name == 'Inati':
             if not HAVE_ISMRMRDTOOLS:
                 raise error('Inati method requires ismrmrd-python-tools')
             nz = data.number()
             for z in range(nz):
                 ci = numpy.squeeze(data.as_array(z))
                 (csm, rho) = coils.calculate_csm_inati_iter(ci)
                 self.append(csm.astype(numpy.complex64))
         elif method_name == 'SRSS':
             if 'niter' in parm:
                 nit = int(parm['niter'])
                 _set_int_par\
                     (self.handle, 'coil_sensitivity', 'smoothness', nit)
             try_calling(pygadgetron.cGT_computeCSMsFromCIs\
                 (self.handle, data.handle))
         else:
             raise error('Unknown method %s' % method_name)
     else:
         raise error('Cannot calculate coil sensitivities from %s' % \
                     repr(type(data)))
Exemplo n.º 3
0
 def append(self, csm):
     '''
     Appends a coil sensitivity map to self.
     csm: Numpy ndarray with csm values
     '''
     if self.handle is None:
         self.handle = pygadgetron.cGT_CoilSensitivities('')
         check_status(self.handle)
     shape = csm.shape
     nc = shape[0]
     if csm.ndim == 4:
         nz = shape[1]
         iy = 2
     else:
         nz = 1
         iy = 1
     ny = shape[iy]
     nx = shape[iy + 1]
     re = csm.real.copy()
     im = csm.imag.copy()
     handle = pygadgetron.cGT_appendCSM\
         (self.handle, nx, ny, nz, nc, re.ctypes.data, im.ctypes.data)
     check_status(handle)
     pyiutil.deleteDataHandle(handle)
Exemplo n.º 4
0
 def read(self, file):
     if self.handle is not None:
         pyiutil.deleteDataHandle(self.handle)
     self.handle = pygadgetron.cGT_CoilSensitivities(file)
     check_status(self.handle)
Exemplo n.º 5
0
 def read(self, file):
     if self.handle is not None:
         pygadgetron.deleteObject(self.handle)
     self.handle = pygadgetron.cGT_CoilSensitivities(file)
     _check_status(self.handle)