nodes: 0, module; 1, function_definition; 2, function_name:split_unit; 3, parameters; 4, block; 5, identifier:self; 6, identifier:unit_id; 7, identifier:indices; 8, expression_statement; 9, expression_statement; 10, for_statement; 11, if_statement; 12, string; 13, assignment; 14, identifier:i; 15, call; 16, block; 17, parenthesized_expression; 18, block; 19, else_clause; 20, string_content:This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids
          and roots that have the split root as a child. This function splits the spike train of the root by the given indices.
  
          Parameters
          ----------
          unit_id: int
              The unit id to be split
          indices: list
              The indices of the unit spike train at which the spike train will be split.; 21, identifier:root_ids; 22, list; 23, identifier:range; 24, argument_list; 25, expression_statement; 26, expression_statement; 27, comparison_operator:unit_id in root_ids; 28, expression_statement; 29, expression_statement; 30, expression_statement; 31, expression_statement; 32, try_statement; 33, expression_statement; 34, expression_statement; 35, delete_statement; 36, expression_statement; 37, expression_statement; 38, expression_statement; 39, expression_statement; 40, expression_statement; 41, expression_statement; 42, expression_statement; 43, expression_statement; 44, expression_statement; 45, expression_statement; 46, expression_statement; 47, expression_statement; 48, for_statement; 49, delete_statement; 50, delete_statement; 51, block; 52, call; 53, assignment; 54, call; 55, identifier:unit_id; 56, identifier:root_ids; 57, assignment; 58, assignment; 59, assignment; 60, assignment; 61, block; 62, except_clause; 63, assignment; 64, assignment; 65, identifier:original_spike_train; 66, assignment; 67, call; 68, assignment; 69, call; 70, call; 71, assignment; 72, call; 73, assignment; 74, call; 75, call; 76, call; 77, call; 78, identifier:feature_name; 79, call; 80, block; 81, subscript; 82, subscript; 83, raise_statement; 84, identifier:len; 85, argument_list; 86, identifier:root_id; 87, attribute; 88, attribute; 89, argument_list; 90, identifier:indices_1; 91, call; 92, identifier:root_index; 93, call; 94, identifier:new_child; 95, subscript; 96, identifier:original_spike_train; 97, call; 98, expression_statement; 99, identifier:IndexError; 100, block; 101, identifier:indices_2; 102, call; 103, identifier:spike_train_2; 104, subscript; 105, identifier:new_root_1_id; 106, binary_operator:max(self._all_ids)+1; 107, attribute; 108, argument_list; 109, identifier:new_root_1; 110, call; 111, attribute; 112, argument_list; 113, attribute; 114, argument_list; 115, identifier:new_root_2_id; 116, binary_operator:max(self._all_ids)+1; 117, attribute; 118, argument_list; 119, identifier:new_root_2; 120, call; 121, attribute; 122, argument_list; 123, attribute; 124, argument_list; 125, attribute; 126, argument_list; 127, attribute; 128, argument_list; 129, attribute; 130, argument_list; 131, expression_statement; 132, expression_statement; 133, expression_statement; 134, attribute; 135, identifier:unit_id; 136, attribute; 137, identifier:root_index; 138, call; 139, attribute; 140, subscript; 141, identifier:unit_id; 142, identifier:root_ids; 143, identifier:append; 144, identifier:root_id; 145, attribute; 146, argument_list; 147, attribute; 148, argument_list; 149, attribute; 150, identifier:root_index; 151, attribute; 152, argument_list; 153, assignment; 154, expression_statement; 155, identifier:list; 156, argument_list; 157, identifier:original_spike_train; 158, identifier:indices_2; 159, call; 160, integer:1; 161, attribute; 162, identifier:append; 163, identifier:new_root_1_id; 164, identifier:Unit; 165, argument_list; 166, identifier:new_root_1; 167, identifier:add_child; 168, identifier:new_child; 169, identifier:new_root_1; 170, identifier:set_spike_train; 171, identifier:spike_train_1; 172, call; 173, integer:1; 174, attribute; 175, identifier:append; 176, identifier:new_root_2_id; 177, identifier:Unit; 178, argument_list; 179, identifier:new_root_2; 180, identifier:add_child; 181, identifier:new_child; 182, identifier:new_root_2; 183, identifier:set_spike_train; 184, identifier:spike_train_2; 185, attribute; 186, identifier:append; 187, identifier:new_root_1; 188, attribute; 189, identifier:append; 190, identifier:new_root_2; 191, identifier:self; 192, identifier:get_unit_spike_feature_names; 193, identifier:unit_id; 194, assignment; 195, call; 196, call; 197, identifier:self; 198, identifier:_unit_features; 199, identifier:self; 200, identifier:_roots; 201, identifier:ValueError; 202, argument_list; 203, identifier:self; 204, identifier:_roots; 205, attribute; 206, identifier:i; 207, identifier:np; 208, identifier:sort; 209, call; 210, identifier:root_ids; 211, identifier:index; 212, identifier:unit_id; 213, identifier:self; 214, identifier:_roots; 215, subscript; 216, identifier:get_spike_train; 217, identifier:spike_train_1; 218, subscript; 219, call; 220, binary_operator:set(range(len(original_spike_train))) - set(indices_1); 221, identifier:max; 222, argument_list; 223, identifier:self; 224, identifier:_all_ids; 225, identifier:new_root_1_id; 226, identifier:max; 227, argument_list; 228, identifier:self; 229, identifier:_all_ids; 230, identifier:new_root_2_id; 231, identifier:self; 232, identifier:_roots; 233, identifier:self; 234, identifier:_roots; 235, identifier:full_features; 236, call; 237, attribute; 238, argument_list; 239, attribute; 240, argument_list; 241, binary_operator:str(unit_id) + " non-valid unit id"; 242, identifier:self; 243, identifier:_roots; 244, attribute; 245, argument_list; 246, attribute; 247, identifier:root_index; 248, identifier:original_spike_train; 249, identifier:indices_1; 250, identifier:print; 251, argument_list; 252, call; 253, call; 254, attribute; 255, attribute; 256, attribute; 257, argument_list; 258, identifier:self; 259, identifier:set_unit_spike_features; 260, identifier:new_root_1_id; 261, identifier:feature_name; 262, subscript; 263, identifier:self; 264, identifier:set_unit_spike_features; 265, identifier:new_root_2_id; 266, identifier:feature_name; 267, subscript; 268, call; 269, string:" non-valid unit id"; 270, identifier:np; 271, identifier:asarray; 272, call; 273, identifier:self; 274, identifier:_roots; 275, binary_operator:str(indices) + " out of bounds for the spike train of " + str(unit_id); 276, identifier:set; 277, argument_list; 278, identifier:set; 279, argument_list; 280, identifier:self; 281, identifier:_all_ids; 282, identifier:self; 283, identifier:_all_ids; 284, identifier:self; 285, identifier:get_unit_spike_features; 286, identifier:unit_id; 287, identifier:feature_name; 288, identifier:full_features; 289, identifier:indices_1; 290, identifier:full_features; 291, identifier:indices_2; 292, identifier:str; 293, argument_list; 294, identifier:list; 295, argument_list; 296, binary_operator:str(indices) + " out of bounds for the spike train of "; 297, call; 298, call; 299, identifier:indices_1; 300, identifier:unit_id; 301, call; 302, call; 303, string:" out of bounds for the spike train of "; 304, identifier:str; 305, argument_list; 306, identifier:range; 307, argument_list; 308, identifier:set; 309, argument_list; 310, identifier:str; 311, argument_list; 312, identifier:unit_id; 313, call; 314, identifier:indices; 315, identifier:indices; 316, identifier:len; 317, argument_list; 318, identifier:original_spike_train
