diff --git a/src/agora/io/signal.py b/src/agora/io/signal.py index 6e8ffd0ae1a377fec4c73998070d5a5a0188f45b..158d522dbd19fc656999a6a7df2955f4157868c3 100644 --- a/src/agora/io/signal.py +++ b/src/agora/io/signal.py @@ -39,7 +39,7 @@ class Signal(BridgeH5): self.candidate_channels = global_parameters.possible_imaging_channels def __getitem__(self, dsets: t.Union[str, t.Collection]): - """Get and potentially pre-process data from h5 file and return as a dataframe.""" + """Get and potentially pre-process data from h5 file and return as a data frame.""" if isinstance(dsets, str): return self.get(dsets) elif isinstance(dsets, list): @@ -47,7 +47,7 @@ class Signal(BridgeH5): # Check we are not comparing tile-indexed and cell-indexed data assert sum(is_bgd) == 0 or sum(is_bgd) == len( dsets - ), "Tile data and cell data can't be mixed" + ), "Tile data and cell data cannot be mixed." return [self.get(dset) for dset in dsets] else: raise Exception(f"Invalid type {type(dsets)} to get datasets") @@ -66,12 +66,12 @@ class Signal(BridgeH5): @staticmethod def add_name(df, name): - """Add name of the Signal as an attribute to its corresponding dataframe.""" + """Add name of the Signal as an attribute to its data frame.""" df.name = name return df def cols_in_mins(self, df: pd.DataFrame): - """Convert numerical columns in a dataframe to minutes.""" + """Convert numerical columns in a data frame to minutes.""" try: df.columns = (df.columns * self.tinterval // 60).astype(int) except Exception as e: @@ -251,6 +251,7 @@ class Signal(BridgeH5): dataset: str or t.List[str], in_minutes: bool = True, lineage: bool = False, + **kwargs, ) -> pd.DataFrame or t.List[pd.DataFrame]: """ Get raw Signal without merging, picking, and lineage information. diff --git a/src/postprocessor/grouper.py b/src/postprocessor/grouper.py index d3699c420dfe908594ac65941c1996808633c0a0..0dca70e0e31f56117077cec0d1cf422956a9bb5c 100644 --- a/src/postprocessor/grouper.py +++ b/src/postprocessor/grouper.py @@ -288,16 +288,22 @@ def concat_one_signal( elif mode == "raw": combined = position.get_raw(path, **kwargs) elif mode == "daughters": - combined = position.get_raw(path, **kwargs) + combined = position.get_raw(path, lineage=True, **kwargs) combined = combined.loc[ combined.index.get_level_values("mother_label") > 0 ] + elif mode == "mothers": + combined = position.get_raw(path, lineage=True, **kwargs) + combined = combined.loc[ + combined.index.get_level_values("mother_label") == 0 + ] + combined = combined.droplevel("mother_label") elif mode == "families": combined = position[path] else: raise Exception(f"concat_one_signal: {mode} not recognised.") if combined is not None: - # adjust indices + # add position and group as indices combined["position"] = position_name combined["group"] = group combined.set_index(["group", "position"], inplace=True, append=True)