code: def linear_model_fit(data_images, mask_images, design_matrix, vector):
      """
      Helper function for group data analysis using arbitrary design matrix
      """
  
      # Prepare arrays
      data, vardata, xyz, mask = prepare_arrays(
          data_images, None, mask_images
      )
  
      # Create glm instance
      G = glm(data, design_matrix)
  
      # Compute requested contrast
      c = G.contrast(vector)
  
      # Compute z-map image
      zmap = np.zeros(data_images[0].shape).squeeze()
      zmap[tuple(xyz)] = c.zscore()
      zimg = Image(zmap, get_affine(data_images[0]))
  
      return zimg
  
imports: import numpy
  import scipy.stats
  from nibabel import Nifti1Image
  from nibabel.affines import apply_affine
  from ..algorithms.graph.field import field_from_graph_and_data
  from ..algorithms.graph.graph import wgraph_from_3d_grid
  from ..algorithms.statistics import empirical_pvalue
  from ..io.nibcompat import get_affine
  from .glm import glm
  from .group.permutation_test import permutation_test_onesample, permutation_test_twosample
label_desc: Use image node_id 8 for calling a global function with example usage: linear_model_fit(data_images, mask_images, design_matrix, vector) and returns: zimg