np-workflows 1.6.89__py3-none-any.whl → 1.6.90__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- np_workflows/__init__.py +3 -5
- np_workflows/experiments/dynamic_routing/main.py +20 -41
- np_workflows/experiments/dynamic_routing/widgets.py +29 -24
- np_workflows/experiments/openscope_P3/P3_workflow_widget.py +11 -19
- np_workflows/experiments/openscope_P3/__init__.py +1 -1
- np_workflows/experiments/openscope_P3/main_P3_pilot.py +66 -68
- np_workflows/experiments/openscope_barcode/__init__.py +1 -1
- np_workflows/experiments/openscope_barcode/barcode_workflow_widget.py +14 -20
- np_workflows/experiments/openscope_barcode/camstim_scripts/barcode_mapping_script.py +8 -14
- np_workflows/experiments/openscope_barcode/camstim_scripts/barcode_opto_script.py +121 -68
- np_workflows/experiments/openscope_barcode/main_barcode_pilot.py +69 -69
- np_workflows/experiments/openscope_loop/__init__.py +1 -1
- np_workflows/experiments/openscope_loop/camstim_scripts/barcode_mapping_script.py +8 -14
- np_workflows/experiments/openscope_loop/camstim_scripts/barcode_opto_script.py +121 -68
- np_workflows/experiments/openscope_loop/loop_workflow_widget.py +11 -19
- np_workflows/experiments/openscope_loop/main_loop_pilot.py +66 -68
- np_workflows/experiments/openscope_psycode/__init__.py +1 -1
- np_workflows/experiments/openscope_psycode/main_psycode_pilot.py +69 -69
- np_workflows/experiments/openscope_psycode/psycode_workflow_widget.py +14 -20
- np_workflows/experiments/openscope_v2/__init__.py +1 -1
- np_workflows/experiments/openscope_v2/main_v2_pilot.py +66 -68
- np_workflows/experiments/openscope_v2/v2_workflow_widget.py +11 -19
- np_workflows/experiments/openscope_vippo/__init__.py +1 -1
- np_workflows/experiments/openscope_vippo/main_vippo_pilot.py +66 -68
- np_workflows/experiments/openscope_vippo/vippo_workflow_widget.py +14 -20
- np_workflows/experiments/task_trained_network/__init__.py +1 -1
- np_workflows/experiments/task_trained_network/camstim_scripts/make_tt_stims.py +24 -14
- np_workflows/experiments/task_trained_network/camstim_scripts/oct22_tt_stim_script.py +54 -41
- np_workflows/experiments/task_trained_network/camstim_scripts/ttn_main_script.py +19 -22
- np_workflows/experiments/task_trained_network/camstim_scripts/ttn_mapping_script.py +8 -14
- np_workflows/experiments/task_trained_network/camstim_scripts/ttn_opto_script.py +121 -68
- np_workflows/experiments/task_trained_network/main_ttn_pilot.py +73 -68
- np_workflows/experiments/task_trained_network/ttn_session_widget.py +11 -19
- np_workflows/experiments/task_trained_network/ttn_stim_config.py +23 -19
- np_workflows/experiments/templeton/main.py +18 -41
- np_workflows/experiments/templeton/widgets.py +26 -23
- np_workflows/shared/__init__.py +1 -1
- np_workflows/shared/base_experiments.py +430 -308
- np_workflows/shared/npxc.py +85 -53
- np_workflows/shared/widgets.py +374 -224
- {np_workflows-1.6.89.dist-info → np_workflows-1.6.90.dist-info}/METADATA +6 -15
- np_workflows-1.6.90.dist-info/RECORD +48 -0
- {np_workflows-1.6.89.dist-info → np_workflows-1.6.90.dist-info}/WHEEL +2 -1
- np_workflows-1.6.90.dist-info/entry_points.txt +2 -0
- np_workflows-1.6.90.dist-info/top_level.txt +1 -0
- np_workflows/assets/images/logo_np_hab.png +0 -0
- np_workflows/assets/images/logo_np_vis.png +0 -0
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_00.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_01.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_02.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_03.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_04.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_05.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_06.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_07.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_08.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_09.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_10.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_11.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_12.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_13.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_14.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_15.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_16.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_17.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/densely_annotated_18.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/flash_250ms.stim +0 -20
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/gabor_20_deg_250ms.stim +0 -30
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/old_stim.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/shuffle_reversed.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/shuffle_reversed_1st.stim +0 -5
- np_workflows/experiments/task_trained_network/camstim_scripts/stims/shuffle_reversed_2nd.stim +0 -5
- np_workflows/shared/camstim_scripts/flash_250ms.stim +0 -20
- np_workflows/shared/camstim_scripts/gabor_20_deg_250ms.stim +0 -30
- np_workflows-1.6.89.dist-info/RECORD +0 -76
- np_workflows-1.6.89.dist-info/entry_points.txt +0 -4
|
@@ -3,15 +3,11 @@ import contextlib
|
|
|
3
3
|
import copy
|
|
4
4
|
import enum
|
|
5
5
|
import functools
|
|
6
|
-
from typing import
|
|
6
|
+
from typing import Any, Literal
|
|
7
7
|
|
|
8
|
-
import IPython.display
|
|
9
|
-
import ipywidgets as ipw
|
|
10
8
|
import np_config
|
|
11
9
|
import np_logging
|
|
12
10
|
import np_session
|
|
13
|
-
import np_workflows
|
|
14
|
-
from typing import Any
|
|
15
11
|
|
|
16
12
|
logger = np_logging.getLogger(__name__)
|
|
17
13
|
|
|
@@ -29,9 +25,10 @@ class TTNSession(enum.Enum):
|
|
|
29
25
|
# setup parameters ---------------------------------------------------------------------
|
|
30
26
|
default_ttn_params = {}
|
|
31
27
|
|
|
28
|
+
|
|
32
29
|
def camstim_defaults() -> dict:
|
|
33
30
|
"""Try to load defaults from camstim config file on the Stim computer.
|
|
34
|
-
|
|
31
|
+
|
|
35
32
|
May encounter permission error if not running as svc_neuropix.
|
|
36
33
|
"""
|
|
37
34
|
with contextlib.suppress(OSError):
|
|
@@ -56,6 +53,7 @@ def camstim_defaults() -> dict:
|
|
|
56
53
|
logger.warning("Could not load camstim defaults from config file on Stim computer.")
|
|
57
54
|
return {}
|
|
58
55
|
|
|
56
|
+
|
|
59
57
|
## no longer added to default_ttn_params:
|
|
60
58
|
# default_ttn_params.update(**camstim_defaults())
|
|
61
59
|
|
|
@@ -64,14 +62,13 @@ def camstim_defaults() -> dict:
|
|
|
64
62
|
default_ttn_params["main"] = {}
|
|
65
63
|
|
|
66
64
|
default_ttn_params["main"]["sweepstim"] = {
|
|
67
|
-
"trigger_delay_sec": 5.0,
|
|
68
|
-
|
|
69
|
-
|
|
65
|
+
"trigger_delay_sec": 5.0, #! does it matter?
|
|
66
|
+
"sync_sqr_loc": (870, 525), # for Window.warp=Warp.Disabled
|
|
67
|
+
"sync_sqr_loc_warp": (540, 329), # for Window.warp=Warp.Spherical
|
|
70
68
|
}
|
|
71
69
|
# default_ttn_params["main"]["movie_path"] = "C:/ProgramData/StimulusFiles/dev/"
|
|
72
|
-
default_ttn_params["main"][
|
|
73
|
-
|
|
74
|
-
] = 'Gamma1.Luminance50'
|
|
70
|
+
default_ttn_params["main"]["monitor"] = "Gamma1.Luminance50"
|
|
71
|
+
|
|
75
72
|
|
|
76
73
|
# other parameters that vary depending on session type (pretest, hab, ephys):
|
|
77
74
|
def per_session_main_stim_params(session: TTNSession) -> dict[str, Any]:
|
|
@@ -105,7 +102,7 @@ def per_session_main_stim_params(session: TTNSession) -> dict[str, Any]:
|
|
|
105
102
|
def main_blank_screen(session: TTNSession) -> dict[str, float | int]:
|
|
106
103
|
match session:
|
|
107
104
|
case TTNSession.PRETEST:
|
|
108
|
-
return {"pre_blank_screen_sec": .5, "post_blank_screen_sec": .5}
|
|
105
|
+
return {"pre_blank_screen_sec": 0.5, "post_blank_screen_sec": 0.5}
|
|
109
106
|
case _:
|
|
110
107
|
return {"pre_blank_screen_sec": 2, "post_blank_screen_sec": 2}
|
|
111
108
|
|
|
@@ -122,6 +119,7 @@ default_ttn_params["opto"] = {}
|
|
|
122
119
|
|
|
123
120
|
# all parameters depend on session type (pretest, hab, ephys):
|
|
124
121
|
|
|
122
|
+
|
|
125
123
|
def per_session_opto_params(
|
|
126
124
|
session: TTNSession, mouse: str | int | np_session.Mouse
|
|
127
125
|
) -> dict[str, dict[str, str | list[float] | Literal["pretest", "experiment"]]]:
|
|
@@ -169,14 +167,20 @@ def per_session_opto_params(
|
|
|
169
167
|
default_ttn_params["mapping"] = {}
|
|
170
168
|
|
|
171
169
|
default_ttn_params["mapping"]["monitor"] = "Gamma1.Luminance50"
|
|
172
|
-
default_ttn_params["mapping"]["gabor_path"] = "gabor_20_deg_250ms.stim"
|
|
173
|
-
default_ttn_params["mapping"][
|
|
170
|
+
default_ttn_params["mapping"]["gabor_path"] = "gabor_20_deg_250ms.stim"
|
|
171
|
+
default_ttn_params["mapping"][
|
|
172
|
+
"flash_path"
|
|
173
|
+
] = "flash_250ms.stim" # relpath in StimulusFiles dir (for _v2 objects)
|
|
174
174
|
default_ttn_params["mapping"]["default_gabor_duration_seconds"] = 1200
|
|
175
|
-
default_ttn_params["mapping"][
|
|
175
|
+
default_ttn_params["mapping"][
|
|
176
|
+
"default_flash_duration_seconds"
|
|
177
|
+
] = 300 # may be overriden by 'max_total_duration_minutes'
|
|
176
178
|
|
|
177
179
|
default_ttn_params["mapping"]["sweepstim"] = {
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
+
"sync_sqr_loc_warp": (540, 329), # for Window.warp=Warp.Spherical
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
|
|
180
184
|
# trigger_delay_sec not specified
|
|
181
185
|
# all stim parameters depend on session type (pretest, hab, ephys):
|
|
182
186
|
def per_session_mapping_params(session: TTNSession) -> dict[str, dict[str, int]]:
|
|
@@ -195,7 +199,7 @@ def per_session_mapping_params(session: TTNSession) -> dict[str, dict[str, int]]
|
|
|
195
199
|
def mapping_blank_screen(session: TTNSession) -> dict[str, float | int]:
|
|
196
200
|
match session:
|
|
197
201
|
case TTNSession.PRETEST:
|
|
198
|
-
return {"pre_blank_screen_sec": .5, "post_blank_screen_sec": .5}
|
|
202
|
+
return {"pre_blank_screen_sec": 0.5, "post_blank_screen_sec": 0.5}
|
|
199
203
|
case TTNSession.EPHYS | TTNSession.HAB_120:
|
|
200
204
|
return {"pre_blank_screen_sec": 2, "post_blank_screen_sec": 2}
|
|
201
205
|
case _:
|
|
@@ -1,65 +1,39 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
|
-
import configparser
|
|
4
|
-
import contextlib
|
|
5
|
-
import copy
|
|
6
|
-
import dataclasses
|
|
7
|
-
import datetime
|
|
8
|
-
import enum
|
|
9
|
-
import functools
|
|
10
|
-
import pathlib
|
|
11
|
-
import platform
|
|
12
|
-
import shutil
|
|
13
|
-
import threading
|
|
14
|
-
import time
|
|
15
|
-
import zlib
|
|
16
|
-
from typing import ClassVar, Literal, NamedTuple, NoReturn, Optional, Type, TypedDict
|
|
17
|
-
|
|
18
|
-
import IPython
|
|
19
|
-
import IPython.display
|
|
20
|
-
import ipywidgets as ipw
|
|
21
|
-
import np_config
|
|
22
3
|
import np_logging
|
|
23
|
-
import np_services
|
|
24
4
|
import np_session
|
|
25
|
-
import np_workflows
|
|
26
|
-
import fabric
|
|
27
|
-
import PIL.Image
|
|
28
|
-
import pydantic
|
|
29
|
-
from pyparsing import Any
|
|
30
5
|
from np_services import (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ScriptCamstim,
|
|
6
|
+
MouseDirector,
|
|
7
|
+
NewScaleCoordinateRecorder,
|
|
34
8
|
OpenEphys,
|
|
9
|
+
ScriptCamstim,
|
|
35
10
|
Sync,
|
|
36
|
-
ImageMVR,
|
|
37
11
|
VideoMVR,
|
|
38
|
-
NewScaleCoordinateRecorder,
|
|
39
|
-
MouseDirector,
|
|
40
12
|
)
|
|
41
13
|
|
|
42
14
|
from np_workflows.shared import base_experiments
|
|
43
15
|
|
|
44
16
|
logger = np_logging.getLogger(__name__)
|
|
45
17
|
|
|
18
|
+
|
|
46
19
|
class TempletonPilot(base_experiments.DynamicRoutingExperiment):
|
|
47
20
|
"""Provides project-specific methods and attributes, mainly related to camstim scripts."""
|
|
48
|
-
|
|
21
|
+
|
|
49
22
|
default_session_subclass = np_session.TempletonPilotSession
|
|
50
|
-
|
|
23
|
+
|
|
51
24
|
workflow: base_experiments.DynamicRoutingExperiment.Workflow
|
|
52
25
|
"""Enum for workflow type, e.g. PRETEST, HAB_AUD, HAB_VIS, EPHYS_ etc."""
|
|
53
26
|
|
|
54
27
|
@property
|
|
55
28
|
def task_name(self) -> str:
|
|
56
29
|
task_name = super().task_name
|
|
57
|
-
return f
|
|
58
|
-
|
|
30
|
+
return f"templeton {task_name}" if "templeton" not in task_name else task_name
|
|
31
|
+
|
|
59
32
|
@task_name.setter
|
|
60
33
|
def task_name(self, value: str):
|
|
61
34
|
super().task_name = value
|
|
62
|
-
|
|
35
|
+
|
|
36
|
+
|
|
63
37
|
def new_experiment(
|
|
64
38
|
mouse: int | str | np_session.Mouse,
|
|
65
39
|
user: str | np_session.User,
|
|
@@ -67,17 +41,20 @@ def new_experiment(
|
|
|
67
41
|
) -> TempletonPilot:
|
|
68
42
|
"""Create a new experiment for the given mouse and user."""
|
|
69
43
|
experiment: Ephys | Hab
|
|
70
|
-
if any(tag in workflow.name for tag in (
|
|
44
|
+
if any(tag in workflow.name for tag in ("EPHYS", "PRETEST")):
|
|
71
45
|
experiment = Ephys(mouse, user)
|
|
72
|
-
elif
|
|
46
|
+
elif "HAB" in workflow.name:
|
|
73
47
|
experiment = Hab(mouse, user)
|
|
74
48
|
else:
|
|
75
|
-
raise ValueError(
|
|
49
|
+
raise ValueError(
|
|
50
|
+
f"Unknown {workflow = }. Create an experiment with e.g.\n\n\texperiment = Ephys(mouse, user)\nexperiment.session.npexp_path.mkdir()"
|
|
51
|
+
)
|
|
76
52
|
experiment.workflow = workflow
|
|
77
53
|
experiment.log(f"{experiment} created")
|
|
78
|
-
experiment.session.npexp_path.mkdir(parents=True, exist_ok=True)
|
|
54
|
+
experiment.session.npexp_path.mkdir(parents=True, exist_ok=True)
|
|
79
55
|
return experiment
|
|
80
56
|
|
|
57
|
+
|
|
81
58
|
class Hab(TempletonPilot):
|
|
82
59
|
def __init__(self, *args, **kwargs):
|
|
83
60
|
self.services = (
|
|
@@ -102,4 +79,4 @@ class Ephys(TempletonPilot):
|
|
|
102
79
|
OpenEphys,
|
|
103
80
|
NewScaleCoordinateRecorder,
|
|
104
81
|
)
|
|
105
|
-
super().__init__(*args, **kwargs)
|
|
82
|
+
super().__init__(*args, **kwargs)
|
|
@@ -1,28 +1,22 @@
|
|
|
1
|
-
import configparser
|
|
2
|
-
import contextlib
|
|
3
|
-
import copy
|
|
4
|
-
import enum
|
|
5
|
-
import functools
|
|
6
|
-
from typing import ClassVar, Literal, NamedTuple, NoReturn, Optional, TypedDict
|
|
7
|
-
|
|
8
1
|
import IPython.display
|
|
9
2
|
import ipywidgets as ipw
|
|
10
|
-
import np_config
|
|
11
|
-
import np_logging
|
|
12
3
|
import np_session
|
|
13
|
-
import np_workflows
|
|
14
|
-
from pyparsing import Any
|
|
15
4
|
|
|
16
|
-
from np_workflows.experiments.templeton.main import Ephys, Hab
|
|
17
5
|
from np_workflows.shared.base_experiments import DynamicRoutingExperiment
|
|
18
6
|
|
|
19
7
|
# for widget, before creating a experiment --------------------------------------------- #
|
|
20
8
|
|
|
21
9
|
|
|
22
10
|
class SelectedWorkflow:
|
|
23
|
-
def __init__(
|
|
11
|
+
def __init__(
|
|
12
|
+
self,
|
|
13
|
+
workflow: str | DynamicRoutingExperiment.Workflow,
|
|
14
|
+
mouse: str | int | np_session.Mouse,
|
|
15
|
+
):
|
|
24
16
|
if isinstance(workflow, str):
|
|
25
|
-
workflow = DynamicRoutingExperiment.Workflow[
|
|
17
|
+
workflow = DynamicRoutingExperiment.Workflow[
|
|
18
|
+
workflow
|
|
19
|
+
] # uses enum name (not value)
|
|
26
20
|
self.workflow = workflow
|
|
27
21
|
self.mouse = str(mouse)
|
|
28
22
|
|
|
@@ -50,11 +44,13 @@ def workflow_select_widget(
|
|
|
50
44
|
workflow_descriptions = ipw.Select(
|
|
51
45
|
options=tuple(_.value for _ in DynamicRoutingExperiment.Workflow),
|
|
52
46
|
disabled=True,
|
|
53
|
-
value=None
|
|
47
|
+
value=None,
|
|
54
48
|
)
|
|
55
49
|
console = ipw.Output()
|
|
56
50
|
with console:
|
|
57
|
-
if last_workflow := np_session.Mouse(selection.mouse).state.get(
|
|
51
|
+
if last_workflow := np_session.Mouse(selection.mouse).state.get(
|
|
52
|
+
"last_workflow"
|
|
53
|
+
):
|
|
58
54
|
print(f"{mouse} last workflow: {last_workflow}")
|
|
59
55
|
print(f"Selected: {selection.workflow.name}")
|
|
60
56
|
|
|
@@ -67,16 +63,23 @@ def workflow_select_widget(
|
|
|
67
63
|
return
|
|
68
64
|
if change["new"] == change["old"]:
|
|
69
65
|
return
|
|
70
|
-
selection.__init__(
|
|
66
|
+
selection.__init__(
|
|
67
|
+
str(workflow_dropdown.value),
|
|
68
|
+
mouse.id if isinstance(mouse, np_session.Mouse) else str(mouse),
|
|
69
|
+
)
|
|
71
70
|
with console:
|
|
72
71
|
print(f"Selected: {selection.workflow}")
|
|
73
|
-
workflow_dropdown.observe(update, names='value')
|
|
74
72
|
|
|
75
|
-
|
|
73
|
+
workflow_dropdown.observe(update, names="value")
|
|
74
|
+
|
|
75
|
+
IPython.display.display(
|
|
76
|
+
ipw.VBox([ipw.HBox([workflow_dropdown, workflow_descriptions]), console])
|
|
77
|
+
)
|
|
76
78
|
|
|
77
79
|
return selection
|
|
78
|
-
|
|
79
|
-
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
|
|
82
|
+
def photodoc_widget(session: np_session.Session, reminder: str) -> None:
|
|
83
|
+
print(
|
|
84
|
+
f"Take an image in Vimba Viewer and save as:\n{session.npexp_path.name}_{reminder}.png"
|
|
85
|
+
)
|
np_workflows/shared/__init__.py
CHANGED