facial_behavior_estimation.py
activate(facemap_schema_name, *, create_schema=True, create_tables=True, linking_module=None)
¶
Activate schema.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
facemap_schema_name |
str
|
Schema name on the database server to activate the
|
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 tables in the database if they do not yet exist. |
True
|
linking_module |
str
|
A module name or a module containing the required
dependencies to activate the |
None
|
Dependencies: Upstream tables: + Session: A parent table to VideoRecording, identifying a recording session + Equipment: A parent table to VideoRecording, identifying video recording equipment Functions: + get_facemap_root_data_dir() -> list Retrieves the root data directory(s) with face recordings for all subject/sessions. Returns a string for the full path to the root data directory. + get_facemap_processed_data_dir(session_key: dict) -> str Optional function to retrieve the desired output directory for Facemap files for a given session. If unspecified, the output is stored in the video folder for the session, which is the default behavior of Facemap. Returns a string of the absolute path of the output directory.
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
get_facemap_root_data_dir()
¶
Pull the relevant function from the parent namespace to specify the root data directory(s).
It is recommended that all paths in DataJoint Elements are stored as relative paths, with respect to some user-configured "root" directory. The root(s) may vary between data modalities and user machines.
Returns:
Name | Type | Description |
---|---|---|
paths |
list
|
list of path(s) to root data directory(s) for Facemap |
Source code in element_facemap/facial_behavior_estimation.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
|
get_facemap_processed_data_dir()
¶
Facemap output directory
If specified by the user, this function provides Facemap with an output directory for processed files. If unspecified, the output is stored in the video directory for the session, which is the default behavior of Facemap.
Returns:
Name | Type | Description |
---|---|---|
path |
str
|
path to Facemap output directory |
Source code in element_facemap/facial_behavior_estimation.py
91 92 93 94 95 96 97 98 99 100 101 102 103 |
|
get_facemap_video_files(video_key)
¶
Retrieve the list of video recording files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
video_key |
dict
|
Primary key of an entry in the VideoRecording table. |
required |
Returns:
Type | Description |
---|---|
List[Path]
|
List of absolute POSIX paths of the video files. |
Source code in element_facemap/facial_behavior_estimation.py
106 107 108 109 110 111 112 113 114 115 |
|
VideoRecording
¶
Bases: Manual
Video recorded in an experiment session for Facemap analysis.
Attributes:
Name | Type | Description |
---|---|---|
Session |
foreign key
|
Primary key from Session. |
recording_id |
int
|
Recording ID. |
Device |
foreign key
|
Primary key from Device. |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
File
¶
Bases: Part
Relative path of video file with respect to facemap_root_data_dir directory.
Attributes:
Name | Type | Description |
---|---|---|
master |
foreign key
|
Primary key from VideoRecording. |
file_id |
smallint
|
File ID. |
file_path |
str
|
Filepath of video, relative to root directory. |
Source code in element_facemap/facial_behavior_estimation.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
|
RecordingInfo
¶
Bases: Imported
Information extracted from video file.
Attributes:
Name | Type | Description |
---|---|---|
VideoRecording |
foreign key
|
Primary key for VideoRecording table. |
px_height |
int
|
Height in pixels. |
px_width |
int
|
Width in pixels. |
nframes |
int
|
Number of frames. |
fps |
int
|
Frames per second in Hz. |
recording_duration |
float
|
Video duration in seconds. |
recording_time |
datetime
|
Time at the beginning of the recording. |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
key_source
property
¶
Limits the population of RecordingInfo to video recordings that have file paths ingested.
make(key)
¶
Populates the RecordingInfo table.
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
FacemapTask
¶
Bases: Manual
Staging table for pairing of recording and Facemap parameters before processing.
Attributes:
Name | Type | Description |
---|---|---|
VideoRecording |
foreign key
|
Primary key for VideoRecording table. |
facemap_task_id |
smallint
|
Facemap task ID |
facemap_output_dir |
str
|
output dir storing the results of Facemap analysis. |
task_mode |
enum
|
Default load. Load or trigger analysis. |
facemap_params |
longblob
|
content of facemap's _proc.npy as dict. |
do_mot_svd |
bool
|
Default True. Do motion singular value decomposition. |
do_mov_svd |
bool
|
Default False. Do movie singular value decomposition. |
task_description |
str
|
Task description. |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
FacemapProcessing
¶
Bases: Computed
Automated table to run Facemap with inputs from FacemapTask.
Attributes:
Name | Type | Description |
---|---|---|
FacemapTask |
foreign key
|
Primary key from FacemapTask. |
processing_time |
datetime
|
Time of generation of the facemap results. |
package_version |
str
|
Facemap package version. |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
key_source
property
¶
Limits the population of FacemapProcessing to those that have VideoRecording.File defined.
make(key)
¶
Runs Facemap
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
FacialSignal
¶
Bases: Imported
Results of the Facemap analysis.
Attributes:
Name | Type | Description |
---|---|---|
FacemapProcessing |
foreign key)
|
Primary key for FacemapProcessing table. |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
Region
¶
Bases: Part
Region's properties.
Attributes:
Name | Type | Description |
---|---|---|
master |
foreign key
|
Primary key of the FacialSignal table. |
roi_no |
int
|
Region number. |
roi_name |
str
|
User-friendly name of the roi. |
xrange |
longblob
|
1d np.array - x pixel indices. |
yrange |
longblob
|
1d np.array - y pixel indices. |
xrange_bin |
longblob
|
1d np.array - binned x pixel indices. |
yrange_bin |
longblob
|
1d np.array - binned y pixel indices. |
motion |
longblob
|
1d np.array - absolute motion energies (nframes). |
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
MotionSVD
¶
Bases: Part
Components of the SVD from motion video.
Attributes:
Name | Type | Description |
---|---|---|
master.Region |
foreign key
|
Primary key from FacialSignal.Region. |
pc_no |
int
|
Principle component (PC) number. |
singular_value |
float
|
singular value corresponding to the PC. |
motmask |
longblob
|
PC (y, x). |
projection |
longblob
|
projections onto the principle component (nframes). |
Source code in element_facemap/facial_behavior_estimation.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 |
|
MovieSVD
¶
Bases: Part
Components of the SVD from movie video.
Attributes:
Name | Type | Description |
---|---|---|
master.Region |
foreign key
|
Primary key of the FacialSignal.Region table. |
pc_no |
int
|
principle component (PC) number. |
singular_value |
float
|
Singular value corresponding to the PC. |
movmask |
longblob
|
PC (y, x) |
projection |
longblob
|
Projections onto the principle component (nframes). |
Source code in element_facemap/facial_behavior_estimation.py
391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
Summary
¶
Bases: Part
Average frames for movie and motion videos.
Attributes:
Name | Type | Description |
---|---|---|
master |
foreign key
|
Primary key from FacialSignal. |
sbin |
int
|
Spatial bin size. |
avgframe |
longblob
|
2d np.array - average binned frame. |
avgmotion |
longblob
|
2d nd.array - average binned motion frame. |
Source code in element_facemap/facial_behavior_estimation.py
411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
make(key)
¶
Populates the FacialSignal table by transferring the results from default Facemap outputs to the database.
Source code in element_facemap/facial_behavior_estimation.py
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 |
|
get_loader_result(key, table)
¶
Retrieve the facemap analysis results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
dict
|
A primary key for an entry in the provided table. |
required |
table |
Table
|
DataJoint user table from which loaded results are retrieved (i.e. FacemapTask). |
required |
Returns:
Name | Type | Description |
---|---|---|
loaded_dataset |
array
|
The results of the facemap analysis. |
creation_time |
datetime
|
Date and time that the results files were created. |
Source code in element_facemap/facial_behavior_estimation.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
|