code: def split_unit(self, unit_id, indices):
          '''This function splits a root from the curation tree according to the given unit_id and indices. It creates two new unit_ids
          and roots that have the split root as a child. This function splits the spike train of the root by the given indices.
  
          Parameters
          ----------
          unit_id: int
              The unit id to be split
          indices: list
              The indices of the unit spike train at which the spike train will be split.
          '''
          root_ids = []
          for i in range(len(self._roots)):
              root_id = self._roots[i].unit_id
              root_ids.append(root_id)
  
          if(unit_id in root_ids):
              indices_1 = np.sort(np.asarray(list(set(indices))))
  
              root_index = root_ids.index(unit_id)
              new_child = self._roots[root_index]
              original_spike_train = self._roots[root_index].get_spike_train()
  
              try:
                  spike_train_1 = original_spike_train[indices_1]
              except IndexError:
                  print(str(indices) + " out of bounds for the spike train of " + str(unit_id))
  
              indices_2 = list(set(range(len(original_spike_train))) - set(indices_1))
              spike_train_2 = original_spike_train[indices_2]
              del original_spike_train
  
              new_root_1_id = max(self._all_ids)+1
              self._all_ids.append(new_root_1_id)
              new_root_1 = Unit(new_root_1_id)
              new_root_1.add_child(new_child)
              new_root_1.set_spike_train(spike_train_1)
  
              new_root_2_id = max(self._all_ids)+1
              self._all_ids.append(new_root_2_id)
              new_root_2 = Unit(new_root_2_id)
              new_root_2.add_child(new_child)
              new_root_2.set_spike_train(spike_train_2)
  
              self._roots.append(new_root_1)
              self._roots.append(new_root_2)
  
              for feature_name in self.get_unit_spike_feature_names(unit_id):
                  full_features = self.get_unit_spike_features(unit_id, feature_name)
                  self.set_unit_spike_features(new_root_1_id, feature_name, full_features[indices_1])
                  self.set_unit_spike_features(new_root_2_id, feature_name, full_features[indices_2])
              del self._unit_features[unit_id]
              del self._roots[root_index]
          else:
              raise ValueError(str(unit_id) + " non-valid unit id")