The uns_merge argument in ad.concat() controls how the .uns (unstructured metadata) dictionaries are combined. These strategies are applied recursively, meaning they respect the nested structure of the dictionaries.
Available strategies for uns_merge:
None: Returns an empty dictionary {}."same": Keeps only the keys and nested values that are exactly the same across all objects."unique": Keeps keys where there is only one possible value across all objects (a superset of "same")."only": Keeps only the keys/values that appear in exactly one of the input objects."first": Takes the union of all keys and uses the value from the first object that contains that key.
This is particularly useful for preserving pipeline parameters or metadata (like spatial images) that are shared or unique to specific subsets.
# Example of recursive uns merging
# If a = {a: 1, c: {c.a: 3, c.b: 4}}
# b = {a: 1, c: {c.b: 4}}
# c = {a: 1, c: {c.a: 3, c.b: 4, c.c: 5}}
# Result with uns_merge="same":
# {'a': 1, 'c': {'c.b': 4}}
# Result with uns_merge="unique":
# {'a': 1, 'c': {'c.a': 3, 'c.b': 4, 'c.c': 5}}
# Result with uns_merge="first":
# {'a': 1, 'b': 2, 'c': {'c.a': 3, 'c.b': 4, 'c.c': 5}}