Data schema
Schema for lab data management.
This package provides DataJoint schemas (tables) for accessing and managing laboratory data. The schemas are organized into modules by data type:
general- Core tables for files, subjects, sessions, datasetsprocedures- Tables for experimental procedures and protocolsephys- Tables for electrophysiology recordings and analysistwophoton- Tables for two-photon microscopy dataonephoton- Tables for one-photon imaging (widefield and miniscope)tasks- Tables for behavioral task datavideo- Tables for video recordingshistology- Tables for histology and anatomy data
File
Bases: Manual
Table for tracking files stored in (s3 or local) storages.
This table stores metadata about files including their path, storage location, creation date, size and MD5 checksum. It provides methods for:
- Deleting files from both the database and S3 storage (does not delete local files)
- Downloading files from S3 to local storage (does not download local storagefiles)
- Checking if files are archived in S3 Glacier storage (does not check local storage)
The table is used as a base class for AnalysisFile which handles analysis outputs.
Source code in labdata/schema/general.py
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
check_if_files_archived(files=None, restore=True, suppress_error=False)
Check if files are archived in S3 Glacier storage.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in labdata/schema/general.py
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 | |
check_if_files_local(local_paths=None)
Checks if files are in a local path, searches accross all local paths
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in labdata/schema/general.py
261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 | |
delete(transaction=True, safemode=None, force_parts=False)
Delete files from both the database and S3 storage.
| Parameters: |
|
|---|
| Raises: |
|
|---|
Source code in labdata/schema/general.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 | |
get(local_paths=None, check_if_archived=True, restore=True, download=True)
Download files from S3 to local storage.
| Parameters: |
|
|---|
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in labdata/schema/general.py
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 | |
AnalysisFile
Bases: File
Table for tracking analysis output files stored in the analysis S3 bucket.
Extends File with upload helpers. Analysis results (e.g. spike sorting
outputs, segmentation masks) are uploaded here so they can be retrieved by
any lab member with access to the analysis storage.
See Also
File : Base class for raw data file tracking.
Source code in labdata/schema/general.py
395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
generate_filepaths(src, dataset)
Generate destination S3 paths for analysis files.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in labdata/schema/general.py
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 | |
upload_files(src, dataset, force=True)
Upload analysis result files to the analysis S3 bucket.
Computes MD5 checksums, uploads to S3, and inserts records into
AnalysisFile. If a file already exists in the database it is
deleted first when force=True.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in labdata/schema/general.py
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 | |
Procedure
Bases: Manual
Table for tracking experimental procedures performed on subjects.
Each procedure entry includes: - Subject - ProcedureType - Date and time - Lab member who performed it - Optional metadata: weight, and notes
Source code in labdata/schema/procedures.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | |
ProcedureType
Bases: Lookup
Table defining types of experimental procedures.
This lookup table enumerates the different types of experimental procedures, including: - Surgical procedures (surgery, implants, craniotomy) - Behavioral procedures (handling, training) - Other manipulations (injections)
The procedure types are used by the Procedure table to categorize and track all procedures performed.
Source code in labdata/schema/procedures.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |
Subject
Bases: Manual
Experimental subject.
Source code in labdata/schema/general.py
554 555 556 557 558 559 560 561 562 563 564 | |
Session
Bases: Manual
An experimental session for a given subject.
A session groups one or more datasets collected on the same day or
experimental block. The session_name is typically a date string
(YYYY-MM-DD) or a descriptive identifier unique per subject.
Examples:
Query all sessions for a subject::
Session() & dict(subject_name='sub001')
Fetch sessions with experimenter info::
(Session() * LabMember().proj(experimenter='user_name')).fetch(as_dict=True)
Source code in labdata/schema/general.py
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
Dataset
Bases: Manual
A single experimental dataset within a session.
A dataset corresponds to one recording block — for example, one run of a behavioral task, one ephys recording, or one imaging session. Multiple datasets can exist per session (e.g. multiple probes, multiple tasks).
The Dataset.DataFiles part table links each dataset to the files in
File that were acquired during that recording.
Examples:
Find all ephys datasets for a subject::
Dataset() & dict(subject_name='sub001', dataset_type='ephys')
List files belonging to a dataset::
(File() & Dataset.DataFiles() & dict(subject_name='sub001',
session_name='2024-01-15',
dataset_name='ephys_g0_t0'))
Source code in labdata/schema/general.py
631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
DataFiles
Bases: Part
Files acquired as part of this dataset.
Source code in labdata/schema/general.py
663 664 665 666 667 668 | |
DatasetEvents
Bases: Imported
Synchronization events and timestamps from each acquisition stream.
Each row represents one named stream (e.g. nidq, bpod, imec0)
within a dataset. The Digital part table holds per-event timestamps
and values; AnalogChannel holds continuous analog data.
Use DatasetEvents.Digital.fetch_synced() to retrieve events already
converted to a common clock via StreamSync.
Examples:
Fetch all events for a dataset::
(DatasetEvents.Digital() & dict(subject_name='sub001',
session_name='2024-01-15',
dataset_name='ephys_g0_t0')).fetch(as_dict=True)
Source code in labdata/schema/general.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 | |
AnalogChannel
Bases: Part
Continuous analog channel values from one stream within a dataset.
Source code in labdata/schema/general.py
764 765 766 767 768 769 770 771 | |
Digital
Bases: Part
Digital event timestamps from one stream within a dataset.
event_timestamps are in the native clock of stream_name.
Call fetch_synced() to retrieve timestamps already converted to
the master clock defined in StreamSync.
Source code in labdata/schema/general.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 | |
fetch_synced(force=False, method='cubic-spline')
Returned events already synchronized between data streams, following the StreamSync table. method: cubic-spline, piecewise-linear
Source code in labdata/schema/general.py
711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 | |
plot_synced(stream_colors='krbgyb', overlay_original=False, lw=1, force=True)
Plot DatasetEvents.Digital.
Source code in labdata/schema/general.py
742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 | |
StreamSync
Bases: Manual
Inter-stream synchronization mapping for a dataset.
Maps a synchronization pulse shared between two acquisition streams so that timestamps from one stream can be converted to the clock of another. One stream is designated the clock (master); the other carries a copy of the same pulse that is used to align time axes.
Use StreamSync.apply() to convert timestamps or
DatasetEvents.Digital.fetch_synced() to retrieve all events already
aligned to the master clock.
Examples:
Insert a sync entry (clock = nidq, sync pulse = bpod)::
StreamSync().insert1(dict(subject_name='sub001',
session_name='2024-01-15',
dataset_name='ephys_g0_t0',
stream_name='bpod', event_name='clock',
clock_dataset='ephys_g0_t0',
clock_stream='nidq', clock_stream_event='clock'))
Source code in labdata/schema/general.py
773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 | |
apply(values, sync_onsets=None, warn=True, clock_onsets=None, force=False, method='cubic-spline')
Returns synchronized signals according a sync pulse shared from a clock. "clock" is main, "sync" is the same acquisition system as "values"
Source code in labdata/schema/general.py
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 | |
clock_stream()
Returns the name of the clock stream(s)
Source code in labdata/schema/general.py
862 863 864 865 866 867 868 869 | |
get_interp_data(force=False, warn=True, allowed_offset=2)
Force will attempt to remove events from the longest stream so the streams are matched.
Source code in labdata/schema/general.py
802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 | |
Watering
Bases: Manual
Table for tracking water administration to subjects.
This table records water consumed, including: - Subject receiving water - Date and time - Volume of water, in microliters
Source code in labdata/schema/procedures.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | |
Weighing
Bases: Manual
Table for tracking subject weights.
This table stores weight measurements for experimental subjects. Each entry includes: - Subject - Date and time of weighing - Weight in grams
Source code in labdata/schema/procedures.py
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | |
DecisionTask
Bases: Imported
Table for behavioral decision task data.
This table serves as a general schema for decision-making behavioral tasks, abstracting common features that can be inherited by specific task tables defined in plugins. Each entry includes: - Total trial counts (assisted, self-performed, initiated, with choice) - Performance metrics (rewarded, punished trials) - Optional reference to water intake during session
The table includes a Part table (TrialSet) that stores detailed sets of trials within a session, dependent on the modality or condition and includes including: - Trial conditions and modalities - Performance metrics per condition - Timing data (initiation times, reaction times) - Response and subject feedback values - Stimulus parameters (intensity, block)
This data can be used to compute: - Psychometric curves - Learning curves - Reaction time distributions - Choice biases and strategies - ...
The schema is designed to be flexible and is meant to be populated by specific task tables (defined as plugins) while maintaining a consistent interface for analysis and visualization.
Source code in labdata/schema/tasks.py
3 4 5 6 7 8 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
TrialSet
Bases: Part
Per-condition trial subset within a behavioral session.
Stores counts, performance metrics, timing, and per-trial arrays for
one modality or condition (e.g. easy vs hard, left vs right).
Multiple TrialSet rows can coexist for a single session.
Source code in labdata/schema/tasks.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | |
PoseEstimationLabelSet
Bases: Manual
A set of manually labeled frames for training a pose estimation model.
Frames are stored in PoseEstimationLabelSet.Frame and keypoint labels
(x, y, optional z) in PoseEstimationLabelSet.Label. Use
export_labeling() to export labels in DeepLabCut / napari-deeplabcut
format.
Source code in labdata/schema/video.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 134 135 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 163 164 165 166 167 168 169 170 171 | |
Frame
Bases: Part
Labeled video frames belonging to this label set.
Source code in labdata/schema/video.py
51 52 53 54 55 56 57 58 59 | |
Label
Bases: Part
Keypoint labels (x, y, optional z) for each labeled frame.
Source code in labdata/schema/video.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
export_labeling(model_num=None, bodyparts=None, disperse_labels=False, export_only_labeled=False)
Exports labeling for PoseEstimation (for use with napari-deeplabcut)
Source code in labdata/schema/video.py
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 | |
update_labeling(labeling_file)
(PoseEstimationLabelSet() & 'pose_label_set_num =3').update_labeling('filename.h5')
Updates the labels in the PoseEstimationLabelSet from a file. Currently only DLC format is supported.
Reach out if you need other formats. Joao Couto 2023
Source code in labdata/schema/video.py
133 134 135 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 163 164 165 166 167 168 169 170 171 | |
PoseEstimationModel
Bases: Manual
A trained pose estimation model (DeepLabCut or similar).
Models are stored as .zip archives in AnalysisFile. Use
insert_model() to upload a trained model folder and register it, and
get_model() to download and unpack the model for inference.
Source code in labdata/schema/video.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
get_model()
Download and unpack the model archive for this entry.
| Returns: |
|
|---|
Source code in labdata/schema/video.py
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 | |
insert_model(model_num, model_folder=None, pose_label_set_num=None, algorithm_name=None, parameters=None, training_datetime=None, container_name=None, code_link=None)
Archive and upload a trained pose estimation model folder.
Zips model_folder, uploads to the analysis S3 bucket via
AnalysisFile.upload_files(), and inserts (or updates) a row in
PoseEstimationModel.
| Parameters: |
|
|---|
Source code in labdata/schema/video.py
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | |
PoseEstimation
Bases: Manual
Pose estimation predictions for each keypoint in a video.
Each row stores the full time series of x, y (and optional z) coordinates
and likelihood values for one body part label in one video, produced by a
specific PoseEstimationModel.
Source code in labdata/schema/video.py
287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
EphysRecording
Bases: Imported
Electrophysiology recording with one or more silicon probes.
These tables are to be populated automatically by EphysRule._post_upload()
from recording metadata files. Each recording has one ProbeSetting row per
probe and ProbeFile rows pointing to the compressed binary files.
Use add_spikeglx_recording() to insert for spikeglx recordings if missing
from metadata files and add_nidq_events() to parse and insert NIDQ/OneBox
digital events into DatasetEvents.
Currently only SpikeGLX recordings are supported; support of OpenEphys is planned.
Examples:
Fetch all recordings for a subject::
EphysRecording() & dict(subject_name='sub001')
Open compressed binary for probe 0, if files are compressed with mtscomp (.cbin, .ch)::
# Get the file paths
cbinfile = (File & (EphysRecording.ProbeFile() & ephysrecordingkey & 'probe_num = 0') & 'file_path LIKE "%.ap.cbin"').get()
chfile = (File & (EphysRecording.ProbeFile() & ephysrecordingkey & 'probe_num = 0') & 'file_path LIKE "%.ap.ch"').get()
# open the recording
from mtscomp import decompress
mapped_data = decompress(cbinfile[0],chfile[0])
Source code in labdata/schema/ephys.py
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 134 135 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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
ProbeFile
Bases: Part
Files belonging to a probe recording. There can be multiple files for a single probe (compressed file, metadata...)
Source code in labdata/schema/ephys.py
156 157 158 159 160 161 162 163 | |
ProbeSetting
Bases: Part
Per-probe configuration and sampling rate for a recording.
Source code in labdata/schema/ephys.py
147 148 149 150 151 152 153 154 155 | |
add_nidq_events(key=None)
Parse NIDQ/OneBox digital events and insert into DatasetEvents.
Reads the NIDQ (or OneBox) binary file for each dataset in the query,
unpacks digital channels, and inserts one DatasetEvents row and one
DatasetEvents.Digital row per event channel. Skips datasets that
already have NIDQ events.
| Parameters: |
|
|---|
Source code in labdata/schema/ephys.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
add_spikeglx_recording(key)
Adds a recording from Dataset ap.meta files.
Source code in labdata/schema/ephys.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 | |
SpikeSorting
Bases: Manual
Spike sorting results for one probe recording.
Each row corresponds to one run of a sorting algorithm (identified by
SpikeSortingParams) on one probe (EphysRecording.ProbeSetting).
The Unit part table contains raw spike times (in samples) and, after
calling SpikeSorting.Unit.get_spike_times(), returns them in seconds
with optional stream synchronisation via StreamSync.
The Waveforms part table holds median waveform shapes for each unit.
Examples:
Get spike times in seconds for a session (see StreamSync also)::
sesskey = dict(subject_name='sub001', session_name='sess')
units = (SpikeSorting.Unit() & sesskey).get_spike_times()
Get units with waveforms::
units = (SpikeSorting.Unit() & sesskey).get_units_with_waveforms()
Source code in labdata/schema/ephys.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |
IntermediateFiles
Bases: Part
Intermediate analysis files (e.g. preprocessed binaries) kept in AnalysisFile.
Source code in labdata/schema/ephys.py
511 512 513 514 515 516 | |
LinkedDatasets
Bases: Part
Cross-session dataset linkage for multi-session spike sorting.
Source code in labdata/schema/ephys.py
518 519 520 521 522 523 | |
Segment
Bases: Part
Raw AP-band segments used for template quality assessment.
Source code in labdata/schema/ephys.py
362 363 364 365 366 367 368 369 370 | |
Unit
Bases: Part
Sorted unit spike times, positions, and amplitudes.
spike_times are stored in samples (uint64). Call
get_spike_times(return_seconds=True) to convert to seconds
using either the probe sampling rate or a StreamSync
interpolation function.
Source code in labdata/schema/ephys.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
get_sampling_rates()
Return sampling rates (float) for each unit in this query.
Source code in labdata/schema/ephys.py
388 389 390 391 | |
get_spike_times(as_dict=True, return_seconds=True, extra_keys=[], warn=True, include_metrics=False, interp_method='cubic-spline')
Gets spike times in seconds if return_seconds=True. Uses the sampling rate if no StreamSync
is defined, otherwise returns the spike times in a synchronized timebase.
spike_times = get_spike_times()
Additional parameters:
as_dict = True # return as dictionary or just the spike times
return_seconds = True # returns in seconds
extra_keys = [] # add additional keys from UnitMetrics or SpikeSorting.Unit
warn = True # show a warning when using just the sampling rate
include_metrics = False # allows selecting additional keys from UnitMetrics
Source code in labdata/schema/ephys.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
get_units_with_waveforms(return_seconds=True, interp_method='cubic-spline')
Fetch spike times and attach median waveforms from SpikeSorting.Waveforms.
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in labdata/schema/ephys.py
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
Waveforms
Bases: Part
Median spike waveforms for each sorted unit.
Source code in labdata/schema/ephys.py
470 471 472 473 474 475 476 | |
delete(transaction=True, safemode=None, force_parts=False, keep_analysis=False)
Delete spike sorting rows and their associated analysis files.
Removes SpikeSorting (and part table) rows from the database, then
deletes the linked waveforms_file and features_file from
AnalysisFile and S3 — unless keep_analysis=True.
| Parameters: |
|
|---|
Source code in labdata/schema/ephys.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 | |
SpikeSortingParams
Bases: Manual
Parameter sets for spike sorting algorithms (e.g. Kilosort versions).
Each row defines one parameter preset. parameters_dict stores a
JSON-encoded dict that is passed to the spike sorter. Insert a new row
here before queueing a SpksCompute job with that parameter set.
Source code in labdata/schema/ephys.py
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
UnitMetrics
Bases: Computed
Per-unit quality metrics computed from spike times and waveforms.
Populated automatically via PopulateCompute or directly with
UnitMetrics.populate(). Requires SpikeSorting.Unit and the
spks package for metric calculations.
Key metrics: firing_rate, isi_contamination, amplitude_cutoff,
presence_ratio, depth, spike_duration, spike_amplitude.
Use with UnitCount and UnitCountCriteria to apply quality thresholds
and count SUA/MUA units per session.
Source code in labdata/schema/ephys.py
525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
make(key)
Compute and insert quality metrics for one sorted unit.
Source code in labdata/schema/ephys.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 | |
UnitCount
Bases: Computed
Count of SUA and MUA units per sorting, given quality criteria.
Computed from UnitMetrics by applying the threshold expressions in
UnitCountCriteria. The Unit part table records which units pass.
Examples:
Count good units for a subject::
(UnitCount() & dict(subject_name='sub001')).fetch('sua', 'mua')
Source code in labdata/schema/ephys.py
645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
Unit
Bases: Part
Individual unit pass/fail record for a given criteria set.
Source code in labdata/schema/ephys.py
666 667 668 669 670 671 672 673 | |
make(key)
Count SUA and MUA units for one sorting × criteria combination.
Source code in labdata/schema/ephys.py
675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 | |
Widefield
Bases: Imported
Table for widefield one-photon imaging data.
This table stores metadata about widefield imaging recordings including: - Frame dimensions and counts - Frame rate - Optical parameters (magnification, objective, pixel scale) - Reference to raw data file - Imaging software details
The table includes a Part table for storing different projections of the data (mean, std, var, max).
Source code in labdata/schema/onephoton.py
5 6 7 8 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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
Projection
Bases: Part
Part table for storing projections of widefield imaging data.
This table stores projections (mean, std, var, max) of the widefield imaging data.
| Attributes: |
|
|---|
Source code in labdata/schema/onephoton.py
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |
open()
Opens the widefield imaging data file.
| Returns: |
|
|---|
Source code in labdata/schema/onephoton.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 | |
FixedBrain
Bases: Imported
Whole brain histology or fixed tissue. The class provides methods for: - Loading brain image data via get() method - Viewing brain data in napari via napari_open() method
Definition
file_path : str Path to the brain imaging data file num_channels : int Number of imaging channels width : int Image width in pixels height : int Image height in pixels um_per_pixel : array Microns per pixel resolution in each dimension hardware : str Imaging hardware/microscope used
Source code in labdata/schema/histology.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 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 | |
Channel
Bases: Part
Per-channel metadata for a fixed whole-brain lightsheet stack.
Stores the excitation/emission wavelength and a free-text description for each imaging channel (e.g. DAPI, GFP, tdTomato).
Source code in labdata/schema/histology.py
67 68 69 70 71 72 73 74 75 76 77 78 79 | |
get()
Get the brain imaging data.
| Returns: |
|
|---|
Source code in labdata/schema/histology.py
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
napari_open(**kwargs)
Open brain data in napari viewer.
Opens the brain imaging data in a napari viewer window for visualization. Only one brain can be opened at a time.
Pass channel_axis = 1 to open with color
| Returns: |
|
|---|
| Raises: |
|
|---|
Source code in labdata/schema/histology.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
FixedBrainTransform
Bases: Computed
Table for storing transformed fixed brain images.
This class computes and stores transformed versions of fixed brain images based on parameters from FixedBrainTransformParameters.
The transformed images are stored as TIFF files in the analysis storage location.
Definition
file_path : str Path to the transformed TIFF file in analysis storage storage : str Storage location name (default: 'analysis') um_per_pixel : array-like Resolution in microns per pixel for each dimension shape : array-like Shape of the transformed stack [T,C,X,Y] hemisphere : str Which hemisphere is included ('left', 'right', or 'both')
Methods:
| Name | Description |
|---|---|
transform |
Apply transformations specified in parameters to generate transformed stack Returnsndarray The transformed image stack |
get |
Load and return the transformed image stack(s) Returnslist List of transformed image stacks as numpy arrays |
Source code in labdata/schema/histology.py
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
get()
Load the transformed brain stacks.
| Returns: |
|
|---|
Source code in labdata/schema/histology.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 | |
make(k)
Apply transform parameters and store the result as an OME-TIFF file.
Source code in labdata/schema/histology.py
276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 | |
transform(key)
Transform fixed brain image according to parameters.
Applies transformations specified in FixedBrainTransformParameters to generate a transformed stack. If the transform has already been computed, loads and returns the existing transformed stack from storage.
Transformation order: 1. Downsample if specified 2. Rotate if specified 3. Crop if specified 4. Transpose dimensions if specified
| Parameters: |
|
|---|
| Returns: |
|
|---|
Source code in labdata/schema/histology.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
FixedBrainTransformAnnotation
Bases: Manual
Table for storing manual annotations of brain locations.
This table stores manually annotated points in transformed brain volumes, such as: - Probe tracks - Injection sites - Anatomical landmarks - Region boundaries
Each annotation consists of: - annotation_name: Description of what is being annotated - annotation_type: Category of annotation (e.g. 'probe_track', 'injection') - xyz: Array of x,y,z coordinates marking the annotation location
The coordinates are in pixels relative to the transformed brain volume.
Source code in labdata/schema/histology.py
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 | |