Skip to content
Snippets Groups Projects
Commit 773d91cc authored by Andi Gerken's avatar Andi Gerken
Browse files

Added individual ids when creating entities

parent ea395db2
No related branches found
No related tags found
1 merge request!39Added individual ids when creating entities
Pipeline #51984 passed
...@@ -26,6 +26,7 @@ class Entity(h5py.Group): ...@@ -26,6 +26,7 @@ class Entity(h5py.Group):
category: str, category: str,
poses: Iterable = None, poses: Iterable = None,
name: str = None, name: str = None,
individual_id: int = None,
positions: Iterable = None, positions: Iterable = None,
orientations: Iterable = None, orientations: Iterable = None,
outlines: Iterable = None, outlines: Iterable = None,
...@@ -55,6 +56,9 @@ class Entity(h5py.Group): ...@@ -55,6 +56,9 @@ class Entity(h5py.Group):
entity.attrs["category"] = category entity.attrs["category"] = category
if individual_id is not None:
entity.attrs["individual_id"] = individual_id
entity.create_poses(poses, positions, orientations, sampling) entity.create_poses(poses, positions, orientations, sampling)
if outlines is not None: if outlines is not None:
......
...@@ -447,6 +447,7 @@ class File(h5py.File): ...@@ -447,6 +447,7 @@ class File(h5py.File):
category: str, category: str,
poses: Iterable = None, poses: Iterable = None,
name: str = None, name: str = None,
individual_id: int = None,
positions: Iterable = None, positions: Iterable = None,
orientations: Iterable = None, orientations: Iterable = None,
outlines: Iterable = None, outlines: Iterable = None,
...@@ -460,6 +461,7 @@ class File(h5py.File): ...@@ -460,6 +461,7 @@ class File(h5py.File):
poses: optional two dimensional array, containing the poses of the entity (x,y,orientation_x, orientation_y). poses: optional two dimensional array, containing the poses of the entity (x,y,orientation_x, orientation_y).
poses_rad: optional two dimensional containing the poses of the entity (x,y, orientation_rad). poses_rad: optional two dimensional containing the poses of the entity (x,y, orientation_rad).
name: optional name of the entity. If no name is given, the is used with an id (e.g. 'fish_1') name: optional name of the entity. If no name is given, the is used with an id (e.g. 'fish_1')
individual_id (int, optional): invididual id of the entity.
outlines: optional three dimensional array, containing the outlines of the entity outlines: optional three dimensional array, containing the outlines of the entity
Returns: Returns:
Name of the created entity Name of the created entity
...@@ -471,14 +473,15 @@ class File(h5py.File): ...@@ -471,14 +473,15 @@ class File(h5py.File):
) )
entity = robofish.io.Entity.create_entity( entity = robofish.io.Entity.create_entity(
self["entities"], entities_group=self["entities"],
category, category=category,
poses, poses=poses,
name, name=name,
positions, individual_id=individual_id,
orientations, positions=positions,
outlines, orientations=orientations,
sampling, outlines=outlines,
sampling=sampling,
) )
return entity return entity
...@@ -488,6 +491,7 @@ class File(h5py.File): ...@@ -488,6 +491,7 @@ class File(h5py.File):
category: str, category: str,
poses: Iterable, poses: Iterable,
names: Iterable[str] = None, names: Iterable[str] = None,
individual_ids: Iterable[int] = None,
outlines=None, outlines=None,
sampling=None, sampling=None,
) -> Iterable: ) -> Iterable:
...@@ -497,6 +501,7 @@ class File(h5py.File): ...@@ -497,6 +501,7 @@ class File(h5py.File):
category: The common category for the entities. The canonical values are ['organism', 'robot', 'obstacle']. category: The common category for the entities. The canonical values are ['organism', 'robot', 'obstacle'].
poses: three dimensional array, containing the poses of the entity. poses: three dimensional array, containing the poses of the entity.
name: optional array of names of the entities. If no names are given, the category is used with an id (e.g. 'fish_1') name: optional array of names of the entities. If no names are given, the category is used with an id (e.g. 'fish_1')
individual_ids (Iterable[int]): optional array of individual ids of the entities.
outlines: optional array, containing the outlines of the entities, either a three dimensional common outline array can be given, or a four dimensional array. outlines: optional array, containing the outlines of the entities, either a three dimensional common outline array can be given, or a four dimensional array.
sampling: The string refference to the sampling. If none is given, the standard sampling from creating the file is used. sampling: The string refference to the sampling. If none is given, the standard sampling from creating the file is used.
Returns: Returns:
...@@ -515,13 +520,14 @@ class File(h5py.File): ...@@ -515,13 +520,14 @@ class File(h5py.File):
e_outline = ( e_outline = (
outlines if outlines is None or outlines.ndim == 3 else outlines[i] outlines if outlines is None or outlines.ndim == 3 else outlines[i]
) )
individual_id = None if individual_ids is None else individual_ids[i]
entity_names.append( entity_names.append(
self.create_entity( self.create_entity(
category=category, category=category,
sampling=sampling, sampling=sampling,
poses=poses[i], poses=poses[i],
name=e_name, name=e_name,
individual_id=individual_id,
outlines=e_outline, outlines=e_outline,
) )
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment