dj-photon-codecs 0.1.0__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.
@@ -0,0 +1,6 @@
1
+ """DataJoint codec for photon-limited movies with Anscombe transformation."""
2
+
3
+ from ._version import version as __version__
4
+ from .codecs import PhotonCodec
5
+
6
+ __all__ = ["PhotonCodec", "__version__"]
@@ -0,0 +1,24 @@
1
+ # file generated by vcs-versioning
2
+ # don't change, don't track in version control
3
+ from __future__ import annotations
4
+
5
+ __all__ = [
6
+ "__version__",
7
+ "__version_tuple__",
8
+ "version",
9
+ "version_tuple",
10
+ "__commit_id__",
11
+ "commit_id",
12
+ ]
13
+
14
+ version: str
15
+ __version__: str
16
+ __version_tuple__: tuple[int | str, ...]
17
+ version_tuple: tuple[int | str, ...]
18
+ commit_id: str | None
19
+ __commit_id__: str | None
20
+
21
+ __version__ = version = '0.1.0'
22
+ __version_tuple__ = version_tuple = (0, 1, 0)
23
+
24
+ __commit_id__ = commit_id = None
@@ -0,0 +1,267 @@
1
+ """Codec for photon-limited movies with Anscombe transformation."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any
6
+
7
+ import numpy as np
8
+ import zarr
9
+ from anscombe_transform import AnscombeTransformV3
10
+ from datajoint import DataJointError
11
+ from datajoint.builtin_codecs import SchemaCodec
12
+ from zarr.codecs import BloscCodec, BytesCodec
13
+
14
+ # Raw photon counts: one count per photon, and zero counts without light.
15
+ CONVERSION_GAIN = 1.0
16
+ ZERO_LEVEL = 0
17
+ # The Anscombe lookup table covers inputs up to this value; larger ones would be clipped.
18
+ MAX_COUNT = 0x7FFF
19
+ # The transform maps counts up to MAX_COUNT to fewer than 1024 levels.
20
+ ENCODED_DTYPE = "uint16"
21
+
22
+
23
+ def _require_context(context: dict[str, Any] | None, *names: str) -> dict[str, Any]:
24
+ """
25
+ Return ``context``, checked to carry ``names``.
26
+
27
+ DataJoint 2.3.4 and later pass ``context`` to every codec that declares it:
28
+ ``schema``, ``table``, ``field``, and ``config`` on insert, ``config`` on
29
+ fetch. The codec reads them there only, never from underscore keys in ``key``.
30
+ """
31
+ missing = [n for n in names if context is None or context.get(n) is None]
32
+ if context is None or missing:
33
+ raise DataJointError(
34
+ "<photon> needs the context that DataJoint 2.3.4 and later pass to codecs "
35
+ f"(missing: {', '.join(missing)}); install datajoint>=2.3.4"
36
+ )
37
+ return context
38
+
39
+
40
+ def _primary_key(key: dict[str, Any] | None) -> dict[str, Any]:
41
+ """The primary key values in ``key``, without the underscore keys DataJoint 2.3 adds."""
42
+ return {k: v for k, v in (key or {}).items() if not k.startswith("_")}
43
+
44
+
45
+ class PhotonCodec(SchemaCodec):
46
+ """
47
+ Store photon-limited movies with Anscombe variance stabilization.
48
+
49
+ The ``<photon@>`` codec stores movies of raw photon counts as Zarr arrays
50
+ in object storage. Each chunk passes through the Anscombe transform from
51
+ the ``anscombe-transform`` package before Blosc/Zstd compression. The
52
+ transform equalizes the Poisson noise across intensity levels and
53
+ re-quantizes the counts to fewer levels, which compress much better. The
54
+ quantization step is below the photon shot noise.
55
+
56
+ Reading the array applies the inverse transform, so a fetch returns photon
57
+ counts in the original dtype (16-bit for 8-bit input), within the
58
+ quantization step.
59
+
60
+ Example::
61
+
62
+ import datajoint as dj
63
+ import numpy as np
64
+
65
+ schema = dj.Schema('calcium_imaging')
66
+
67
+ @schema
68
+ class Recording(dj.Manual):
69
+ definition = '''
70
+ recording_id : int32
71
+ ---
72
+ movie : <photon@> # photon-limited movie
73
+ '''
74
+
75
+ # Insert raw photon counts
76
+ movie = np.random.poisson(lam=10, size=(1000, 512, 512)).astype('uint16')
77
+ Recording.insert1({'recording_id': 1, 'movie': movie})
78
+
79
+ # Fetch returns a read-only Zarr array
80
+ zarr_array = (Recording & {'recording_id': 1}).fetch1('movie')
81
+ frame_100 = zarr_array[100] # one frame
82
+ snippet = zarr_array[100:200] # a frame range
83
+
84
+ Storage Structure::
85
+
86
+ {store_root}/{schema}/{table}/{pk}/{field}_{token}.zarr/
87
+
88
+ Notes
89
+ -----
90
+ - Input must be non-negative integer photon counts, at most 32767.
91
+ - 8-bit movies are stored and fetched as 16-bit.
92
+ - Chunks hold up to 100 frames with full spatial dimensions, for
93
+ frame-by-frame access.
94
+
95
+ See Also
96
+ --------
97
+ anscombe-transform : Anscombe transform codec for Zarr.
98
+ dj-zarr-codecs : Zarr array storage codec.
99
+ """
100
+
101
+ name = "photon"
102
+ CODEC_VERSION = "1.0" # Data format version for backward compatibility
103
+
104
+ def validate(self, value: Any) -> None:
105
+ """
106
+ Validate that value is a movie of photon counts.
107
+
108
+ Parameters
109
+ ----------
110
+ value : Any
111
+ Value to validate.
112
+
113
+ Raises
114
+ ------
115
+ DataJointError
116
+ If value is not a numpy array of 3 or more dimensions with an
117
+ integer dtype and values from 0 to 32767.
118
+ """
119
+ if not isinstance(value, np.ndarray):
120
+ raise DataJointError(f"<photon> requires numpy.ndarray, got {type(value).__name__}")
121
+ if value.dtype.kind not in "iu":
122
+ raise DataJointError(
123
+ f"<photon> requires an integer array of photon counts, got dtype {value.dtype}"
124
+ )
125
+ if value.ndim < 3:
126
+ raise DataJointError(
127
+ f"<photon> requires 3D+ arrays (time, height, width, ...), got {value.ndim}D"
128
+ )
129
+ if value.size and value.min() < 0:
130
+ raise DataJointError(
131
+ "<photon> requires non-negative values (photon counts cannot be negative)"
132
+ )
133
+ if value.size and value.max() > MAX_COUNT:
134
+ raise DataJointError(f"<photon> supports photon counts up to {MAX_COUNT}")
135
+
136
+ def encode(
137
+ self,
138
+ value: np.ndarray,
139
+ *,
140
+ key: dict | None = None,
141
+ context: dict | None = None,
142
+ store_name: str | None = None,
143
+ ) -> dict:
144
+ """
145
+ Encode a photon-limited movie as an Anscombe-filtered Zarr array.
146
+
147
+ Parameters
148
+ ----------
149
+ value : np.ndarray
150
+ Movie of raw photon counts (3D+: time, height, width, ...).
151
+ key : dict, optional
152
+ Primary key values for path construction.
153
+ context : dict, optional
154
+ ``schema``, ``table``, ``field``, and ``config`` of the insert, as
155
+ DataJoint passes them.
156
+ store_name : str, optional
157
+ Name of the object store to use.
158
+
159
+ Returns
160
+ -------
161
+ dict
162
+ Metadata stored in database: path, store, codec_version, shape, dtype, transform.
163
+
164
+ Raises
165
+ ------
166
+ DataJointError
167
+ If ``context`` lacks the ``schema``, ``table``, ``field``, or
168
+ ``config`` that DataJoint 2.3.4 and later pass, or if encoding fails.
169
+ """
170
+ context = _require_context(context, "schema", "table", "field", "config")
171
+ config = context["config"]
172
+ self.validate(value)
173
+ if value.dtype.itemsize < 2:
174
+ # The inverse lookup table spans counts up to MAX_COUNT, beyond 8 bits.
175
+ value = value.astype(np.uint16 if value.dtype.kind == "u" else np.int16)
176
+ try:
177
+ path, _token = self._build_path(
178
+ context["schema"],
179
+ context["table"],
180
+ context["field"],
181
+ _primary_key(key),
182
+ ext=".zarr",
183
+ store_name=store_name,
184
+ config=config,
185
+ )
186
+ store_map = self._get_backend(store_name, config=config).get_fsmap(path)
187
+
188
+ # Chunk along time so frames can be read in sequence.
189
+ chunks = (min(100, value.shape[0]), *value.shape[1:])
190
+ zarr.create_array(
191
+ store=store_map,
192
+ data=value,
193
+ chunks=chunks,
194
+ filters=[
195
+ AnscombeTransformV3(
196
+ zero_level=ZERO_LEVEL,
197
+ conversion_gain=CONVERSION_GAIN,
198
+ encoded_dtype=ENCODED_DTYPE,
199
+ decoded_dtype=str(value.dtype),
200
+ )
201
+ ],
202
+ # The filter's output is uint16 whatever the input dtype, so the
203
+ # serializer names its byte order.
204
+ serializer=BytesCodec(endian="little"),
205
+ compressors=BloscCodec(cname="zstd", clevel=5, shuffle="bitshuffle"),
206
+ attributes={"codec_name": self.name, "codec_version": self.CODEC_VERSION},
207
+ )
208
+ except Exception as e:
209
+ raise DataJointError(f"Failed to encode photon movie: {e}") from e
210
+
211
+ return {
212
+ "path": path,
213
+ "store": store_name,
214
+ "codec_version": self.CODEC_VERSION,
215
+ "shape": list(value.shape),
216
+ "dtype": str(value.dtype),
217
+ "transform": "anscombe",
218
+ }
219
+
220
+ def decode(
221
+ self,
222
+ stored: dict,
223
+ *,
224
+ key: dict | None = None,
225
+ context: dict | None = None,
226
+ ) -> zarr.Array:
227
+ """
228
+ Open a stored photon-limited movie.
229
+
230
+ Parameters
231
+ ----------
232
+ stored : dict
233
+ Metadata from database containing path and store.
234
+ key : dict, optional
235
+ Primary key values (unused).
236
+ context : dict, optional
237
+ ``config`` of the fetching connection, as DataJoint passes it.
238
+
239
+ Returns
240
+ -------
241
+ zarr.Array
242
+ Read-only Zarr array. Reading it applies the inverse Anscombe
243
+ transform and returns photon counts in the original dtype.
244
+
245
+ Raises
246
+ ------
247
+ DataJointError
248
+ If ``context`` lacks the ``config`` that DataJoint 2.3.4 and later
249
+ pass, or if decoding fails.
250
+ """
251
+ del key # the stored metadata locates the array
252
+ config = _require_context(context, "config")["config"]
253
+ try:
254
+ backend = self._get_backend(stored.get("store"), config=config)
255
+ z = zarr.open_array(backend.get_fsmap(stored["path"]), mode="r")
256
+ except Exception as e:
257
+ raise DataJointError(f"Failed to decode photon movie: {e}") from e
258
+
259
+ # Check codec version for backward compatibility.
260
+ # Priority: Zarr attrs > DB metadata > default "1.0"
261
+ version = str(z.attrs.get("codec_version", stored.get("codec_version", "1.0")))
262
+ if not version.startswith("1."):
263
+ raise DataJointError(
264
+ f"Unsupported photon codec version: {version}. "
265
+ "Upgrade dj-photon-codecs or migrate data."
266
+ )
267
+ return z
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.5
2
+ Name: dj-photon-codecs
3
+ Version: 0.1.0
4
+ Summary: DataJoint codec for photon-limited movies with Anscombe transformation and compression
5
+ Project-URL: Homepage, https://github.com/datajoint/dj-photon-codecs
6
+ Project-URL: Repository, https://github.com/datajoint/dj-photon-codecs
7
+ Project-URL: Documentation, https://dj-photon-codecs.readthedocs.io/
8
+ Project-URL: Bug Tracker, https://github.com/datajoint/dj-photon-codecs/issues
9
+ Author-email: Dimitri Yatsenko <dimitri@datajoint.com>, Davis Bennett <davis.v.bennett@gmail.com>
10
+ License-Expression: Apache-2.0
11
+ License-File: LICENSE
12
+ Keywords: anscombe,codec,datajoint,imaging,photon
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Intended Audience :: Science/Research
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
20
+ Classifier: Topic :: Scientific/Engineering
21
+ Requires-Python: >=3.11
22
+ Requires-Dist: anscombe-transform>=1.0
23
+ Requires-Dist: datajoint>=2.3.4
24
+ Requires-Dist: numpy>=1.25
25
+ Requires-Dist: zarr>=3.1.2
26
+ Description-Content-Type: text/markdown
27
+
28
+ # dj-photon-codecs
29
+
30
+ DataJoint codec for photon-limited movies with Anscombe variance stabilization and compressed Zarr storage.
31
+
32
+ [![PyPI version](https://badge.fury.io/py/dj-photon-codecs.svg)](https://pypi.org/project/dj-photon-codecs/)
33
+ [![Documentation](https://readthedocs.org/projects/dj-photon-codecs/badge/?version=latest)](https://dj-photon-codecs.readthedocs.io/)
34
+ [![License: Apache 2.0](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
35
+
36
+ ## Overview
37
+
38
+ This codec enables efficient storage of photon-limited imaging data (calcium imaging, fluorescence microscopy) by:
39
+
40
+ 1. **Variance stabilization** - Anscombe transformation converts Poisson noise to constant variance
41
+ 2. **High compression** - Blosc/Zstd achieves 3-5x compression on stabilized data
42
+ 3. **Efficient access** - Zarr format with temporal chunking for frame-by-frame processing
43
+
44
+ ## Quick Start
45
+
46
+ ### Installation
47
+
48
+ ```bash
49
+ pip install dj-photon-codecs
50
+ ```
51
+
52
+ ### Basic Usage
53
+
54
+ ```python
55
+ import datajoint as dj
56
+ import numpy as np
57
+
58
+ # Configure object storage
59
+ dj.config['stores'] = {
60
+ 'imaging': {
61
+ 'protocol': 's3',
62
+ 'bucket': 'my-data',
63
+ }
64
+ }
65
+
66
+ # Define table
67
+ schema = dj.Schema('calcium_imaging')
68
+
69
+ @schema
70
+ class Recording(dj.Manual):
71
+ definition = """
72
+ recording_id : int32
73
+ ---
74
+ movie : <photon@imaging> # Photon-limited movie
75
+ """
76
+
77
+ # Insert raw photon counts (non-negative integers up to 32767)
78
+ movie = np.random.poisson(lam=10, size=(1000, 512, 512)).astype(np.uint16)
79
+ Recording.insert1({'recording_id': 1, 'movie': movie})
80
+
81
+ # Fetch returns a read-only Zarr array; reading it applies the inverse transform
82
+ zarr_array = (Recording & {'recording_id': 1}).fetch1('movie')
83
+ frame = zarr_array[100] # photon counts of one frame
84
+ ```
85
+
86
+ The movie is stored as a Zarr array whose chunks pass through the
87
+ [anscombe-transform](https://github.com/datajoint/anscombe-transform) filter
88
+ before Blosc/Zstd compression. The filter re-quantizes the counts with a step
89
+ below the photon shot noise, so the fetched counts match the inserted ones
90
+ within that step.
91
+
92
+ Requires `datajoint>=2.3.4` and Python 3.11 or later.
93
+
94
+ ## Features
95
+
96
+ - **Automatic variance stabilization** using Anscombe transformation
97
+ - **3-5x compression** with Blosc/Zstd on variance-stabilized data
98
+ - **Temporal chunking** optimized for sequential frame access
99
+ - **Schema-addressed paths** mirroring database structure
100
+ - **Lazy loading** - access frames without loading entire movie
101
+ - **Transparent inverse** - fetched arrays read back as photon counts
102
+
103
+ ## When to Use
104
+
105
+ ✅ **Use for:**
106
+ - Photon-limited imaging (calcium imaging, fluorescence microscopy)
107
+ - Data where Poisson shot noise dominates
108
+ - Large movies requiring efficient storage
109
+ - Sequential frame processing workflows
110
+
111
+ ❌ **Don't use for:**
112
+ - Preprocessed/normalized data (ΔF/F, z-scored)
113
+ - Data with negative values
114
+ - Non-Poisson noise dominates
115
+
116
+ ## Documentation
117
+
118
+ 📚 **[Full Documentation](https://dj-photon-codecs.readthedocs.io/)**
119
+
120
+ - [Installation Guide](https://dj-photon-codecs.readthedocs.io/en/latest/getting-started/installation/)
121
+ - [Quick Start Tutorial](https://dj-photon-codecs.readthedocs.io/en/latest/getting-started/quick-start/)
122
+ - [User Guide](https://dj-photon-codecs.readthedocs.io/en/latest/user-guide/overview/)
123
+ - [API Reference](https://dj-photon-codecs.readthedocs.io/en/latest/api/reference/)
124
+ - [Examples](https://dj-photon-codecs.readthedocs.io/en/latest/examples/calcium-imaging/)
125
+
126
+ ## Contributing
127
+
128
+ Contributions are welcome! See our [Contributing Guide](https://dj-photon-codecs.readthedocs.io/en/latest/contributing/).
129
+
130
+ ```bash
131
+ # Development setup
132
+ git clone https://github.com/datajoint/dj-photon-codecs.git
133
+ cd dj-photon-codecs
134
+ uv sync
135
+
136
+ # Run tests (the database test needs Docker and skips without it)
137
+ uv run pytest
138
+
139
+ # Build docs
140
+ uv run --group docs mkdocs serve
141
+ ```
142
+
143
+ ## Support
144
+
145
+ - 📖 [Documentation](https://dj-photon-codecs.readthedocs.io/)
146
+ - 💬 [GitHub Discussions](https://github.com/datajoint/dj-photon-codecs/discussions) - Questions and community
147
+ - 🐛 [GitHub Issues](https://github.com/datajoint/dj-photon-codecs/issues) - Bug reports and feature requests
148
+
149
+ ## Related Projects
150
+
151
+ - [DataJoint](https://datajoint.com) - Scientific data pipeline framework
152
+ - [anscombe-transform](https://github.com/datajoint/anscombe-transform) - Variance stabilization library
153
+ - [dj-zarr-codecs](https://github.com/datajoint/dj-zarr-codecs) - General Zarr array codec
154
+ - [Zarr](https://zarr.dev/) - Chunked, compressed array storage
155
+
156
+ ## License
157
+
158
+ Apache License 2.0. Copyright (c) 2026 DataJoint Inc.
@@ -0,0 +1,8 @@
1
+ dj_photon_codecs/__init__.py,sha256=EEO976ILT3_bKd49HY2Kki1aGnhCmEuMnoTmnMXlRNY,198
2
+ dj_photon_codecs/_version.py,sha256=n_5vdJsPNu7wZ57LGuRL585uvll-hiuvZUBWzdG0RQU,520
3
+ dj_photon_codecs/codecs.py,sha256=VKJY993j_hKcUiT_cQWCvpoeyieMtv50iwkcmtfqnn8,9743
4
+ dj_photon_codecs-0.1.0.dist-info/METADATA,sha256=yfjR7Oijjg0wZYbhRQLfVkXXwzVKo-kjlXF3xIQvqAI,5817
5
+ dj_photon_codecs-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
6
+ dj_photon_codecs-0.1.0.dist-info/entry_points.txt,sha256=qCnsyXeK9zZtbVG18lonFztdEPEdCzRZHew-tLnou8k,57
7
+ dj_photon_codecs-0.1.0.dist-info/licenses/LICENSE,sha256=oiwr9R90o13bPAXICOFr-y6YhML_005xM4adsn6qghc,10760
8
+ dj_photon_codecs-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [datajoint.codecs]
2
+ photon = dj_photon_codecs:PhotonCodec
@@ -0,0 +1,191 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright 2026 DataJoint Inc.
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.