diff --git a/src/agora/io/signal.py b/src/agora/io/signal.py index dc951d87565acdadc2bcd58dda964897993009d5..48203c049475d8f64904e5adbd70ff3fbad7bdbe 100644 --- a/src/agora/io/signal.py +++ b/src/agora/io/signal.py @@ -42,21 +42,15 @@ class Signal(BridgeH5): "Cy5", "pHluorin405", ) - # Alan: why "equivalences"? this variable is unused. - equivalences = { - "m5m": ("extraction/GFP/max/max5px", "extraction/GFP/max/median") - } def __getitem__(self, dsets: t.Union[str, t.Collection]): """Get and potentially pre-process data from h5 file and return as a dataframe.""" - if isinstance(dsets, str): - # no pre-processing + if isinstance(dsets, str): # no pre-processing df = self.get_raw(dsets) return self.add_name(df, dsets) - elif isinstance(dsets, list): - # pre-processing + elif isinstance(dsets, list): # pre-processing is_bgd = [dset.endswith("imBackground") for dset in dsets] - # Alan: what does this error message mean? + # Check we are not comaring 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" @@ -72,14 +66,6 @@ class Signal(BridgeH5): df.name = name return df - # def cols_in_mins_old(self, df: pd.DataFrame): - # """Convert numerical columns in a dataframe to minutes.""" - # try: - # df.columns = (df.columns * self.tinterval // 60).astype(int) - # except Exception as e: - # print(f"Warning:Signal: Unable to convert columns to minutes: {e}") - # return df - def cols_in_mins(self, df: pd.DataFrame): # Convert numerical columns in a dataframe to minutes try: @@ -292,10 +278,8 @@ class Signal(BridgeH5): if in_minutes: df = self.cols_in_mins(df) elif isinstance(dataset, list): - # Alan: no mother_labels in this case? return [self.get_raw(dset) for dset in dataset] - if lineage: - # assumes that df is sorted + if lineage: # assume that df is sorted mother_label = np.zeros(len(df), dtype=int) lineage = self.lineage() a, b = validate_association( @@ -307,7 +291,7 @@ class Signal(BridgeH5): df = add_index_levels(df, {"mother_label": mother_label}) return df except Exception as e: - self._log(f"Could not fetch dataset {dataset}", "error") + self._log(f"Could not fetch dataset {dataset}: {e}", "error") raise e def get_merges(self): diff --git a/src/postprocessor/chainer.py b/src/postprocessor/chainer.py index a5387ccb1138357e54c46fb3e2cf6abadc5b6424..3462ff38d3493a7086bf6d14b20581a80c3ccd75 100644 --- a/src/postprocessor/chainer.py +++ b/src/postprocessor/chainer.py @@ -22,9 +22,9 @@ class Chainer(Signal): them when called. """ - # these no longer seem to be used - #process_types = ("multisignal", "processes", "reshapers") - #common_chains = {} + equivalences = { + "m5m": ("extraction/GFP/max/max5px", "extraction/GFP/max/median") + } def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -83,7 +83,7 @@ class Chainer(Signal): **kwargs, ): """Load data from an h5 file.""" - 1/0 + 1 / 0 if dataset in self.common_chains: # get dataset for composite chains data = self.common_chains[dataset](**kwargs) @@ -96,7 +96,7 @@ class Chainer(Signal): # keep data only from early time points data = self.get_retained(data, retain) # data = data.loc[data.notna().sum(axis=1) > data.shape[1] * retain] - if (stages and "stage" not in data.columns.names): + if stages and "stage" not in data.columns.names: # return stages as additional column level stages_index = [ x