Skip to content

optogenetics.py

activate(schema_name, *, create_schema=True, create_tables=True, linking_module=None)

Activate this schema.

Parameters:

Name Type Description Default
schema_name str

schema name on the database server

required
create_schema bool

when True (default), create schema in the database if it does not yet exist.

True
create_tables bool

when True (default), create schema tables in the database if they do not yet exist.

True
linking_module str

a module (or name) containing the required dependencies.

None
Dependencies

Upstream tables: Device: Referenced by OptoProtocol. Pulse generator used for stimulation. Session: Referenced by OptoProtocol. Typically a recording session. Implantation: Referenced by OptoProtocol. Location of the implanted optical fiber.

Source code in element_optogenetics/optogenetics.py
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def activate(
    schema_name: str,
    *,
    create_schema: bool = True,
    create_tables: bool = True,
    linking_module: str = None,
):
    """Activate this schema.

    Args:
        schema_name (str): schema name on the database server
        create_schema (bool): when True (default), create schema in the database if it
                            does not yet exist.
        create_tables (bool): when True (default), create schema tables in the database
                             if they do not yet exist.
        linking_module (str): a module (or name) containing the required dependencies.

    Dependencies:
        Upstream tables:
            Device: Referenced by OptoProtocol. Pulse generator used for stimulation.
            Session: Referenced by OptoProtocol. Typically a recording session.
            Implantation: Referenced by OptoProtocol. Location of the implanted optical fiber.
    """

    if isinstance(linking_module, str):
        linking_module = importlib.import_module(linking_module)
    assert inspect.ismodule(
        linking_module
    ), "The argument 'linking_module' must be a module's name or a module"

    global _linking_module
    _linking_module = linking_module

    schema.activate(
        schema_name,
        create_schema=create_schema,
        create_tables=create_tables,
        add_objects=_linking_module.__dict__,
    )

OptoWaveformType

Bases: Lookup

Stimulus waveform type (e.g., square, sine, etc.)

Attributes:

Name Type Description
waveform_type varchar(32)

Waveform type (e.g., square, sine)

Source code in element_optogenetics/optogenetics.py
50
51
52
53
54
55
56
57
58
59
60
61
@schema
class OptoWaveformType(dj.Lookup):
    """Stimulus waveform type (e.g., square, sine, etc.)

    Attributes:
        waveform_type ( varchar(32) ): Waveform type (e.g., square, sine)
    """

    definition = """
    waveform_type:    varchar(32)
    """
    contents = zip(["Square", "Ramp", "Sine"])

OptoWaveform

Bases: Lookup

OptoWaveform defines the shape of one cycle of the optogenetic stimulus

Child tables specify features of specific waveforms (e.g., square, sine, etc.)

Attributes:

Name Type Description
waveform_name varchar(32)

Name of waveform

OptoWaveformType foreign key

OptoWaveformType primary key

normalized_waveform longblob

For one cycle, normalized to peak

waveform_description varchar(255), optional

Description of waveform

Source code in element_optogenetics/optogenetics.py
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
@schema
class OptoWaveform(dj.Lookup):
    """OptoWaveform defines the shape of one cycle of the optogenetic stimulus

    Child tables specify features of specific waveforms (e.g., square, sine, etc.)

    Attributes:
        waveform_name ( varchar(32) ): Name of waveform
        OptoWaveformType (foreign key): OptoWaveformType primary key
        normalized_waveform (longblob, optional): For one cycle, normalized to peak
        waveform_description ( varchar(255), optional ): Description of waveform
    """

    definition = """
    # OptoWaveform defines the shape of one cycle of the optogenetic stimulus
    waveform_name            : varchar(32)
    ---
    -> OptoWaveformType
    normalized_waveform=null : longblob      # For one cycle, normalized to peak
    waveform_description=''  : varchar(255)  # description of the waveform
    """

    class Square(dj.Part):
        """Square waveform

        Attributes:
            OptoWaveform (foreign key): OptoWaveform primary key
            on_proportion ( decimal(2, 2) unsigned ): Proportion of stimulus on time within a cycle
            off_proportion ( decimal(2, 2) unsigned ): Proportion of stimulus off time within a cycle
        """

        definition = """
        -> master
        ---
        on_proportion  : decimal(2, 2) unsigned # Proportion of stimulus on time within a cycle
        off_proportion : decimal(2, 2) unsigned # Proportion of stimulus off time within a cycle
        """

    class Ramp(dj.Part):
        """Ramp waveform

        Attributes:
            OptoWaveform (foreign key): OptoWaveform primary key
            ramp_up_proportion ( decimal(2, 2) unsigned ): Ramp up proportion of the linear waveform
            ramp_down_proportion ( decimal(2, 2) unsigned ): Ramp down proportion of the linear waveform
        """

        definition = """
        -> master
        ---
        ramp_up_proportion   : decimal(2, 2) unsigned # Ramp up proportion of the linear waveform
        ramp_down_proportion : decimal(2, 2) unsigned # Ramp down proportion of the linear waveform
        """

    class Sine(dj.Part):
        """Sine Waveform. Starting_phase ranges (0, 2]. 0 for Sine, 0.5 for Cosine

        Attributes:
            OptoWaveform (foreign key): OptoWaveform primary key
            number_of_cycles (smallint): Number of cycles
            starting_phase (decimal(3, 2) ): Phase in pi at the beginning of the cycle.
                Defaults to 0
        """

        definition = """ # Starting_phase ranges (0, 2]. 0 for Sine, 0.5 for Cosine
        -> master
        ---
        number_of_cycles  : smallint
        starting_phase=0  : decimal(3, 2) # (pi) phase at the beginning of the cycle
        """

Square

Bases: Part

Square waveform

Attributes:

Name Type Description
OptoWaveform foreign key

OptoWaveform primary key

on_proportion decimal(2, 2) unsigned

Proportion of stimulus on time within a cycle

off_proportion decimal(2, 2) unsigned

Proportion of stimulus off time within a cycle

Source code in element_optogenetics/optogenetics.py
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
class Square(dj.Part):
    """Square waveform

    Attributes:
        OptoWaveform (foreign key): OptoWaveform primary key
        on_proportion ( decimal(2, 2) unsigned ): Proportion of stimulus on time within a cycle
        off_proportion ( decimal(2, 2) unsigned ): Proportion of stimulus off time within a cycle
    """

    definition = """
    -> master
    ---
    on_proportion  : decimal(2, 2) unsigned # Proportion of stimulus on time within a cycle
    off_proportion : decimal(2, 2) unsigned # Proportion of stimulus off time within a cycle
    """

Ramp

Bases: Part

Ramp waveform

Attributes:

Name Type Description
OptoWaveform foreign key

OptoWaveform primary key

ramp_up_proportion decimal(2, 2) unsigned

Ramp up proportion of the linear waveform

ramp_down_proportion decimal(2, 2) unsigned

Ramp down proportion of the linear waveform

Source code in element_optogenetics/optogenetics.py
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
class Ramp(dj.Part):
    """Ramp waveform

    Attributes:
        OptoWaveform (foreign key): OptoWaveform primary key
        ramp_up_proportion ( decimal(2, 2) unsigned ): Ramp up proportion of the linear waveform
        ramp_down_proportion ( decimal(2, 2) unsigned ): Ramp down proportion of the linear waveform
    """

    definition = """
    -> master
    ---
    ramp_up_proportion   : decimal(2, 2) unsigned # Ramp up proportion of the linear waveform
    ramp_down_proportion : decimal(2, 2) unsigned # Ramp down proportion of the linear waveform
    """

Sine

Bases: Part

Sine Waveform. Starting_phase ranges (0, 2]. 0 for Sine, 0.5 for Cosine

Attributes:

Name Type Description
OptoWaveform foreign key

OptoWaveform primary key

number_of_cycles smallint

Number of cycles

starting_phase decimal(3, 2)

Phase in pi at the beginning of the cycle. Defaults to 0

Source code in element_optogenetics/optogenetics.py
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
class Sine(dj.Part):
    """Sine Waveform. Starting_phase ranges (0, 2]. 0 for Sine, 0.5 for Cosine

    Attributes:
        OptoWaveform (foreign key): OptoWaveform primary key
        number_of_cycles (smallint): Number of cycles
        starting_phase (decimal(3, 2) ): Phase in pi at the beginning of the cycle.
            Defaults to 0
    """

    definition = """ # Starting_phase ranges (0, 2]. 0 for Sine, 0.5 for Cosine
    -> master
    ---
    number_of_cycles  : smallint
    starting_phase=0  : decimal(3, 2) # (pi) phase at the beginning of the cycle
    """

OptoStimParams

Bases: Manual

A single optical stimulus that repeats.

Power and intensity are both optional. Users may wish to document one or the other.

Attributes:

Name Type Description
opto_params_id smallint

Stimulus parameter ID

OptoWaveform foreign key

OptoWaveform primary key

wavelength int

Wavelength in nm of optical stimulation light

power decimal(6, 2), optional

Total power in mW from light source

light_intensity decimal(6, 2), optional

Power for given area

frequency decimal(5, 1)

Frequency in Hz of the waveform

duration decimal(5, 1)

Duration in ms of each optical stimulus

Source code in element_optogenetics/optogenetics.py
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
@schema
class OptoStimParams(dj.Manual):
    """A single optical stimulus that repeats.

    Power and intensity are both optional. Users may wish to document one or the other.

    Attributes:
        opto_params_id (smallint): Stimulus parameter ID
        OptoWaveform (foreign key): OptoWaveform primary key
        wavelength (int): Wavelength in nm of optical stimulation light
        power ( decimal(6, 2), optional ): Total power in mW from light source
        light_intensity ( decimal(6, 2), optional ): Power for given area
        frequency ( decimal(5, 1) ): Frequency in Hz of the waveform
        duration ( decimal(5, 1) ): Duration in ms of each optical stimulus
    """

    definition = """
    # Defines a single optical stimulus that repeats.
    opto_params_id     : smallint
    ---
    -> OptoWaveform
    wavelength           : int             # (nm) wavelength of optical stimulation light
    power=null           : decimal(6, 2)   # (mW) total power from light source
    light_intensity=null : decimal(6, 2)   # (mW/mm2) power for given area
    frequency            : decimal(5, 1)   # (Hz) frequency of the waveform
    duration             : decimal(5, 1)   # (ms) duration of each optical stimulus
    """

OptoProtocol

Bases: Manual

Protocol for a given session. This table ties together the fiber location, pulse generator, and stimulus parameters.

Attributes:

Name Type Description
Session foreign key

Session primary key

protocol_id int

Protocol ID

OptoStimParams foreign key

OptoStimParams primary key

Implantation foreign key

Implantation primary key

Device (foreign key

Device primary key

protocol_description varchar(255), optional

Description of optogenetics protocol

Source code in element_optogenetics/optogenetics.py
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
@schema
class OptoProtocol(dj.Manual):
    """Protocol for a given session.  This table ties together the fiber location, pulse generator, and stimulus parameters.

    Attributes:
        Session (foreign key): Session primary key
        protocol_id (int): Protocol ID
        OptoStimParams (foreign key): OptoStimParams primary key
        Implantation (foreign key): Implantation primary key
        Device  (foreign key, optional): Device  primary key
        protocol_description ( varchar(255), optional ): Description of optogenetics protocol
    """

    definition = """
    -> Session
    protocol_id: int
    ---
    -> OptoStimParams
    -> Implantation
    -> [nullable] Device
    protocol_description='' : varchar(255) # description of optogenetics protocol
    """

OptoEvent

Bases: Manual

Start and end time of the stimulus within a session

Attributes:

Name Type Description
OptoProtocol foreign key

OptoProtocol primary key

stim_start_time float

Stimulus start time in seconds relative to session start

stim_end_time float

Stimulus end time in seconds relative to session start

Source code in element_optogenetics/optogenetics.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
@schema
class OptoEvent(dj.Manual):
    """Start and end time of the stimulus within a session

    Attributes:
        OptoProtocol (foreign key): OptoProtocol primary key
        stim_start_time (float): Stimulus start time in seconds relative to session start
        stim_end_time (float): Stimulus end time in seconds relative to session start
    """

    definition = """
    -> OptoProtocol
    stim_start_time  : float  # (s) stimulus start time relative to session start
    ---
    stim_end_time    : float  # (s) stimulus end time relative session start
    """