Skip to content

Commit 3d012e5

Browse files
committed
Fix lfpykit head model load on osb
1 parent 87ce93d commit 3d012e5

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ ENV NEURON_HOME=/opt/conda
5757
# For lfpykit 0.4
5858
# RUN wget -P $(pip show LFPykit | grep "Location:" | awk '{print $2"/lfpykit"}') https://www.parralab.org/nyhead/sa_nyhead.mat
5959
# For lpfykit 0.5
60+
6061
RUN wget --no-check-certificate -P ${FOLDER}/workspace https://www.parralab.org/nyhead/sa_nyhead.mat
6162

6263
USER $NB_UID

netpyne_ui/__init__.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,23 @@
1111
"https://d8bf7e40eec34cb9891f6dd8207b5e83@sentry.metacell.us/6"
1212
)
1313

14-
15-
14+
HEAD_MODEL_FILE = os.getenv("NP_LFPYKIT_HEAD_FILE", "sa_nyhead.mat")
15+
16+
def init_eeg():
17+
import sys
18+
from netpyne_ui.constants import HERE
19+
# FIXES library asking for input to download
20+
sys.stdin = open(os.path.join(HERE, "resources/stdin.txt"),'r')
21+
from lfpykit.eegmegcalc import NYHeadModel
22+
try:
23+
NYHeadModel(HEAD_MODEL_FILE) # Downloads the model if does not exist
24+
except:
25+
logging.error("Error initializing the EEG head model", exc_info=True)
26+
27+
if not os.path.exists(HEAD_MODEL_FILE):
28+
from multiprocessing import Process
29+
thread = Process(target = init_eeg)
30+
thread.start()
1631

1732
RouteManager.add_controller(api.NetPyNEController)
1833

0 commit comments

Comments
 (0)