code: def _get_group_parameters(
      group_assignment, n_subjects, pairwise=False
  ):
      # Set up dictionary to contain group info
      group_parameters = {
          "group_assignment": group_assignment,
          "n_subjects": n_subjects,
          "group_labels": None,
          "groups": None,
          "sorter": None,
          "unsorter": None,
          "group_matrix": None,
          "group_selector": None,
      }
  
      # Set up group selectors for two-group scenario
      if group_assignment and len(np.unique(group_assignment)) == 2:
          group_parameters["n_groups"] = 2
  
          # Get group labels and counts
          group_labels = np.unique(group_assignment)
          groups = {
              group_labels[0]: group_assignment.count(group_labels[0]),
              group_labels[1]: group_assignment.count(group_labels[1]),
          }
  
          # For two-sample pairwise approach set up selector from matrix
          if pairwise:
              # Sort the group_assignment variable if it came in shuffled
              # so it's easier to build group assignment matrix
              sorter = np.array(group_assignment).argsort()
              unsorter = np.array(group_assignment).argsort().argsort()
  
              # Populate a matrix with group assignments
              upper_left = np.full(
                  (groups[group_labels[0]], groups[group_labels[0]]),
                  group_labels[0],
              )
              upper_right = np.full(
                  (groups[group_labels[0]], groups[group_labels[1]]),
                  np.nan,
              )
              lower_left = np.full(
                  (groups[group_labels[1]], groups[group_labels[0]]),
                  np.nan,
              )
              lower_right = np.full(
                  (groups[group_labels[1]], groups[group_labels[1]]),
                  group_labels[1],
              )
              group_matrix = np.vstack(
                  (
                      np.hstack((upper_left, upper_right)),
                      np.hstack((lower_left, lower_right)),
                  )
              )
              np.fill_diagonal(group_matrix, np.nan)
              group_parameters["group_matrix"] = group_matrix
  
              # Unsort matrix and squareform to create selector
              group_parameters["group_selector"] = squareform(
                  group_matrix[unsorter, :][:, unsorter], checks=False
              )
              group_parameters["sorter"] = sorter
              group_parameters["unsorter"] = unsorter
  
          # If leave-one-out approach, just user group assignment as selector
          else:
              group_parameters["group_selector"] = group_assignment
  
          # Save these parameters for later
          group_parameters["groups"] = groups
          group_parameters["group_labels"] = group_labels
  
      # Manage one-sample and incorrect group assignments
      elif (
          not group_assignment or len(np.unique(group_assignment)) == 1
      ):
          group_parameters["n_groups"] = 1
  
          # If pairwise initialize matrix of ones for sign-flipping
          if pairwise:
              group_parameters["group_matrix"] = np.ones(
                  (
                      group_parameters["n_subjects"],
                      group_parameters["n_subjects"],
                  )
              )
  
      elif len(np.unique(group_assignment)) > 2:
          raise ValueError(
              "This test is not valid for more than "
              "2 groups! (got {0})".format(
                  len(np.unique(group_assignment))
              )
          )
      else:
          raise ValueError("Invalid group assignments!")
  
      return group_parameters
  
imports: import numpy
  import logging
  from scipy.spatial.distance import squareform
  from itertools import combinations, permutations, product
  from brainiak.fcma.util import compute_correlation
  from brainiak.utils.utils import array_correlation, phase_randomize, p_from_null, _check_timeseries_input
label_desc: Use image node_id 10 for calling a global function with example usage: _get_group_parameters(group_assignment, n_subjects, pairwise) and returns: group_parameters