1919 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020"""
2121import logging
22+ from multiprocessing import Pool
2223import numpy
2324import matplotlib .pyplot as plt
2425import pathlib
@@ -172,6 +173,12 @@ def read_recordings(
172173 f"the available stimuli names"
173174 )
174175
176+ def extract_efeatures_helper (self , recording_id , efeatures , efeature_names , efel_settings ):
177+ """Helper function to compute efeatures for a single recording."""
178+ self .recordings [recording_id ].compute_efeatures (
179+ efeatures , efeature_names , efel_settings )
180+ return self .recordings [recording_id ]
181+
175182 def extract_efeatures (
176183 self ,
177184 protocol_name ,
@@ -192,10 +199,17 @@ def extract_efeatures(
192199 is to be extracted several time on different sections
193200 of the same recording.
194201 """
202+ recording_ids = self .get_recordings_id_by_protocol_name (protocol_name )
203+
204+ # Run in parallel via multiprocessing
205+ with Pool (maxtasksperchild = 1 ) as pool :
206+ tasks = [
207+ (rec_id , efeatures , efeature_names , efel_settings )
208+ for rec_id in recording_ids
209+ ]
210+ results = pool .starmap (self .extract_efeatures_helper , tasks )
195211
196- for i in self .get_recordings_id_by_protocol_name (protocol_name ):
197- self .recordings [i ].compute_efeatures (
198- efeatures , efeature_names , efel_settings )
212+ self .recordings = results
199213
200214 def compute_relative_amp (self ):
201215 """Compute the relative current amplitude for all the recordings as a
0 commit comments