Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 64e62e1

Browse files
committed
attempt to feature extraction in parallel
1 parent b5fc0e5 commit 64e62e1

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

bluepyefe/cell.py

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
2020
"""
2121
import logging
22+
from multiprocessing import Pool
2223
import numpy
2324
import matplotlib.pyplot as plt
2425
import 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

Comments
 (0)