From 73b7b230973951e39d62b3f3adb9c0d742507d7e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Al=C3=A1n=20Mu=C3=B1oz?= <amuoz@ed.ac.uk>
Date: Fri, 17 Dec 2021 11:22:47 +0000
Subject: [PATCH] add mothers method

---
 pcore/io/signal.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pcore/io/signal.py b/pcore/io/signal.py
index 8fd15720..d2816a5a 100644
--- a/pcore/io/signal.py
+++ b/pcore/io/signal.py
@@ -28,6 +28,14 @@ class Signal(BridgeH5):
         df.name = name
         return df
 
+    def mothers(self, signal, cutoff=0.8):
+        df = self[signal]
+        get_mothers = lambda df: df.loc[df.notna().sum(axis=1) > df.shape[1] * cutoff]
+        if isinstance(df, pd.DataFrame):
+            return get_mothers(df)
+        elif isinstance(df, list):
+            return [get_mothers(d) for d in df]
+
     def __getitem__(self, dsets):
 
         if isinstance(dsets, str) and (
-- 
GitLab