Skip to content
Snippets Groups Projects
Commit ad558e11 authored by pswain's avatar pswain
Browse files

stop grouper from exiting with assertion if cannot find data

parent 0feb0543
No related branches found
No related tags found
No related merge requests found
...@@ -107,35 +107,38 @@ class Grouper(ABC): ...@@ -107,35 +107,38 @@ class Grouper(ABC):
if path.startswith("/"): if path.startswith("/"):
path = path.strip("/") path = path.strip("/")
good_chains = self.filter_chains(path) good_chains = self.filter_chains(path)
if standard: if good_chains:
fn_pos = concat_standard if standard:
else: fn_pos = concat_standard
fn_pos = concat_one_signal else:
kwargs["mode"] = mode fn_pos = concat_one_signal
records = self.pool_function( kwargs["mode"] = mode
path=path, records = self.pool_function(
f=fn_pos, path=path,
pool=pool, f=fn_pos,
chainers=good_chains, pool=pool,
**kwargs, chainers=good_chains,
) **kwargs,
# check for errors
errors = [
k for kymo, k in zip(records, self.chainers.keys()) if kymo is None
]
records = [record for record in records if record is not None]
if len(errors):
print("Warning: Positions contain errors {errors}")
assert len(records), "All data sets contain errors"
# combine into one dataframe
concat = pd.concat(records, axis=0)
if len(concat.index.names) > 4:
# reorder levels in the multi-index dataframe when mother_label is present
concat = concat.reorder_levels(
("group", "position", "trap", "cell_label", "mother_label")
) )
concat_sorted = concat.sort_index() # check for errors
return concat_sorted errors = [
k
for kymo, k in zip(records, self.chainers.keys())
if kymo is None
]
records = [record for record in records if record is not None]
if len(errors):
print("Warning: Positions contain errors {errors}")
assert len(records), "All data sets contain errors"
# combine into one dataframe
concat = pd.concat(records, axis=0)
if len(concat.index.names) > 4:
# reorder levels in the multi-index dataframe when mother_label is present
concat = concat.reorder_levels(
("group", "position", "trap", "cell_label", "mother_label")
)
concat_sorted = concat.sort_index()
return concat_sorted
def filter_chains(self, path: str) -> t.Dict[str, Chainer]: def filter_chains(self, path: str) -> t.Dict[str, Chainer]:
"""Filter chains to those whose data is available in the h5 file.""" """Filter chains to those whose data is available in the h5 file."""
...@@ -150,9 +153,6 @@ class Grouper(ABC): ...@@ -150,9 +153,6 @@ class Grouper(ABC):
f"Grouper:Warning: {nchains_dif} chains do not contain" f"Grouper:Warning: {nchains_dif} chains do not contain"
f" channel {path}" f" channel {path}"
) )
assert len(
good_chains
), f"No valid dataset to use. Valid datasets are {self.available}"
return good_chains return good_chains
def pool_function( def pool_function(
......
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