11"""
2- Pipeline on spikes/peaks/detected peaks
3-
4- Functions that can be chained:
5- * after peak detection
6- * already detected peaks
7- * spikes (labeled peaks)
8- to compute some additional features on-the-fly:
9- * peak localization
10- * peak-to-peak
11- * pca
12- * amplitude
13- * amplitude scaling
14- * ...
15-
16- There are two ways for using theses "plugin nodes":
17- * during `peak_detect()`
18- * when peaks are already detected and reduced with `select_peaks()`
19- * on a sorting object
2+
3+
204"""
215
226from __future__ import annotations
@@ -490,7 +474,7 @@ def run_node_pipeline(
490474 nodes ,
491475 job_kwargs ,
492476 job_name = "pipeline" ,
493- mp_context = None ,
477+ # mp_context=None,
494478 gather_mode = "memory" ,
495479 gather_kwargs = {},
496480 squeeze_output = True ,
@@ -500,7 +484,61 @@ def run_node_pipeline(
500484 skip_after_n_peaks = None ,
501485):
502486 """
503- Common function to run pipeline with peak detector or already detected peak.
487+ Machinery to compute in paralell operations on peaks and traces.
488+
489+ This usefull in several use cases:
490+ * in sortingcomponents : detect peaks and make some computation on then (localize, pca, ...)
491+ * in sortingcomponents : replay some peaks and make some computation on then (localize, pca, ...)
492+ * postprocessing : replay some spikes and make some computation on then (localize, pca, ...)
493+
494+ Here a "peak" is a spike without any labels just a "detected".
495+ Here a "spike" is a spike with any a label so already sorted.
496+
497+ The main idea is to have a graph of nodes.
498+ Every node is doing a computaion of some peaks and related traces.
499+ The first node is PeakSource so either a peak detector PeakDetector or peak/spike replay (PeakRetriever/SpikeRetriever)
500+
501+ Every can have one or several output that can be directed to other nodes (aka nodes have parents).
502+
503+ Every node can optionaly have an global output that will be globaly gather by the main process.
504+ This is controlled by return_output = True.
505+
506+ The gather consists of concatenating features related to peaks (localization, pca, scaling, ...) into a single big vector.
507+ Theses vector can be in "memory" or in file ("npy")
508+
509+
510+ Parameters
511+ ----------
512+
513+ recording: Recording
514+
515+ nodes: a list of PipelineNode
516+
517+ job_kwargs: dict
518+ The classical job_kwargs
519+ job_name : str
520+ The name of the pipeline used for the progress_bar
521+ gather_mode : "memory" | "npz"
522+
523+ gather_kwargs : dict
524+ OPtions to control the "gather engine". See GatherToMemory or GatherToNpy.
525+ squeeze_output : bool, default True
526+ If only one output node, the, squeeze the tuple
527+ folder : str | Path | None
528+ Used for gather_mode="npz"
529+ names : list of str
530+ Names of outputs.
531+ verbose : bool, default False
532+ Verbosity.
533+ skip_after_n_peaks : None | int
534+ Skip the computaion after n_peaks.
535+ This is not an exact because internally this skip is done per worker in average.
536+
537+ Returns
538+ -------
539+ outputs: tuple of np.array | np.array
540+ a tuple of vector for the output of nodes having return_output=True.
541+ If squeeze_output=True and only one output then directly np.array.
504542 """
505543
506544 check_graph (nodes )
0 commit comments