class_docstr: Wrapper for Siemens format DICOMs
  
  Adds attributes:
  
  * csa_header : mapping
  * b_matrix : (3,3) array
  * q_vector : (3,) array
docstr: Get DWI B matrix referring to voxel space
  
  Parameters
  ----------
  None
  
  Returns
  -------
  B : (3,3) array or None
     B matrix in *voxel* orientation space.  Returns None if this is
     not a Siemens header with the required information.  We return
     None if this is a b0 acquisition
docstr_tok: ["Get","DWI","B","matrix","referring","to","voxel","space","Parameters","--","--","--","--","--","None","Returns","--","--","--","-","B",":","(","3,3",")","array","or","None","B","matrix","in","*","voxel","*","orientation","space",".","Returns","None","if","this","is","not","a","Siemens","header","with","the","required","information",".","We","return","None","if","this","is","a","b0","acquisition"]
code: def b_matrix(self):
      """Get DWI B matrix referring to voxel space
  
      Parameters
      ----------
      None
  
      Returns
      -------
      B : (3,3) array or None
         B matrix in *voxel* orientation space.  Returns None if this is
         not a Siemens header with the required information.  We return
         None if this is a b0 acquisition
      """
      hdr = self.csa_header
      # read B matrix as recorded in CSA header.  This matrix refers to
      # the space of the DICOM patient coordinate space.
      B = csar.get_b_matrix(hdr)
      if B is None:  # may be not diffusion or B0 image
          bval_requested = csar.get_b_value(hdr)
          if bval_requested is None:
              return None
          if bval_requested != 0:
              raise csar.CSAError("No B matrix and b value != 0")
          return np.zeros((3, 3))
      # rotation from voxels to DICOM PCS, inverted to give the rotation
      # from DPCS to voxels.  Because this is an orthonormal matrix, its
      # transpose is its inverse
      R = self.rotation_matrix.T
      # because B results from V dot V.T, the rotation B is given by R dot
      # V dot V.T dot R.T == R dot B dot R.T
      B_vox = np.dot(R, np.dot(B, R.T))
      # fix presumed rounding errors in the B matrix by making it positive
      # semi-definite.
      return nearest_pos_semi_def(B_vox)
  
imports: import operator
  import warnings
  import numpy
  from nibabel.optpkg import optional_package
  from ..onetime import auto_attr
  from ..openers import ImageOpener
  from .None import csareader
  from .dwiparams import B2q, nearest_pos_semi_def, q2bg
label_desc: Use image node_id 4 for calling the SiemensWrapper obj's underlying member method code with example usage: obj.b_matrix() and returns: nearest_pos_semi_def, np, None