Skip to content
Snippets Groups Projects
Commit 5370f421 authored by Arin Wongprommoon's avatar Arin Wongprommoon
Browse files

fix(postproc): groups signal not present in all HDFs in dir

WHY IS THIS CHANGE NEEDED?:
- if a signal is not present in all HDFs files in a directory, defining
  a grouper object and then invoking
  grouper.concat_signal('<name_of_signal>') throws an error

HOW DOES THE CHANGE SOLVE THE PROBLEM?:
- modify pool_function() so that a dictionary of signals is an argument.
  this dictionary of signals indicates which files have the signal of interest.
- pass the dictionary of signals into concat_signal(), so that it knows
  which ones to process (i.e. concatenate)
parent af9f38a4
No related branches found
No related tags found
No related merge requests found
...@@ -116,7 +116,12 @@ class Grouper(ABC): ...@@ -116,7 +116,12 @@ class Grouper(ABC):
) )
signals = self.pool_function( signals = self.pool_function(
path=path, f=concat_signal_ind, mode=mode, pool=pool, **kwargs path=path,
f=concat_signal_ind,
mode=mode,
pool=pool,
signals=sitems,
**kwargs,
) )
errors = [k for s, k in zip(signals, self.signals.keys()) if s is None] errors = [k for s, k in zip(signals, self.signals.keys()) if s is None]
...@@ -196,15 +201,17 @@ class Grouper(ABC): ...@@ -196,15 +201,17 @@ class Grouper(ABC):
path: str, path: str,
f: t.Callable, f: t.Callable,
pool: t.Optional[int] = None, pool: t.Optional[int] = None,
signals: t.Dict[str, Signal] = None,
**kwargs, **kwargs,
): ):
""" """
Wrapper to add support for threading to process independent signals. Wrapper to add support for threading to process independent signals.
Particularly useful when aggregating multiple elements. Particularly useful when aggregating multiple elements.
""" """
if pool or pool is None: pool = pool or 8
if pool is None: signals = signals or self.signals
pool = 8
if pool:
with Pool(pool) as p: with Pool(pool) as p:
kymographs = p.map( kymographs = p.map(
...@@ -214,7 +221,7 @@ class Grouper(ABC): ...@@ -214,7 +221,7 @@ class Grouper(ABC):
group=self.positions_groups[x[0]], group=self.positions_groups[x[0]],
**kwargs, **kwargs,
), ),
self.signals.items(), signals.items(),
) )
else: else:
kymographs = [ kymographs = [
......
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