Skip to content

Commit 1880684

Browse files
Change quantitative properties to add units to name (#6)
* add new spec (not working for the stimulated_rois) * tests not working * fix testing * define what is required * improve tutorial * add explaination for stimulus table * add testing for power,frequency and pulse_width as 1D arrays * set defaults for power,frequency and pulse_width * add schema diagram * remove unnecessary imports * add targeted_rois (required) and segmented_rois (optional) * remove unnecessary imports * remove old schema * update schema * minor fixes * add elements to __all__ to count as used * add exception to ruff * remove space * adjust to proper sentences * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Update spec/ndx-patterned-ogen.extensions.yaml Co-authored-by: Cody Baker <[email protected]> * Improve readability of doc strings * targeted_rois defined as table region * add example for slm model and filter_description * split SLM in 2 device SLM2D and SLM3D * split OgenPattern in 2D and 3D * update tutorial and schema * minor fixes * update schema * set sweeep_size and sweep_mask as datasets * set SpiralScanning and TemporalFocusing properties as datasets * set effector as dataset * set spatial_resolution as dataset * set all LightSource properties as datasets except "model" * update tutorial * set segmented_rois default * change required:false to quantity:'?' for dataset * remove unnecessary class definition * add unit, shape and dims * update tutorial and mock_fun accordingly * minor fixes * Apply suggestions from code review * add unit measure in the name of the attribute --------- Co-authored-by: Cody Baker <[email protected]>
1 parent 042cc16 commit 1880684

File tree

6 files changed

+538
-457
lines changed

6 files changed

+538
-457
lines changed

spec/ndx-patterned-ogen.extensions.yaml

Lines changed: 93 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -6,81 +6,103 @@ groups:
66
- name: description
77
dtype: text
88
doc: Description of the scanning or scanless method for shaping optogenetic light. Examples include diffraction limited points, 3D shot, disks, etc.
9-
required: false
10-
- name: sweep_size
9+
- name: sweep_size_in_um
1110
dtype: numeric
1211
doc:
13-
Size of the scanning sweep pattern in micrometers. If a scalar is provided, the sweep pattern is
12+
Size of the scanning sweep pattern (default in micrometers). If a scalar is provided, the sweep pattern is
1413
assumed to be a circle (for 2D patterns) with diameter 'sweep_size'.
1514
If 'sweep_size' is a two dimensional array, the the sweep pattern is assumed to be a
1615
rectangle, with dimensions [width, height].
1716
required: false
17+
dims:
18+
- diameter
19+
- width, height
20+
shape:
21+
- - 1
22+
- - 2
23+
datasets:
1824
- name: sweep_mask
1925
dtype: numeric
2026
doc:
2127
Scanning sweep pattern designated using a mask of size [width, height] for 2D stimulation,
2228
where for a given pixel a value of 1 indicates stimulation, and a
2329
value of 0 indicates no stimulation.
24-
required: false
30+
quantity: "?"
31+
dims:
32+
- num_rows
33+
- num_cols
34+
shape:
35+
-
36+
-
2537
- neurodata_type_def: OptogeneticStimulus3DPattern
2638
neurodata_type_inc: LabMetaData
2739
doc: Container to store the information about a generic 3D stimulus pattern (spatial information).
2840
attributes:
2941
- name: description
3042
dtype: text
3143
doc: Description of the scanning or scanless method for shaping optogenetic light. Examples include diffraction limited points, 3D shot, disks, etc.
32-
required: false
33-
- name: sweep_size
44+
- name: sweep_size_in_um
3445
dtype: numeric
3546
doc:
36-
Size of the scanning sweep pattern in micrometers. If a scalar is provided, the sweep pattern is
47+
Size of the scanning sweep pattern (default in micrometers). If a scalar is provided, the sweep pattern is
3748
assumed to be a cylinder (for 3D patterns), with diameter 'sweep_size'.
3849
If 'sweep_size' is a three dimensional array, the the sweep pattern is assumed to be a
3950
cuboid, with dimensions [width, height, depth].
4051
required: false
52+
dims:
53+
- diameter
54+
- width, height, depth
55+
shape:
56+
- - 1
57+
- - 3
58+
datasets:
4159
- name: sweep_mask
4260
dtype: numeric
4361
doc:
4462
Scanning sweep pattern designated using a mask of size [width,height, depth] for 3D stimulation,
4563
where for a given pixel a value of 1 indicates stimulation, and a
4664
value of 0 indicates no stimulation.
47-
required: false
65+
quantity: "?"
66+
dims:
67+
- num_rows
68+
- num_cols
69+
- num_planes
70+
shape:
71+
-
72+
-
73+
-
4874
- neurodata_type_def: SpiralScanning
4975
neurodata_type_inc: LabMetaData
5076
doc: Container to store the parameters defining a spiral scanning pattern.
5177
attributes:
52-
- name: diameter
78+
- name: diameter_in_um
5379
dtype: numeric
5480
doc: Spiral diameter (in micrometers).
55-
required: true
5681
- name: number_of_revolutions
5782
dtype: numeric
5883
doc: Number of turns within a spiral.
59-
required: true
84+
- name: height_in_um
85+
dtype: numeric
86+
doc: Spiral height of each sweep (in micrometers).
87+
required: false
6088
- name: description
6189
dtype: text
6290
doc: Describe any additional details about the pattern.
6391
required: false
64-
- name: height
65-
dtype: numeric
66-
doc: Spiral height of each sweep (in micrometers).
67-
required: false
6892
- neurodata_type_def: TemporalFocusing
6993
neurodata_type_inc: LabMetaData
7094
doc: Container to store the parameters defining a temporal focusing beam-shaping.
7195
attributes:
72-
- name: lateral_point_spread_function
96+
- name: lateral_point_spread_function_in_um
7397
dtype: text
7498
doc:
7599
Estimated lateral spatial profile or point spread function, expressed as
76100
mean [um] ± s.d [um].
77-
required: true
78-
- name: axial_point_spread_function
101+
- name: axial_point_spread_function_in_um
79102
dtype: text
80103
doc:
81104
Estimated axial spatial profile or point spread function, expressed as mean
82105
[um] ± s.d [um].
83-
required: true
84106
- name: description
85107
dtype: text
86108
doc: Describe any additional details about the pattern.
@@ -92,12 +114,10 @@ groups:
92114
- name: effector
93115
dtype: text
94116
doc: Light-activated effector protein expressed by the targeted cell (e.g., ChR2).
95-
required: true
96117
links:
97118
- name: light_source
98-
target_type: LightSource
119+
target_type: Device
99120
doc: Light source used to apply photostimulation.
100-
required: true
101121
- name: spatial_light_modulator
102122
target_type: Device
103123
doc: Spatial light modulator used to generate photostimulation pattern.
@@ -110,10 +130,14 @@ groups:
110130
dtype: text
111131
doc: The model specification of the spatial light modulator (e.g. 'X15213 series', from Hamamatsu).
112132
required: false
113-
- name: spatial_resolution
133+
- name: spatial_resolution_in_px
114134
dtype: numeric
115135
doc: Resolution of spatial light modulator (in pixels), formatted as [width, height].
116136
required: false
137+
dims:
138+
- width, height
139+
shape:
140+
- 2
117141
- neurodata_type_def: SpatialLightModulator3D
118142
neurodata_type_inc: Device
119143
doc: 3D spatial light modulator used in the experiment.
@@ -122,105 +146,133 @@ groups:
122146
dtype: text
123147
doc: The model specification of the spatial light modulator (e.g. 'NeuraLight 3D Ultra', from Bruker).
124148
required: false
125-
- name: spatial_resolution
149+
- name: spatial_resolution_in_px
126150
dtype: numeric
127151
doc: Resolution of spatial light modulator (in pixels), formatted as [width, height, depth].
128152
required: false
153+
dims:
154+
- width, height, depth
155+
shape:
156+
- 3
129157
- neurodata_type_def: LightSource
130158
neurodata_type_inc: Device
131159
doc: Light source used in the experiment.
132160
attributes:
133-
- name: stimulation_wavelength
161+
- name: stimulation_wavelength_in_nm
134162
dtype: numeric
135163
doc: Excitation wavelength of stimulation light (nanometers).
136-
required: true
137-
- name: model
138-
dtype: text
139-
doc: Model of light source device.
140-
required: false
141164
- name: filter_description
142165
dtype: text
143166
doc: Filter used to obtain the excitation wavelength of stimulation light, e.g. 'Short pass at 1040 nm'.
144167
required: false
145-
- name: peak_power
168+
- name: peak_power_in_W
146169
dtype: numeric
147170
doc: Incident power of stimulation device (in Watts).
148171
required: false
149-
- name: peak_pulse_energy
172+
- name: peak_pulse_energy_in_J
150173
dtype: numeric
151174
doc: If device is pulsed light source, pulse energy (in Joules).
152175
required: false
153-
- name: intensity
176+
- name: intensity_in_W_per_m2
154177
dtype: numeric
155178
doc: Intensity of the excitation in W/m^2, if known.
156179
required: false
157-
- name: exposure_time
180+
- name: exposure_time_in_s
158181
dtype: numeric
159182
doc: Exposure time of the sample (in sec).
160183
required: false
161-
- name: pulse_rate
184+
- name: pulse_rate_in_Hz
162185
dtype: numeric
163186
doc: If device is pulsed light source, pulse rate (in Hz) used for stimulation.
164187
required: false
188+
- name: model
189+
dtype: text
190+
doc: Model of light source device.
191+
required: false
165192
- neurodata_type_def: OptogeneticStimulusTarget
166193
neurodata_type_inc: LabMetaData
167194
doc: Container to store the targated rois in a photostimulation experiment.
168195
datasets:
169196
- name: targeted_rois
170197
neurodata_type_inc: DynamicTableRegion
171198
doc: A table region referencing a PlaneSegmentation object storing targeted ROIs.
172-
required: true
173199
- name: segmented_rois
174200
neurodata_type_inc: DynamicTableRegion
175201
doc: A table region referencing a PlaneSegmentation object storing segmented ROIs that receive photostimulation.
176-
required: false
202+
quantity: "?"
177203
- neurodata_type_def: PatternedOptogeneticStimulusTable
178204
neurodata_type_inc: TimeIntervals
179205
doc: Table to hold all patterned optogenetic stimulus onsets.
180-
quantity: "?"
181206
datasets:
182207
- name: power
183208
neurodata_type_inc: VectorData
184209
doc: Power (in Watts) defined as a scalar. All rois in target receive the same photostimulation power.
185210
quantity: "?"
211+
attributes:
212+
- name: unit
213+
value: Watts
214+
doc: Unit of measure of power, fixed to Watts.
215+
dtype: text
186216
- name: power_per_roi
187217
neurodata_type_inc: VectorData
188218
doc: Power (in Watts) defined as an array. Each power value refers to each roi in target.
189219
quantity: "?"
220+
attributes:
221+
- name: unit
222+
value: Watts
223+
doc: Unit of measure of power, fixed to Watts.
224+
dtype: text
190225
- name: targets
191226
neurodata_type_inc: VectorData
192227
dtype:
193228
target_type: OptogeneticStimulusTarget
194229
reftype: object
195230
doc: Targeted rois for the stimulus onset.
196-
required: true
197231
- name: stimulus_pattern
198232
neurodata_type_inc: VectorData
199233
dtype:
200234
target_type: LabMetaData
201235
reftype: object
202236
doc: Link to the stimulus pattern.
203-
required: true
204237
- name: stimulus_site
205238
neurodata_type_inc: VectorData
206239
dtype:
207240
target_type: PatternedOptogeneticStimulusSite
208241
reftype: object
209242
doc: Link to the stimulus site.
210-
required: true
211243
- name: frequency
212244
neurodata_type_inc: VectorData
213245
doc: Frequency (in Hz) defined as a scalar. All rois in target receive the photostimulation at the same frequency.
214246
quantity: "?"
247+
attributes:
248+
- name: unit
249+
value: Hertz
250+
doc: Unit of measure of frequency, fixed to Hertz.
251+
dtype: text
215252
- name: frequency_per_roi
216253
neurodata_type_inc: VectorData
217254
doc: Frequency (in Hz) defined as an array. Each frequency value refers to each roi in target.
218255
quantity: "?"
256+
attributes:
257+
- name: unit
258+
value: Hertz
259+
doc: Unit of measure of frequency, fixed to Hertz.
260+
dtype: text
219261
- name: pulse_width
220262
neurodata_type_inc: VectorData
221263
doc: Pulse Width (in sec/phase) defined as a scalar. All rois in target receive the photostimulation with the same pulse width.
222264
quantity: "?"
265+
attributes:
266+
- name: unit
267+
value: seconds/phase
268+
doc: Unit of measure of power, fixed to seconds per phase.
269+
dtype: text
223270
- name: pulse_width_per_roi
224271
neurodata_type_inc: VectorData
225272
doc: Pulse Width (in sec/phase) defined as an array. Each pulse width value refers to each roi in target.
226273
quantity: "?"
274+
attributes:
275+
- name: unit
276+
value: seconds/phase
277+
doc: Unit of measure of power, fixed to seconds per phase.
278+
dtype: text

src/pynwb/ndx_patterned_ogen/__init__.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import os
2-
from pynwb import load_namespaces
2+
from pynwb import load_namespaces, get_class
33

44
try:
55
from importlib.resources import files
@@ -14,22 +14,24 @@
1414
# If that path does not exist, we are likely running in editable mode. Use the local path instead
1515
if not os.path.exists(__spec_path):
1616
__spec_path = __location_of_this_file.parent.parent.parent / "spec" / "ndx-patterned-ogen.namespace.yaml"
17+
18+
load_namespaces(str(__spec_path))
19+
20+
SpatialLightModulator2D = get_class('SpatialLightModulator2D', 'ndx-patterned-ogen')
21+
SpatialLightModulator3D = get_class('SpatialLightModulator3D', 'ndx-patterned-ogen')
22+
LightSource = get_class('LightSource', 'ndx-patterned-ogen')
23+
OptogeneticStimulus2DPattern = get_class('OptogeneticStimulus2DPattern', 'ndx-patterned-ogen')
24+
OptogeneticStimulus3DPattern = get_class('OptogeneticStimulus3DPattern', 'ndx-patterned-ogen')
25+
SpiralScanning = get_class('SpiralScanning', 'ndx-patterned-ogen')
26+
TemporalFocusing = get_class('TemporalFocusing', 'ndx-patterned-ogen')
1727

1828
# Load the namespace
19-
load_namespaces(str(__spec_path))
2029

2130
from .patterned_ogen import (
22-
SpatialLightModulator3D,
23-
SpatialLightModulator2D,
24-
LightSource,
2531
PatternedOptogeneticStimulusSite,
2632
PatternedOptogeneticStimulusTable,
27-
OptogeneticStimulus2DPattern,
28-
OptogeneticStimulus3DPattern,
2933
OptogeneticStimulusSite,
3034
OptogeneticStimulusTarget,
31-
SpiralScanning,
32-
TemporalFocusing,
3335
)
3436

3537
__all__ = [

0 commit comments

Comments
 (0)