Skip to content

Commit

Permalink
Change quantitative properties to add units to name (#6)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
alessandratrapani and CodyCBakerPhD authored Feb 5, 2024
1 parent 042cc16 commit 1880684
Show file tree
Hide file tree
Showing 6 changed files with 538 additions and 457 deletions.
134 changes: 93 additions & 41 deletions spec/ndx-patterned-ogen.extensions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,81 +6,103 @@ groups:
- name: description
dtype: text
doc: Description of the scanning or scanless method for shaping optogenetic light. Examples include diffraction limited points, 3D shot, disks, etc.
required: false
- name: sweep_size
- name: sweep_size_in_um
dtype: numeric
doc:
Size of the scanning sweep pattern in micrometers. If a scalar is provided, the sweep pattern is
Size of the scanning sweep pattern (default in micrometers). If a scalar is provided, the sweep pattern is
assumed to be a circle (for 2D patterns) with diameter 'sweep_size'.
If 'sweep_size' is a two dimensional array, the the sweep pattern is assumed to be a
rectangle, with dimensions [width, height].
required: false
dims:
- diameter
- width, height
shape:
- - 1
- - 2
datasets:
- name: sweep_mask
dtype: numeric
doc:
Scanning sweep pattern designated using a mask of size [width, height] for 2D stimulation,
where for a given pixel a value of 1 indicates stimulation, and a
value of 0 indicates no stimulation.
required: false
quantity: "?"
dims:
- num_rows
- num_cols
shape:
-
-
- neurodata_type_def: OptogeneticStimulus3DPattern
neurodata_type_inc: LabMetaData
doc: Container to store the information about a generic 3D stimulus pattern (spatial information).
attributes:
- name: description
dtype: text
doc: Description of the scanning or scanless method for shaping optogenetic light. Examples include diffraction limited points, 3D shot, disks, etc.
required: false
- name: sweep_size
- name: sweep_size_in_um
dtype: numeric
doc:
Size of the scanning sweep pattern in micrometers. If a scalar is provided, the sweep pattern is
Size of the scanning sweep pattern (default in micrometers). If a scalar is provided, the sweep pattern is
assumed to be a cylinder (for 3D patterns), with diameter 'sweep_size'.
If 'sweep_size' is a three dimensional array, the the sweep pattern is assumed to be a
cuboid, with dimensions [width, height, depth].
required: false
dims:
- diameter
- width, height, depth
shape:
- - 1
- - 3
datasets:
- name: sweep_mask
dtype: numeric
doc:
Scanning sweep pattern designated using a mask of size [width,height, depth] for 3D stimulation,
where for a given pixel a value of 1 indicates stimulation, and a
value of 0 indicates no stimulation.
required: false
quantity: "?"
dims:
- num_rows
- num_cols
- num_planes
shape:
-
-
-
- neurodata_type_def: SpiralScanning
neurodata_type_inc: LabMetaData
doc: Container to store the parameters defining a spiral scanning pattern.
attributes:
- name: diameter
- name: diameter_in_um
dtype: numeric
doc: Spiral diameter (in micrometers).
required: true
- name: number_of_revolutions
dtype: numeric
doc: Number of turns within a spiral.
required: true
- name: height_in_um
dtype: numeric
doc: Spiral height of each sweep (in micrometers).
required: false
- name: description
dtype: text
doc: Describe any additional details about the pattern.
required: false
- name: height
dtype: numeric
doc: Spiral height of each sweep (in micrometers).
required: false
- neurodata_type_def: TemporalFocusing
neurodata_type_inc: LabMetaData
doc: Container to store the parameters defining a temporal focusing beam-shaping.
attributes:
- name: lateral_point_spread_function
- name: lateral_point_spread_function_in_um
dtype: text
doc:
Estimated lateral spatial profile or point spread function, expressed as
mean [um] ± s.d [um].
required: true
- name: axial_point_spread_function
- name: axial_point_spread_function_in_um
dtype: text
doc:
Estimated axial spatial profile or point spread function, expressed as mean
[um] ± s.d [um].
required: true
- name: description
dtype: text
doc: Describe any additional details about the pattern.
Expand All @@ -92,12 +114,10 @@ groups:
- name: effector
dtype: text
doc: Light-activated effector protein expressed by the targeted cell (e.g., ChR2).
required: true
links:
- name: light_source
target_type: LightSource
target_type: Device
doc: Light source used to apply photostimulation.
required: true
- name: spatial_light_modulator
target_type: Device
doc: Spatial light modulator used to generate photostimulation pattern.
Expand All @@ -110,10 +130,14 @@ groups:
dtype: text
doc: The model specification of the spatial light modulator (e.g. 'X15213 series', from Hamamatsu).
required: false
- name: spatial_resolution
- name: spatial_resolution_in_px
dtype: numeric
doc: Resolution of spatial light modulator (in pixels), formatted as [width, height].
required: false
dims:
- width, height
shape:
- 2
- neurodata_type_def: SpatialLightModulator3D
neurodata_type_inc: Device
doc: 3D spatial light modulator used in the experiment.
Expand All @@ -122,105 +146,133 @@ groups:
dtype: text
doc: The model specification of the spatial light modulator (e.g. 'NeuraLight 3D Ultra', from Bruker).
required: false
- name: spatial_resolution
- name: spatial_resolution_in_px
dtype: numeric
doc: Resolution of spatial light modulator (in pixels), formatted as [width, height, depth].
required: false
dims:
- width, height, depth
shape:
- 3
- neurodata_type_def: LightSource
neurodata_type_inc: Device
doc: Light source used in the experiment.
attributes:
- name: stimulation_wavelength
- name: stimulation_wavelength_in_nm
dtype: numeric
doc: Excitation wavelength of stimulation light (nanometers).
required: true
- name: model
dtype: text
doc: Model of light source device.
required: false
- name: filter_description
dtype: text
doc: Filter used to obtain the excitation wavelength of stimulation light, e.g. 'Short pass at 1040 nm'.
required: false
- name: peak_power
- name: peak_power_in_W
dtype: numeric
doc: Incident power of stimulation device (in Watts).
required: false
- name: peak_pulse_energy
- name: peak_pulse_energy_in_J
dtype: numeric
doc: If device is pulsed light source, pulse energy (in Joules).
required: false
- name: intensity
- name: intensity_in_W_per_m2
dtype: numeric
doc: Intensity of the excitation in W/m^2, if known.
required: false
- name: exposure_time
- name: exposure_time_in_s
dtype: numeric
doc: Exposure time of the sample (in sec).
required: false
- name: pulse_rate
- name: pulse_rate_in_Hz
dtype: numeric
doc: If device is pulsed light source, pulse rate (in Hz) used for stimulation.
required: false
- name: model
dtype: text
doc: Model of light source device.
required: false
- neurodata_type_def: OptogeneticStimulusTarget
neurodata_type_inc: LabMetaData
doc: Container to store the targated rois in a photostimulation experiment.
datasets:
- name: targeted_rois
neurodata_type_inc: DynamicTableRegion
doc: A table region referencing a PlaneSegmentation object storing targeted ROIs.
required: true
- name: segmented_rois
neurodata_type_inc: DynamicTableRegion
doc: A table region referencing a PlaneSegmentation object storing segmented ROIs that receive photostimulation.
required: false
quantity: "?"
- neurodata_type_def: PatternedOptogeneticStimulusTable
neurodata_type_inc: TimeIntervals
doc: Table to hold all patterned optogenetic stimulus onsets.
quantity: "?"
datasets:
- name: power
neurodata_type_inc: VectorData
doc: Power (in Watts) defined as a scalar. All rois in target receive the same photostimulation power.
quantity: "?"
attributes:
- name: unit
value: Watts
doc: Unit of measure of power, fixed to Watts.
dtype: text
- name: power_per_roi
neurodata_type_inc: VectorData
doc: Power (in Watts) defined as an array. Each power value refers to each roi in target.
quantity: "?"
attributes:
- name: unit
value: Watts
doc: Unit of measure of power, fixed to Watts.
dtype: text
- name: targets
neurodata_type_inc: VectorData
dtype:
target_type: OptogeneticStimulusTarget
reftype: object
doc: Targeted rois for the stimulus onset.
required: true
- name: stimulus_pattern
neurodata_type_inc: VectorData
dtype:
target_type: LabMetaData
reftype: object
doc: Link to the stimulus pattern.
required: true
- name: stimulus_site
neurodata_type_inc: VectorData
dtype:
target_type: PatternedOptogeneticStimulusSite
reftype: object
doc: Link to the stimulus site.
required: true
- name: frequency
neurodata_type_inc: VectorData
doc: Frequency (in Hz) defined as a scalar. All rois in target receive the photostimulation at the same frequency.
quantity: "?"
attributes:
- name: unit
value: Hertz
doc: Unit of measure of frequency, fixed to Hertz.
dtype: text
- name: frequency_per_roi
neurodata_type_inc: VectorData
doc: Frequency (in Hz) defined as an array. Each frequency value refers to each roi in target.
quantity: "?"
attributes:
- name: unit
value: Hertz
doc: Unit of measure of frequency, fixed to Hertz.
dtype: text
- name: pulse_width
neurodata_type_inc: VectorData
doc: Pulse Width (in sec/phase) defined as a scalar. All rois in target receive the photostimulation with the same pulse width.
quantity: "?"
attributes:
- name: unit
value: seconds/phase
doc: Unit of measure of power, fixed to seconds per phase.
dtype: text
- name: pulse_width_per_roi
neurodata_type_inc: VectorData
doc: Pulse Width (in sec/phase) defined as an array. Each pulse width value refers to each roi in target.
quantity: "?"
attributes:
- name: unit
value: seconds/phase
doc: Unit of measure of power, fixed to seconds per phase.
dtype: text
20 changes: 11 additions & 9 deletions src/pynwb/ndx_patterned_ogen/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from pynwb import load_namespaces
from pynwb import load_namespaces, get_class

try:
from importlib.resources import files
Expand All @@ -14,22 +14,24 @@
# If that path does not exist, we are likely running in editable mode. Use the local path instead
if not os.path.exists(__spec_path):
__spec_path = __location_of_this_file.parent.parent.parent / "spec" / "ndx-patterned-ogen.namespace.yaml"

load_namespaces(str(__spec_path))

SpatialLightModulator2D = get_class('SpatialLightModulator2D', 'ndx-patterned-ogen')
SpatialLightModulator3D = get_class('SpatialLightModulator3D', 'ndx-patterned-ogen')
LightSource = get_class('LightSource', 'ndx-patterned-ogen')
OptogeneticStimulus2DPattern = get_class('OptogeneticStimulus2DPattern', 'ndx-patterned-ogen')
OptogeneticStimulus3DPattern = get_class('OptogeneticStimulus3DPattern', 'ndx-patterned-ogen')
SpiralScanning = get_class('SpiralScanning', 'ndx-patterned-ogen')
TemporalFocusing = get_class('TemporalFocusing', 'ndx-patterned-ogen')

# Load the namespace
load_namespaces(str(__spec_path))

from .patterned_ogen import (
SpatialLightModulator3D,
SpatialLightModulator2D,
LightSource,
PatternedOptogeneticStimulusSite,
PatternedOptogeneticStimulusTable,
OptogeneticStimulus2DPattern,
OptogeneticStimulus3DPattern,
OptogeneticStimulusSite,
OptogeneticStimulusTarget,
SpiralScanning,
TemporalFocusing,
)

__all__ = [
Expand Down
Loading

0 comments on commit 1880684

Please sign in to comment.