Skip to content
Snippets Groups Projects
Commit afb70a35 authored by Alán Muñoz's avatar Alán Muñoz
Browse files

docs(signal): act on peter comments

parent 159ac656
No related branches found
No related tags found
No related merge requests found
...@@ -42,21 +42,15 @@ class Signal(BridgeH5): ...@@ -42,21 +42,15 @@ class Signal(BridgeH5):
"Cy5", "Cy5",
"pHluorin405", "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]): 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 dataframe."""
if isinstance(dsets, str): if isinstance(dsets, str): # no pre-processing
# no pre-processing
df = self.get_raw(dsets) df = self.get_raw(dsets)
return self.add_name(df, dsets) return self.add_name(df, dsets)
elif isinstance(dsets, list): elif isinstance(dsets, list): # pre-processing
# pre-processing
is_bgd = [dset.endswith("imBackground") for dset in dsets] 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( assert sum(is_bgd) == 0 or sum(is_bgd) == len(
dsets dsets
), "Tile data and cell data can't be mixed" ), "Tile data and cell data can't be mixed"
...@@ -72,14 +66,6 @@ class Signal(BridgeH5): ...@@ -72,14 +66,6 @@ class Signal(BridgeH5):
df.name = name df.name = name
return df 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): def cols_in_mins(self, df: pd.DataFrame):
# Convert numerical columns in a dataframe to minutes # Convert numerical columns in a dataframe to minutes
try: try:
...@@ -292,10 +278,8 @@ class Signal(BridgeH5): ...@@ -292,10 +278,8 @@ class Signal(BridgeH5):
if in_minutes: if in_minutes:
df = self.cols_in_mins(df) df = self.cols_in_mins(df)
elif isinstance(dataset, list): elif isinstance(dataset, list):
# Alan: no mother_labels in this case?
return [self.get_raw(dset) for dset in dataset] return [self.get_raw(dset) for dset in dataset]
if lineage: if lineage: # assume that df is sorted
# assumes that df is sorted
mother_label = np.zeros(len(df), dtype=int) mother_label = np.zeros(len(df), dtype=int)
lineage = self.lineage() lineage = self.lineage()
a, b = validate_association( a, b = validate_association(
...@@ -307,7 +291,7 @@ class Signal(BridgeH5): ...@@ -307,7 +291,7 @@ class Signal(BridgeH5):
df = add_index_levels(df, {"mother_label": mother_label}) df = add_index_levels(df, {"mother_label": mother_label})
return df return df
except Exception as e: 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 raise e
def get_merges(self): def get_merges(self):
......
...@@ -22,9 +22,9 @@ class Chainer(Signal): ...@@ -22,9 +22,9 @@ class Chainer(Signal):
them when called. them when called.
""" """
# these no longer seem to be used equivalences = {
#process_types = ("multisignal", "processes", "reshapers") "m5m": ("extraction/GFP/max/max5px", "extraction/GFP/max/median")
#common_chains = {} }
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
...@@ -83,7 +83,7 @@ class Chainer(Signal): ...@@ -83,7 +83,7 @@ class Chainer(Signal):
**kwargs, **kwargs,
): ):
"""Load data from an h5 file.""" """Load data from an h5 file."""
1/0 1 / 0
if dataset in self.common_chains: if dataset in self.common_chains:
# get dataset for composite chains # get dataset for composite chains
data = self.common_chains[dataset](**kwargs) data = self.common_chains[dataset](**kwargs)
...@@ -96,7 +96,7 @@ class Chainer(Signal): ...@@ -96,7 +96,7 @@ class Chainer(Signal):
# keep data only from early time points # keep data only from early time points
data = self.get_retained(data, retain) data = self.get_retained(data, retain)
# data = data.loc[data.notna().sum(axis=1) > data.shape[1] * 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 # return stages as additional column level
stages_index = [ stages_index = [
x x
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment