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
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 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 | |
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
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 | |
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
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 | |
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
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 | |
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
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 | |
AnalysisFile
Bases: File
Source code in labdata/schema/general.py
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 | |
upload_files(src, dataset, force=True)
Upload a file to the AWS analysis bucket.
src is a list of file paths
Source code in labdata/schema/general.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 419 420 421 422 423 | |
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
481 482 483 484 485 486 487 488 489 490 491 | |
Session
Bases: Manual
Source code in labdata/schema/general.py
517 518 519 520 521 522 523 524 525 | |
Dataset
Bases: Manual
Source code in labdata/schema/general.py
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
DatasetEvents
Bases: Imported
Source code in labdata/schema/general.py
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 627 628 629 | |
Digital
Bases: Part
Source code in labdata/schema/general.py
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 | |
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
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 | |
plot_synced(stream_colors='krbgyb', overlay_original=False, lw=1, force=True)
Plot DatasetEvents.Digital.
Source code in labdata/schema/general.py
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 | |
StreamSync
Bases: Manual
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 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 699 700 701 702 703 704 705 | |
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
678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 | |
clock_stream()
Returns the name of the clock stream(s)
Source code in labdata/schema/general.py
698 699 700 701 702 703 704 705 | |
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
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 669 670 671 672 673 674 675 676 | |
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 | |
PoseEstimationLabelSet
Bases: Manual
Source code in labdata/schema/video.py
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 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 | |
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
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 | |
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
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 | |
PoseEstimationModel
Bases: Manual
Source code in labdata/schema/video.py
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 | |
PoseEstimation
Bases: Manual
Source code in labdata/schema/video.py
232 233 234 235 236 237 238 239 240 241 242 243 | |
EphysRecording
Bases: Imported
Source code in labdata/schema/ephys.py
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 172 173 174 175 176 177 178 179 180 181 182 183 184 | |
add_spikeglx_recording(key)
Adds a recording from Dataset ap.meta files.
Source code in labdata/schema/ephys.py
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 | |
SpikeSorting
Bases: Manual
Source code in labdata/schema/ephys.py
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 | |
Unit
Bases: Part
Source code in labdata/schema/ephys.py
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 | |
get_spike_times(as_dict=True, return_seconds=True, extra_keys=[], warn=True, include_metrics=False, interp_method='cubic-spline')
spike_times = get_spike_times()
Gets spike times corrected if the sync is applied. defaults: as_dict = True return_seconds = True extra_keys = [] warn = True. # show a warning when using just the sampling rate include_metrics = False
Source code in labdata/schema/ephys.py
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 | |
SpikeSortingParams
Bases: Manual
Source code in labdata/schema/ephys.py
221 222 223 224 225 226 227 228 229 230 | |
UnitMetrics
Bases: Computed
Source code in labdata/schema/ephys.py
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 | |
UnitCount
Bases: Computed
Source code in labdata/schema/ephys.py
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 524 525 526 527 528 529 530 531 532 | |
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
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 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 | |
get()
Get the brain imaging data.
| Returns: |
|
|---|
Source code in labdata/schema/histology.py
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | |
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
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
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
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 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 | |
get()
Load the transformed brain stacks.
| Returns: |
|
|---|
Source code in labdata/schema/histology.py
247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 | |
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
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 | |
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
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 | |