code: def _field_gradient_jac_Map_(i, ref, target, targeti):
      """
      Given a reference field ref and a target field target
      compute the jacobian of the target with respect to ref
      """
      import scipy.linalg as nl
  
      xyz = ref.field
      fgj = []
      ln = ref.list_of_neighbors()
      j = ln[i]
      if np.size(j) > 0:
          dx = xyz[j] - xyz[i]
          dx = np.squeeze(dx)
          idx = nl.pinv(dx)
          for k in range(targeti.shape[0]):
              df = target[j] - targeti[k]
              df = np.squeeze(df)
              fg = np.dot(idx, df)
              fgj.append(nl.det(fg))
      else:
          fgj = np.zeros(targeti.shape[0])
  
      fgj = np.array(fgj)
      return fgj
  
file_path: nipy/nipy/labs/spatial_models/hierarchical_parcellation.py
imports: from warnings import warn
  import numpy
  from numpy.random import rand
  from nipy.algorithms.clustering.utils import kmeans, voronoi
  from nipy.algorithms.graph.field import Field
  from nipy.algorithms.graph.graph import wgraph_from_coo_matrix
  from .parcellation import MultiSubjectParcellation
label_desc: Use image node_id 6 for calling a global function with example usage: _field_gradient_jac_Map_(i, ref, target, targeti) and returns: fgj