Reference
Recording data
AxonaTrial
Bases: TrialInterface
Source code in ephysiopy/io/recording.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 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 |
|
get_spike_times(tetrode=None, cluster=None, *args, **kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tetrode
|
int
|
|
None
|
cluster
|
int
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
spike_times |
ndarray
|
|
Source code in ephysiopy/io/recording.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
OpenEphysBase
Bases: TrialInterface
Source code in ephysiopy/io/recording.py
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 524 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 627 628 629 630 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 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 772 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 |
|
get_spike_times(tetrode=None, cluster=None, *args, **kwargs)
cached
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tetrode
|
int
|
|
None
|
cluster
|
int
|
|
None
|
Returns:
Name | Type | Description |
---|---|---|
spike_times |
ndarray
|
|
Source code in ephysiopy/io/recording.py
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 |
|
load_lfp(*args, **kwargs)
cached
Valid kwargs are: 'target_sample_rate' - int the sample rate to downsample to from the original
Source code in ephysiopy/io/recording.py
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 |
|
load_ttl(*args, **kwargs)
cached
Parameters:
Name | Type | Description | Default |
---|---|---|---|
StimControl_id
|
str
|
This is the string "StimControl [0-9][][0-9]" where the numbers are the node id in the openephys signal chain |
required |
TTL_channel_number
|
int
|
The integer value in the "states.npy" file that corresponds to the identity of the TTL input on the Digital I/O board on the openephys recording system. i.e. if there is input to BNC port 3 on the digital I/O board then values of 3 in the states.npy file are high TTL values on this input and -3 are low TTL values (I think) |
required |
Returns:
Name | Type | Description |
---|---|---|
bool
|
Nothing but sets some keys/values in a dict on 'self' |
|
bool
|
called ttl_data, namely: |
|
ttl_timestamps |
list
|
the times of high ttl pulses in ms |
stim_duration |
int
|
the duration of the ttl pulse in ms |
Source code in ephysiopy/io/recording.py
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 |
|
TrialInterface
Bases: FigureMaker
Defines a minimal and required set of methods for loading electrophysiology data recorded using Axona or OpenEphys (OpenEphysNWB is there but not used)
Source code in ephysiopy/io/recording.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 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 |
|
get_spike_times(cluster, tetrode, *args, **kwargs)
abstractmethod
Returns the times of an individual cluster
Source code in ephysiopy/io/recording.py
287 288 289 290 |
|
load_cluster_data(*args, **kwargs)
abstractmethod
Load the cluster data (Kilosort/ Axona cut/ whatever else
Source code in ephysiopy/io/recording.py
273 274 275 276 |
|
load_lfp(*args, **kwargs)
abstractmethod
Load the LFP data
Source code in ephysiopy/io/recording.py
248 249 250 251 |
|
load_neural_data(*args, **kwargs)
abstractmethod
Load the neural data
Source code in ephysiopy/io/recording.py
253 254 255 256 |
|
load_pos_data(ppm=300, jumpmax=100, *args, **kwargs)
abstractmethod
Load the position data
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pname
|
Path
|
Path to base directory containing pos data |
required |
ppm
|
int
|
pixels per metre |
300
|
jumpmax
|
int
|
max jump in pixels between positions, more than this and the position is interpolated over |
100
|
Source code in ephysiopy/io/recording.py
258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
|
load_settings(*args, **kwargs)
abstractmethod
Loads the format specific settings file
Source code in ephysiopy/io/recording.py
278 279 280 281 |
|
memmapBinaryFile(path2file, n_channels=384, **kwargs)
Returns a numpy memmap of the int16 data in the file path2file, if present
Source code in ephysiopy/io/recording.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
Plotting the results
FigureMaker
Bases: object
A mixin class for TrialInterface that deals solely with producing graphical output.
Source code in ephysiopy/visualise/plotting.py
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 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 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 524 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 627 628 629 630 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 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 772 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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 |
|
__init__()
Initializes the FigureMaker object.
Source code in ephysiopy/visualise/plotting.py
49 50 51 52 53 |
|
eb_map(cluster, channel, **kwargs)
Gets the ego-centric boundary map for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the ego-centric boundary map for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
|
eb_spikes(cluster, channel, **kwargs)
Gets the ego-centric boundary spikes for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the ego-centric boundary spikes for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 |
|
getSpikePosIndices(spk_times)
Returns the indices into the position data at which some spike times occurred.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. |
required |
Returns:
Type | Description |
---|---|
np.ndarray: The indices into the position data at which the spikes occurred. |
Source code in ephysiopy/visualise/plotting.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 |
|
hd_map(cluster, channel, **kwargs)
Gets the head direction map for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the head direction map for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|
initialise()
Initializes the FigureMaker object with data from PosCalcs.
Source code in ephysiopy/visualise/plotting.py
55 56 57 58 59 60 61 62 |
|
makeEgoCentricBoundaryMap(spk_times, ax=None, **kwargs)
Creates an ego-centric boundary map plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. |
required |
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 |
|
makeEgoCentricBoundarySpikePlot(spk_times, add_colour_wheel=False, ax=None, **kwargs)
Creates an ego-centric boundary spike plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. |
required |
add_colour_wheel
|
bool
|
Whether to add a colour wheel to the plot. Defaults to False. |
False
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 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 |
|
makeHDPlot(spk_times=None, ax=None, **kwargs)
Creates a head direction plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
The spike times in seconds. If None, no spikes are plotted. |
None
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 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 |
|
makePowerSpectrum(freqs, power, sm_power, band_max_power, freq_at_band_max_power, max_freq=50, theta_range=[6, 12], ax=None, **kwargs)
Plots the power spectrum. The parameters can be obtained from calcEEGPowerSpectrum() in the EEGCalcsGeneric class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
freqs
|
array
|
The frequencies. |
required |
power
|
array
|
The power values. |
required |
sm_power
|
array
|
The smoothed power values. |
required |
band_max_power
|
float
|
The maximum power in the band. |
required |
freq_at_band_max_power
|
float
|
The frequency at which the maximum power in the band occurs. |
required |
max_freq
|
int
|
The maximum frequency. Defaults to 50. |
50
|
theta_range
|
tuple
|
The theta range. Defaults to [6, 12]. |
[6, 12]
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 870 871 872 |
|
makeRaster(spk_times, dt=(-50, 100), prc_max=0.5, ax=None, ms_per_bin=1, sample_rate=30000.0, **kwargs)
Plots a raster plot for a specified tetrode/ cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
The spike times in samples. |
required |
dt
|
tuple
|
The window of time in ms to examine zeroed on the event of interest i.e. the first value will probably be negative as in the example. Defaults to (-50, 100). |
(-50, 100)
|
prc_max
|
float
|
The proportion of firing the cell has to 'lose' to count as silent; a float between 0 and 1. Defaults to 0.5. |
0.5
|
ax
|
axes
|
The axes to plot into. If not provided a new figure is created. Defaults to None. |
None
|
ms_per_bin
|
int
|
The number of milliseconds in each bin of the raster plot. Defaults to 1. |
1
|
sample_rate
|
float
|
The sample rate. Defaults to 3e4. |
30000.0
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 |
|
makeRateMap(spk_times, ax=None, **kwargs)
Creates a rate map plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. |
required |
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 |
|
makeSAC(spk_times=None, ax=None, **kwargs)
Creates a spatial autocorrelation plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
The spike times in seconds. If None, no spikes are plotted. |
None
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 |
|
makeSpeedVsHeadDirectionPlot(spk_times, ax=None, **kwargs)
Creates a speed versus head direction plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
The spike times in seconds. |
required |
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 772 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 |
|
makeSpeedVsRatePlot(spk_times, minSpeed=0.0, maxSpeed=40.0, sigma=3.0, ax=None, **kwargs)
Plots the instantaneous firing rate of a cell against running speed. Also outputs a couple of measures as with Kropff et al., 2015; the Pearsons correlation and the depth of modulation (dom).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
The spike times in seconds. |
required |
minSpeed
|
float
|
The minimum speed. Defaults to 0.0. |
0.0
|
maxSpeed
|
float
|
The maximum speed. Defaults to 40.0. |
40.0
|
sigma
|
float
|
The sigma value. Defaults to 3.0. |
3.0
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 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 |
|
makeSpikePathPlot(spk_times=None, ax=None, **kwargs)
Creates a spike path plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. If None, no spikes are plotted. |
None
|
ax
|
axes
|
The axes to plot on. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
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 |
|
makeSummaryPlot(spk_times)
Creates a summary plot with spike path, rate map, head direction plot, and spatial autocorrelation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
ndarray
|
The spike times in seconds. |
required |
Returns:
Type | Description |
---|---|
matplotlib.figure.Figure: The created figure. |
Source code in ephysiopy/visualise/plotting.py
286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
makeXCorr(spk_times, ax=None, **kwargs)
Returns an axis containing the autocorrelogram of the spike times provided over the range +/-500ms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spk_times
|
array
|
Spike times in seconds. |
required |
ax
|
axes
|
The axes to plot into. If None, new axes are created. |
None
|
**kwargs
|
Additional keyword arguments for the function. binsize (int, optional): The size of the bins in ms. Gets passed to SpikeCalcsGeneric.xcorr(). Defaults to 1. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
Source code in ephysiopy/visualise/plotting.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 |
|
plotSpectrogramByDepth(nchannels=384, nseconds=100, maxFreq=125, channels=[], frequencies=[], frequencyIncrement=1, **kwargs)
Plots a heat map spectrogram of the LFP for each channel. Line plots of power per frequency band and power on a subset of channels are also displayed to the right and above the main plot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nchannels
|
int
|
The number of channels on the probe. |
384
|
nseconds
|
int
|
How long in seconds from the start of the trial to do the spectrogram for (for speed). Default is 100. |
100
|
maxFreq
|
int
|
The maximum frequency in Hz to plot the spectrogram out to. Maximum is 1250. Default is 125. |
125
|
channels
|
list
|
The channels to plot separately on the top plot. |
[]
|
frequencies
|
list
|
The specific frequencies to examine across all channels. The mean from frequency: frequency+frequencyIncrement is calculated and plotted on the left hand side of the plot. |
[]
|
frequencyIncrement
|
int
|
The amount to add to each value of the frequencies list above. |
1
|
**kwargs
|
Additional keyword arguments for the function. Valid key value pairs: "saveas" - save the figure to this location, needs absolute path and filename. |
{}
|
Notes
Should also allow kwargs to specify exactly which channels and / or frequency bands to do the line plots for.
Source code in ephysiopy/visualise/plotting.py
1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 |
|
power_spectrum(**kwargs)
Gets the power spectrum.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
259 260 261 262 263 264 265 266 267 268 |
|
rate_map(cluster, channel, **kwargs)
Gets the rate map for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the rate map for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
|
sac(cluster, channel, **kwargs)
Gets the spatial autocorrelation for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the spatial autocorrelation for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
show_SAC(A, inDict, ax=None, **kwargs)
Displays the result of performing a spatial autocorrelation (SAC) on a grid cell.
Uses the dictionary containing measures of the grid cell SAC to make a pretty picture
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array
|
The spatial autocorrelogram. |
required |
inDict
|
dict
|
The dictionary calculated in getmeasures. |
required |
ax
|
axes
|
If given the plot will get drawn in these axes. Default None. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Returns:
Type | Description |
---|---|
axes
|
matplotlib.axes: The axes with the plot. |
See Also
ephysiopy.common.binning.RateMap.autoCorr2D() ephysiopy.common.ephys_generic.FieldCalcs.getMeaures()
Source code in ephysiopy/visualise/plotting.py
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 |
|
speed_v_hd(cluster, channel, **kwargs)
Gets the speed versus head direction plot for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the speed versus head direction plot for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
|
speed_v_rate(cluster, channel, **kwargs)
Gets the speed versus rate plot for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list
|
The cluster(s) to get the speed versus rate plot for. |
required |
channel
|
int
|
The channel number. |
required |
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
|
spike_path(cluster=None, channel=None, **kwargs)
Gets the spike path for the specified cluster(s) and channel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int | list | None
|
The cluster(s) to get the spike path for. |
None
|
channel
|
int | None
|
The channel number. |
None
|
**kwargs
|
Additional keyword arguments for the function. |
{}
|
Source code in ephysiopy/visualise/plotting.py
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
|
Binning up data
RateMap
Bases: object
Bins up positional data (xy, head direction etc) and produces rate maps of the relevant kind. This is a generic class meant to be independent of any particular recording format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xy
|
ndarray
|
The xy data, usually given as a 2 x n sample numpy array. |
None
|
hdir
|
ndarray
|
The head direction data, usually a 1 x n sample numpy array. |
None
|
speed
|
ndarray
|
Similar to hdir. |
None
|
pos_weights
|
ndarray
|
A 1D numpy array n samples long which is used to weight a particular position sample when binning data. For example, if there were 5 positions recorded and a cell spiked once in position 2 and 5 times in position 3 and nothing anywhere else then pos_weights looks like: [0 0 1 5 0] In the case of binning up position this will be an array of mostly 1's unless there are some positions you want excluded for some reason. |
None
|
ppm
|
int
|
Pixels per metre. Specifies how many camera pixels per metre so this, in combination with cmsPerBin, will determine how many bins there are in the rate map. Defaults to None. |
430
|
xyInCms
|
bool
|
Whether the positional data is in cms. Defaults to False. |
False
|
cmsPerBin
|
int
|
How many cms on a side each bin is in a rate map OR the number of degrees per bin in the case of directional binning. Defaults to 3. |
required |
smooth_sz
|
int
|
The width of the smoothing kernel for smoothing rate maps. Defaults to 5. |
5
|
Notes
There are several instance variables you can set, see below.
Source code in ephysiopy/common/binning.py
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 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 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 524 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 627 628 629 630 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 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 772 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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
|
nBins
property
writable
The number of bins for each dim
pos_weights
property
writable
The 'weights' used as an argument to np.histogram* for binning up position Mostly this is just an array of 1's equal to the length of the pos data, but usefully can be adjusted when masking data in the trial by
autoCorr2D(A, nodwell, tol=1e-10)
Performs a spatial autocorrelation on the array A
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
Either 2 or 3D. In the former it is simply the binned up ratemap where the two dimensions correspond to x and y. If 3D then the first two dimensions are x and y and the third (last dimension) is 'stack' of ratemaps |
required |
nodwell
|
array_like
|
A boolean array corresponding the bins in the ratemap that weren't visited. See Notes below. |
required |
tol
|
float
|
Values below this are set to zero to deal with v small values thrown up by the fft. Default 1e-10 |
1e-10
|
Returns:
Name | Type | Description |
---|---|---|
sac |
array_like
|
The spatial autocorrelation in the relevant dimensionality |
Notes
The nodwell input can usually be generated by:
nodwell = ~np.isfinite(A)
Source code in ephysiopy/common/binning.py
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 |
|
crossCorr2D(A, B, A_nodwell, B_nodwell, tol=1e-10)
Performs a spatial crosscorrelation between the arrays A and B
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A,
|
B (array_like
|
Either 2 or 3D. In the former it is simply the binned up ratemap where the two dimensions correspond to x and y. If 3D then the first two dimensions are x and y and the third (last dimension) is 'stack' of ratemaps |
required |
nodwell_A,
|
nodwell_B (array_like
|
A boolean array corresponding the bins in the ratemap that weren't visited. See Notes below. |
required |
tol
|
float
|
Values below this are set to zero to deal with v small values thrown up by the fft. Default 1e-10 |
1e-10
|
Returns:
Name | Type | Description |
---|---|---|
sac |
array_like
|
The spatial crosscorrelation in the relevant dimensionality |
Notes
The nodwell input can usually be generated by:
nodwell = ~np.isfinite(A)
Source code in ephysiopy/common/binning.py
768 769 770 771 772 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 |
|
doStackedCorrelations(spkW, times, splits, var2bin=VariableToBin.XY, maptype=MapType.RATE, **kwargs)
Returns a list of binned data where each item in the list is the result of running np.histogramdd on a spatial variable (xy, dir etc) and a temporal one at the same time. The idea is to split the spatial variable into two temporal halves based on the bin edges in 'splits' and then to run correlations between the two halves and furthermore to do this for all of the clusters that have spike weights in 'spkW'. 'spkW' should be the result of using getAllSpikeWeights().
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spkW
|
ndarray
|
The result of calling getAllSpikeWeights() |
required |
times
|
ndarray
|
Position times in seconds |
required |
splits
|
ndarray
|
Where to split the data in seconds. Will typically take the form (0, 100, 200) for example which will give a split between 0-100 and 100-200 seconds |
required |
var2bin
|
Enum
|
The spatial variable to bin up |
XY
|
maptype
|
Enum
|
The type of map to produce |
RATE
|
Source code in ephysiopy/common/binning.py
1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
|
getAdaptiveMap(pos_binned, spk_binned, alpha=200)
Produces a ratemap that has been adaptively binned according to the algorithm described in Skaggs et al., 1996) [1]_.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pos_binned
|
array_like
|
The binned positional data. For example that returned from getMap above with mapType as 'pos' |
required |
spk_binned
|
array_like
|
The binned spikes |
required |
alpha
|
int
|
A scaling parameter determing the amount of occupancy to aim at in each bin. Defaults to 200. |
200
|
Returns:
Type | Description |
---|---|
Returns adaptively binned spike and pos maps. Use to generate Skaggs |
|
information measure |
Notes
Positions with high rates mean proportionately less error than those with low rates, so this tries to even the playing field. This type of binning should be used for calculations of spatial info as with the skaggs_info method in the fieldcalcs class (see below) alpha is a scaling parameter that might need tweaking for different data sets. From the paper: The data [are] first binned into a 64 X 64 grid of spatial locations, and then the firing rate at each point in this grid was calculated by expanding a circle around the point until the following criterion was met: Nspks > alpha / (Nocc^2 * r^2) where Nspks is the number of spikes emitted in a circle of radius r (in bins), Nocc is the number of occupancy samples, alpha is the scaling parameter The firing rate in the given bin is then calculated as: sample_rate * (Nspks / Nocc)
References
.. [1] W. E. Skaggs, B. L. McNaughton, K. M. Gothard & E. J. Markus "An Information-Theoretic Approach to Deciphering the Hippocampal Code" Neural Information Processing Systems, 1993.
Source code in ephysiopy/common/binning.py
613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 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 |
|
getAllSpikeWeights(spike_times, spike_clusters, pos_times, **kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spike_times
|
ndarray
|
Spike times in seconds |
required |
spike_clusters
|
ndarray
|
Cluster identity vector |
required |
pos_times
|
ndarray
|
The times at which position was captured in seconds |
required |
Returns:
Type | Description |
---|---|
np.ndarray: The bincounts with respect to position for each cluster. Shape of returned array will be nClusters x npos |
Source code in ephysiopy/common/binning.py
1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 |
|
getMap(spkWeights, varType=VariableToBin.XY, mapType=MapType.RATE, smoothing=True, **kwargs)
Bins up the variable type varType and returns a tuple of (rmap, binnedPositionDir) or (rmap, binnedPostionX, binnedPositionY)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spkWeights
|
array_like
|
Shape equal to number of positions samples captured and consists of position weights. For example, if there were 5 positions recorded and a cell spiked once in position 2 and 5 times in position 3 and nothing anywhere else then pos_weights looks like: [0 0 1 5 0] |
required |
varType
|
Enum value - see Variable2Bin defined at top of this file
|
The variable to bin up. Legal values are: XY, DIR and SPEED |
XY
|
mapType
|
enum value - see MapType defined at top of this file
|
If RATE then the binned up spikes are divided by varType. Otherwise return binned up position. Options are RATE or POS |
RATE
|
smoothing
|
bool
|
Whether to smooth the data or not. Defaults to True. |
True
|
Returns:
Type | Description |
---|---|
binned_data, binned_pos (tuple): This is either a 2-tuple or a 3-tuple depening on whether binned pos (mapType 'pos') or binned spikes (mapType 'rate') is asked for respectively |
Source code in ephysiopy/common/binning.py
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 |
|
getSAC(spkWeights, **kwargs)
Returns the SAC - convenience function
Source code in ephysiopy/common/binning.py
487 488 489 490 491 492 493 |
|
getSpatialSparsity(spkWeights, sample_rate=50, **kwargs)
Gets the spatial sparsity measure - closer to 1 means sparser firing field.
References
Skaggs, W.E., McNaughton, B.L., Wilson, M.A. & Barnes, C.A. Theta phase precession in hippocampal neuronal populations and the compression of temporal sequences. Hippocampus 6, 149–172 (1996).
Source code in ephysiopy/common/binning.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 |
|
get_egocentric_boundary_map(spk_weights, degs_per_bin=3, xy_binsize=2.5, arena_type='circle', return_dists=False, return_raw_spk=False, return_raw_occ=False)
Helps construct dwell time/spike counts maps with respect to boundaries at given egocentric directions and distances.
Note
For the directional input, the 0 degree reference is horizontal pointing East and moves counter-clockwise.
Source code in ephysiopy/common/binning.py
1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
|
tWinSAC(xy, spkIdx, ppm=365, winSize=10, pos_sample_rate=50, nbins=71, boxcar=5, Pthresh=100, downsampfreq=50, plot=False)
Temporal windowed spatial autocorrelation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
xy
|
array_like
|
The position data |
required |
spkIdx
|
array_like
|
The indices in xy where the cell fired |
required |
ppm
|
int
|
The camera pixels per metre. Default 365 |
365
|
winSize
|
int
|
The window size for the temporal search |
10
|
pos_sample_rate
|
int
|
The rate at which position was sampled. Default 50 |
50
|
nbins
|
int
|
The number of bins for creating the resulting ratemap. Default 71 |
71
|
boxcar
|
int
|
The size of the smoothing kernel to smooth ratemaps. Default 5 |
5
|
Pthresh
|
int
|
The cut-off for values in the ratemap; values < Pthresh become nans. Default 100 |
100
|
downsampfreq
|
int
|
How much to downsample. Default 50 |
50
|
plot
|
bool
|
Whether to show a plot of the result. Default False |
False
|
Returns:
Name | Type | Description |
---|---|---|
H |
array_like
|
The temporal windowed SAC |
Source code in ephysiopy/common/binning.py
869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 |
|
Field calculations
border_score(A, B=None, shape='square', fieldThresh=0.3, smthKernSig=3, circumPrc=0.2, binSize=3.0, minArea=200, debug=False)
Calculates a border score totally dis-similar to that calculated in Solstad et al (2008)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
Should be the ratemap |
required |
B
|
array_like
|
This should be a boolean mask where True (1) is equivalent to the presence of a border and False (0) is equivalent to 'open space'. Naievely this will be the edges of the ratemap but could be used to take account of boundary insertions/ creations to check tuning to multiple environmental boundaries. Default None: when the mask is None then a mask is created that has 1's at the edges of the ratemap i.e. it is assumed that occupancy = environmental shape |
None
|
shape
|
str
|
description of environment shape. Currently only 'square' or 'circle' accepted. Used to calculate the proportion of the environmental boundaries to examine for firing |
'square'
|
fieldThresh
|
float
|
Between 0 and 1 this is the percentage amount of the maximum firing rate to remove from the ratemap (i.e. to remove noise) |
0.3
|
smthKernSig
|
float
|
the sigma value used in smoothing the ratemap (again!) with a gaussian kernel |
3
|
circumPrc
|
float
|
The percentage amount of the circumference of the environment that the field needs to be to count as long enough to make it through |
0.2
|
binSize
|
float
|
bin size in cm |
3.0
|
minArea
|
float
|
min area for a field to be considered |
200
|
debug
|
bool
|
If True then some plots and text will be output |
False
|
Returns:
Name | Type | Description |
---|---|---|
float |
the border score |
Notes
If the cell is a border cell (BVC) then we know that it should fire at a fixed distance from a given boundary (possibly more than one). In essence this algorithm estimates the amount of variance in this distance i.e. if the cell is a border cell this number should be small. This is achieved by first doing a bunch of morphological operations to isolate individual fields in the ratemap (similar to the code used in phasePrecession.py - see the partitionFields method therein). These partitioned fields are then thinned out (using skimage's skeletonize) to a single pixel wide field which will lie more or less in the middle of the (highly smoothed) sub-field. It is the variance in distance from the nearest boundary along this pseudo-iso-line that is the boundary measure
Other things to note are that the pixel-wide field has to have some minimum length. In the case of a circular environment this is set to 20% of the circumference; in the case of a square environment markers this is at least half the length of the longest side
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
calc_angs(points)
Calculates the angles for all triangles in a delaunay tesselation of the peak points in the ratemap
Source code in ephysiopy/common/fieldcalcs.py
526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
|
coherence(smthd_rate, unsmthd_rate)
calculates coherence of receptive field via correlation of smoothed and unsmoothed ratemaps
Source code in ephysiopy/common/fieldcalcs.py
567 568 569 570 571 572 573 574 575 576 577 |
|
corr_maps(map1, map2, maptype='normal')
correlates two ratemaps together ignoring areas that have zero sampling
Source code in ephysiopy/common/fieldcalcs.py
546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
|
deform_SAC(A, circleXY=None, ellipseXY=None)
Deforms a SAC that is non-circular to be more circular
Basically a blatant attempt to improve grid scores, possibly introduced in a paper by Matt Nolan...
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
The SAC |
required |
circleXY
|
array_like
|
The xy coordinates defining a circle. |
None
|
ellipseXY
|
array_like
|
The xy coordinates defining an |
None
|
Returns:
Name | Type | Description |
---|---|---|
deformed_sac |
array_like
|
The SAC deformed to be more circular |
See Also
ephysiopy.common.ephys_generic.FieldCalcs.grid_field_props skimage.transform.AffineTransform skimage.transform.warp skimage.exposure.rescale_intensity
Source code in ephysiopy/common/fieldcalcs.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
|
field_lims(A)
Returns a labelled matrix of the ratemap A. Uses anything greater than the half peak rate to select as a field. Data is heavily smoothed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array
|
The ratemap |
required |
Returns:
Name | Type | Description |
---|---|---|
label |
array
|
The labelled ratemap |
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
field_props(A, min_dist=5, neighbours=2, prc=50, plot=False, ax=None, tri=False, verbose=True, **kwargs)
Returns a dictionary of properties of the field(s) in a ratemap A
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
a ratemap (but could be any image) |
required |
min_dist
|
float
|
the separation (in bins) between fields for measures such as field distance to make sense. Used to partition the image into separate fields in the call to feature.peak_local_max |
5
|
neighbours
|
int
|
the number of fields to consider as neighbours to any given field. Defaults to 2 |
2
|
prc
|
float
|
percent of fields to consider |
50
|
ax
|
Axes
|
user supplied axis. If None a new figure window |
None
|
tri
|
bool
|
whether to do Delaunay triangulation between fields and add to plot |
False
|
verbose
|
bool
|
dumps the properties to the console |
True
|
plot
|
bool
|
whether to plot some output - currently consists of the ratemap A, the fields of which are outline in a black contour. Default False |
False
|
Returns:
Name | Type | Description |
---|---|---|
result |
dict
|
The properties of the field(s) in the input ratemap A |
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
get_circular_regions(A, **kwargs)
Returns a list of images which are expanding circular regions centred on the middle of the image out to the image edge. Used for calculating the grid score of each image to find the one with the max grid score. Based on some Moser paper I can't recall.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
ndarray
|
The SAC |
required |
Other Parameters:
Name | Type | Description |
---|---|---|
min_radius |
int
|
The smallest radius circle to start with |
Source code in ephysiopy/common/fieldcalcs.py
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 |
|
global_threshold(A, prc=50, min_dist=5)
Globally thresholds a ratemap and counts number of fields found
Source code in ephysiopy/common/fieldcalcs.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
|
grid_field_props(A, maxima='centroid', allProps=True, **kwargs)
Extracts various measures from a spatial autocorrelogram
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
The spatial autocorrelogram (SAC) |
required |
maxima
|
str
|
The method used to detect the peaks in the SAC. Legal values are 'single' and 'centroid'. Default 'centroid' |
'centroid'
|
allProps
|
bool
|
Whether to return a dictionary that |
True
|
Returns:
Name | Type | Description |
---|---|---|
props |
dict
|
A dictionary containing measures of the SAC. |
Keys include: * gridness score * scale * orientation * coordinates of the peaks (nominally 6) closest to SAC centre * a binary mask around the extent of the 6 central fields * values of the rotation procedure used to calculate gridness * ellipse axes and angle (if allProps is True and the it worked) |
Notes
The output from this method can be used as input to the show() method of this class. When it is the plot produced will display a lot more informative.
See Also
ephysiopy.common.binning.autoCorr2D()
Source code in ephysiopy/common/fieldcalcs.py
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 772 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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 |
|
grid_orientation(peakCoords, closestPeakIdx)
Calculates the orientation angle of a grid field.
The orientation angle is the angle of the first peak working counter-clockwise from 3 o'clock
Parameters:
Name | Type | Description | Default |
---|---|---|---|
peakCoords
|
array_like
|
The peak coordinates as pairs of xy |
required |
closestPeakIdx
|
array_like
|
A 1D array of the indices in peakCoords |
required |
Returns:
Name | Type | Description |
---|---|---|
peak_orientation |
float
|
The first value in an array of the angles of |
the peaks in the SAC working counter-clockwise from a line |
||
extending from the middle of the SAC to 3 o'clock. |
Source code in ephysiopy/common/fieldcalcs.py
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
|
gridness(image, step=30)
Calculates the gridness score in a grid cell SAC.
Briefly, the data in image
is rotated in step
amounts and
each rotated array is correlated with the original.
The maximum of the values at 30, 90 and 150 degrees
is the subtracted from the minimum of the values at 60, 120
and 180 degrees to give the grid score.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image
|
array_like
|
The spatial autocorrelogram |
required |
step
|
int
|
The amount to rotate the SAC in each step of the |
30
|
Returns:
Name | Type | Description |
---|---|---|
gridmeasures |
3 - tuple
|
The gridscore, the correlation values at each |
|
Notes
The correlation performed is a Pearsons R. Some rescaling of the
values in image
is performed following rotation.
See Also
skimage.transform.rotate : for how the rotation of image
is done
skimage.exposure.rescale_intensity : for the resscaling following
rotation
Source code in ephysiopy/common/fieldcalcs.py
941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
|
kldiv(X, pvect1, pvect2, variant=None)
Calculates the Kullback-Leibler or Jensen-Shannon divergence between two distributions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
X
|
array_like
|
Vector of M variable values |
required |
P1
|
array_like
|
Length-M vector of probabilities representing |
required |
P2
|
array_like
|
Length-M vector of probabilities representing |
required |
sym
|
str
|
If 'sym', returns a symmetric variant of the Kullback-Leibler divergence, given by [KL(P1,P2)+KL(P2,P1)]/2 |
required |
js
|
str
|
If 'js', returns the Jensen-Shannon divergence, |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
The Kullback-Leibler divergence or Jensen-Shannon divergence |
Notes
The Kullback-Leibler divergence is given by:
.. math:: KL(P1(x),P2(x)) = sum_[P1(x).log(P1(x)/P2(x))]
If X contains duplicate values, there will be an warning message, and these values will be treated as distinct values. (I.e., the actual values do not enter into the computation, but the probabilities for the two duplicate values will be considered as probabilities corresponding to two unique values.). The elements of probability vectors P1 and P2 must each sum to 1 +/- .00001.
This function is taken from one on the Mathworks file exchange
See Also
Cover, T.M. and J.A. Thomas. "Elements of Information Theory," Wiley, 1991.
https://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergence
Source code in ephysiopy/common/fieldcalcs.py
610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 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 |
|
kldiv_dir(polarPlot)
Returns a kl divergence for directional firing: measure of directionality. Calculates kl diveregence between a smoothed ratemap (probably should be smoothed otherwise information theoretic measures don't 'care' about position of bins relative to one another) and a pure circular distribution. The larger the divergence the more tendancy the cell has to fire when the animal faces a specific direction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
polarPlot
|
1D-array
|
The binned and smoothed directional ratemap |
required |
Returns:
Name | Type | Description |
---|---|---|
klDivergence |
float
|
The divergence from circular of the 1D-array |
from a uniform circular distribution |
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
limit_to_one(A, prc=50, min_dist=5)
Processes a multi-peaked ratemap (ie grid cell) and returns a matrix where the multi-peaked ratemap consist of a single peaked field that is a) not connected to the border and b) close to the middle of the ratemap
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
local_threshold(A, prc=50, min_dist=5)
Locally thresholds a ratemap to take only the surrounding prc amount around any local peak
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
skaggs_info(ratemap, dwelltimes, **kwargs)
Calculates Skaggs information measure
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ratemap
|
array_like
|
The binned up ratemap |
required |
dwelltimes
|
array_like
|
Must be same size as ratemap |
required |
Returns:
Name | Type | Description |
---|---|---|
bits_per_spike |
float
|
Skaggs information score |
Notes
THIS DATA SHOULD UNDERGO ADAPTIVE BINNING See getAdaptiveMap() in binning class
Returns Skaggs et al's estimate of spatial information in bits per spike:
.. math:: I = sum_{x} p(x).r(x).log(r(x)/r)
Source code in ephysiopy/common/fieldcalcs.py
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 |
|
Grid cells
SAC
Bases: object
Spatial AutoCorrelation (SAC) class
Source code in ephysiopy/common/gridcell.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 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 |
|
getMeasures(A, maxima='centroid', allProps=True, **kwargs)
Extracts various measures from a spatial autocorrelogram
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
The spatial autocorrelogram (SAC) |
required |
maxima
|
str
|
The method used to detect the peaks in the |
'centroid'
|
field_extent_method
|
int
|
The method used to delimit |
required |
allProps
|
bool
|
Whether to return a dictionary that |
True
|
Returns:
Name | Type | Description |
---|---|---|
props |
dict
|
A dictionary containing measures of the SAC. |
Keys include: * gridness score * scale * orientation * the coordinates of the peaks closest to SAC centre * a binary mask that defines the extent of the 6 central fields * values of the rotation procedure used to calculate gridness * ellipse axes and angle (if allProps is True and it worked) |
Notes
In order to maintain backward compatibility this is a wrapper for ephysiopy.common.ephys_generic.FieldCalcs.grid_field_props()
See Also
ephysiopy.common.ephys_generic.FieldCalcs.grid_field_props()
Source code in ephysiopy/common/gridcell.py
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 |
|
get_basic_gridscore(A, step=30, **kwargs)
Rotates the image A in step amounts, correlated each rotated image with the original. The maximum of the values at 30, 90 and 150 degrees is the subtracted from the minimum of the values at 60, 120 and 180 degrees to give the grid score.
Source code in ephysiopy/common/gridcell.py
52 53 54 55 56 57 58 59 60 |
|
get_deformed_sac_gridscore(A, **kwargs)
Deforms a non-circular SAC into a circular SAC (circular meaning the ellipse drawn around the edges of the 6 nearest peaks to the SAC centre) and returns get_basic_griscore() calculated on the deformed (or re-formed?!) SAC
Source code in ephysiopy/common/gridcell.py
75 76 77 78 79 80 81 82 83 84 |
|
get_expanding_circle_gridscore(A, **kwargs)
Calculates the gridscore for each circular sub-region of image A where the circles are centred on the image centre and expanded to the edge of the image. The maximum of the get_basic_gridscore() for each of these circular sub-regions is returned as the gridscore
Source code in ephysiopy/common/gridcell.py
62 63 64 65 66 67 68 69 70 71 72 73 |
|
show(A, inDict, ax=None, **kwargs)
Displays the result of performing a spatial autocorrelation (SAC) on a grid cell.
Uses the dictionary containing measures of the grid cell SAC to make a pretty picture
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
array_like
|
The spatial autocorrelogram |
required |
inDict
|
dict
|
The dictionary calculated in getmeasures |
required |
Returns:
Name | Type | Description |
---|---|---|
fig |
matplotlib.Figure instance
|
The Figure on which the SAC is |
shown |
See Also
ephysiopy.common.binning.RateMap.autoCorr2D() ephysiopy.common.ephys_generic.FieldCalcs.getMeaures()
Source code in ephysiopy/common/gridcell.py
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 |
|
Phase coding
phasePrecession2D
Bases: object
Performs phase precession analysis for single unit data
Mostly a total rip-off of code written by Ali Jeewajee for his paper on 2D phase precession in place and grid cells [1]_
.. [1] Jeewajee A, Barry C, Douchamps V, Manson D, Lever C, Burgess N. Theta phase precession of grid and place cell firing in open environments. Philos Trans R Soc Lond B Biol Sci. 2013 Dec 23;369(1635):20120532. doi: 10.1098/rstb.2012.0532.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lfp_sig
|
array
|
The LFP signal against which cells might precess... |
required |
lfp_fs
|
int
|
The sampling frequency of the LFP signal |
required |
xy
|
array
|
The position data as 2 x num_position_samples |
required |
spike_ts
|
array
|
The times in samples at which the cell fired |
required |
pos_ts
|
array
|
The times in samples at which position was captured |
required |
pp_config
|
dict
|
Contains parameters for running the analysis. See phase_precession_config dict in ephysiopy.common.eegcalcs |
phase_precession_config
|
Source code in ephysiopy/common/phasecoding.py
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 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 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 524 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 627 628 629 630 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 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 772 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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
|
getPosProps(labels, peaksXY, laserEvents=None, plot=False, **kwargs)
Uses the output of partitionFields and returns vectors the same length as pos.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tetrode,
|
cluster (int
|
The tetrode / cluster to examine |
required |
peaksXY
|
array_like
|
The x-y coords of the peaks in the ratemap |
required |
laserEvents
|
array_like
|
The position indices of on events |
None
|
Returns:
Type | Description |
---|---|
pos_dict, run_dict (dict): Contains a whole bunch of information |
|
for the whole trial and also on a run-by-run basis (run_dict). |
|
See the end of this function for all the key / value pairs. |
Source code in ephysiopy/common/phasecoding.py
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 524 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 627 628 629 630 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 |
|
partitionFields(ftype='g', plot=False, **kwargs)
Partitions fields.
Partitions spikes into fields by finding the watersheds around the peaks of a super-smoothed ratemap
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spike_ts
|
array
|
The ratemap to partition |
required |
ftype
|
str
|
'p' or 'g' denoting place or grid cells - not implemented yet |
'g'
|
plot
|
bool
|
Whether to produce a debugging plot or not |
False
|
Returns:
Name | Type | Description |
---|---|---|
peaksXY |
array_like
|
The xy coordinates of the peak rates in |
each field |
||
peaksRate |
array_like
|
The peak rates in peaksXY |
labels |
ndarray
|
An array of the labels corresponding to |
each field (starting at 1) |
||
rmap |
ndarray
|
The ratemap of the tetrode / cluster |
Source code in ephysiopy/common/phasecoding.py
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 |
|
performRegression(laserEvents=None, **kwargs)
Wrapper function for doing the actual regression which has multiple stages.
Specifically here we partition fields into sub-fields, get a bunch of information about the position, spiking and theta data and then do the actual regression.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tetrode
|
int
|
The tetrode to examine |
required |
cluster
|
int
|
The cluster to examine |
required |
laserEvents
|
array_like
|
The on times for laser events |
None
|
See Also
ephysiopy.common.eegcalcs.phasePrecession.partitionFields() ephysiopy.common.eegcalcs.phasePrecession.getPosProps() ephysiopy.common.eegcalcs.phasePrecession.getThetaProps() ephysiopy.common.eegcalcs.phasePrecession.getSpikeProps() ephysiopy.common.eegcalcs.phasePrecession._ppRegress()
Source code in ephysiopy/common/phasecoding.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 |
|
applyFilter2Labels(M, x)
M is a logical mask specifying which label numbers to keep x is an array of positive integer labels
This method sets the undesired labels to 0 and renumbers the remaining labels 1 to n when n is the number of trues in M
Source code in ephysiopy/common/phasecoding.py
987 988 989 990 991 992 993 994 995 996 997 |
|
ccc(t, p)
Calculates correlation between two random circular variables
Source code in ephysiopy/common/phasecoding.py
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
|
ccc_jack(t, p)
Function used to calculate jackknife estimates of correlation
Source code in ephysiopy/common/phasecoding.py
1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 |
|
circCircCorrTLinear(theta, phi, k=1000, alpha=0.05, hyp=0, conf=True)
An almost direct copy from AJs Matlab fcn to perform correlation between 2 circular random variables.
Returns the correlation value (rho), p-value, bootstrapped correlation values, shuffled p values and correlation values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta,
|
phi (array_like
|
mx1 array containing circular data (radians) whose correlation is to be measured |
required |
k
|
int
|
number of permutations to use to calculate p-value from randomisation and bootstrap estimation of confidence intervals. Leave empty to calculate p-value analytically (NB confidence intervals will not be calculated). Default is 1000. |
1000
|
alpha
|
float
|
hypothesis test level e.g. 0.05, 0.01 etc. Default is 0.05. |
0.05
|
hyp
|
int
|
hypothesis to test; -1/ 0 / 1 (-ve correlated / correlated in either direction / positively correlated). Default is 0. |
0
|
conf
|
bool
|
True or False to calculate confidence intervals via jackknife or bootstrap. Default is True. |
True
|
References
Fisher (1993), Statistical Analysis of Circular Data, Cambridge University Press, ISBN: 0 521 56890 0
Source code in ephysiopy/common/phasecoding.py
1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 |
|
circRegress(x, t)
Finds approximation to circular-linear regression for phase precession.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
list
|
n-by-1 list of in-field positions (linear variable) |
required |
t
|
list
|
n-by-1 list of phases, in degrees (converted to radians) |
required |
Note
Neither x nor t can contain NaNs, must be paired (of equal length).
Source code in ephysiopy/common/phasecoding.py
1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 |
|
fixAngle(a)
Ensure angles lie between -pi and pi a must be in radians
Source code in ephysiopy/common/phasecoding.py
1047 1048 1049 1050 1051 1052 1053 |
|
shuffledPVal(theta, phi, rho, k, hyp)
Calculates shuffled p-values for correlation
Source code in ephysiopy/common/phasecoding.py
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 |
|
Rhymicity
CosineDirectionalTuning
Bases: object
Produces output to do with Welday et al (2011) like analysis of rhythmic firing a la oscialltory interference model
Source code in ephysiopy/common/rhythmicity.py
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 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 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 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 |
|
spk_clusters = self.spk_clusters[idx_to_keep]
instance-attribute
There can be more spikes than pos samples in terms of sampling as the open-ephys buffer probably needs to finish writing and the camera has already stopped, so cut of any cluster indices and spike times that exceed the length of the pos indices
__init__(spike_times, pos_times, spk_clusters, x, y, tracker_params={})
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spike_times
|
1d np.array
|
Spike times |
required |
pos_times
|
1d np.array
|
Position times |
required |
spk_clusters
|
1d np.array
|
Spike clusters |
required |
x
|
and y (1d np.array
|
Position coordinates |
required |
tracker_params
|
dict
|
From the PosTracker as created in OESettings.Settings.parse |
{}
|
Note
All timestamps should be given in sub-millisecond accurate seconds and pos_xy in cms
Source code in ephysiopy/common/rhythmicity.py
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 71 72 73 74 |
|
getDirectionalBinPerPosition(binwidth)
Direction is in degrees as that what is created by me in some of the other bits of this package.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
binwidth
|
int
|
The bin width in degrees |
required |
Returns:
Type | Description |
---|---|
A digitization of which directional bin each pos sample belongs to |
Source code in ephysiopy/common/rhythmicity.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
getRunsOfMinLength()
Identifies runs of at least self.min_runlength seconds long, which at 30Hz pos sampling rate equals 12 samples, and returns the start and end indices at which the run was occurred and the directional bin that run belongs to
Returns:
Type | Description |
---|---|
np.array: The start and end indices into pos samples of the run and the directional bin to which it belongs |
Source code in ephysiopy/common/rhythmicity.py
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 |
|
intrinsic_freq_autoCorr(spkTimes=None, posMask=None, maxFreq=25, acBinSize=0.002, acWindow=0.5, plot=True, **kwargs)
This is taken and adapted from ephysiopy.common.eegcalcs.EEGCalcs
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spkTimes
|
array
|
Times in seconds of the cells firing |
None
|
posMask
|
array
|
Boolean array corresponding to the length of spkTimes where True is stuff to keep |
None
|
maxFreq
|
float
|
The maximum frequency to do the power spectrum out to |
25
|
acBinSize
|
float
|
The bin size of the autocorrelogram in seconds |
0.002
|
acWindow
|
float
|
The range of the autocorr in seconds |
0.5
|
Note
Make sure all times are in seconds
Source code in ephysiopy/common/rhythmicity.py
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 394 395 396 397 398 399 400 |
|
power_spectrum(eeg, plot=True, binWidthSecs=None, maxFreq=25, pad2pow=None, ymax=None, **kwargs)
Method used by eeg_power_spectra and intrinsic_freq_autoCorr Signal in must be mean normalised already
Source code in ephysiopy/common/rhythmicity.py
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 |
|
speedFilterRuns(runs, minspeed=5.0)
Given the runs identified in getRunsOfMinLength, filter for speed and return runs that meet the min speed criteria.
The function goes over the runs with a moving window of length equal to self.min_runlength in samples and sees if any of those segments meet the speed criteria and splits them out into separate runs if true.
NB For now this means the same spikes might get included in the autocorrelation procedure later as the moving window will use overlapping periods - can be modified later.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
runs
|
3 x nRuns np.array
|
Generated from getRunsOfMinLength |
required |
minspeed
|
float
|
Min running speed in cm/s for an epoch (minimum epoch length defined previously in getRunsOfMinLength as minlength, usually 0.4s) |
5.0
|
Returns:
Type | Description |
---|---|
3 x nRuns np.array: A modified version of the "runs" input variable |
Source code in ephysiopy/common/rhythmicity.py
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 |
|
LFPOscillations
Bases: object
Does stuff with the LFP such as looking at nested oscillations (theta/ gamma coupling), the modulation index of such phenomena, filtering out certain frequencies in the LFP, getting the instantaneous phase and amplitude and so on
Source code in ephysiopy/common/rhythmicity.py
514 515 516 517 518 519 520 521 522 523 524 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 627 628 629 630 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 706 707 708 709 710 711 712 713 714 |
|
filterForLaser(sig=None, width=0.125, dip=15.0, stimFreq=6.66)
Attempts to filter out frequencies from optogenetic experiments where the frequency of laser stimulation was at 6.66Hz.
Note
This method may not work as expected for each trial and might require tailoring. A potential improvement could be using mean power or a similar metric.
Source code in ephysiopy/common/rhythmicity.py
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 |
|
getFreqPhase(sig, band2filter, ford=3)
Uses the Hilbert transform to calculate the instantaneous phase and amplitude of the time series in sig.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sig
|
array
|
The signal to be analysed |
required |
ford
|
int
|
The order for the Butterworth filter |
3
|
band2filter
|
list
|
The two frequencies to be filtered for |
required |
Source code in ephysiopy/common/rhythmicity.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
|
modulationindex(sig=None, nbins=20, forder=2, thetaband=[4, 8], gammaband=[30, 80], plot=True)
Calculates the modulation index of theta and gamma oscillations. Specifically this is the circular correlation between the phase of theta and the power of theta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
sig
|
array
|
The LFP signal |
None
|
nbins
|
int
|
The number of bins in the circular range 0 to 2*pi |
20
|
forder
|
int
|
The order of the butterworth filter |
2
|
thetaband
|
list
|
The lower/upper bands of the theta freq range |
[4, 8]
|
gammaband
|
list
|
The lower/upper bands of the gamma freq range |
[30, 80]
|
plot
|
bool
|
Show some pics or not |
True
|
Source code in ephysiopy/common/rhythmicity.py
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 |
|
plv(sig=None, forder=2, thetaband=[4, 8], gammaband=[30, 80], plot=True, **kwargs)
Computes the phase-amplitude coupling (PAC) of nested oscillations. More specifically this is the phase-locking value (PLV) between two nested oscillations in EEG data, in this case theta (default 4-8Hz) and gamma (defaults to 30-80Hz). A PLV of unity indicates perfect phase locking (here PAC) and a value of zero indicates no locking (no PAC)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eeg
|
numpy array
|
The eeg data itself. This is a 1-d array which |
required |
forder
|
int
|
The order of the filter(s) applied to the eeg data |
2
|
thetaband,
|
gammaband (list/array
|
The range of values to bandpass |
required |
plot
|
bool
|
Whether to plot the resulting binned up |
True
|
Returns:
Name | Type | Description |
---|---|---|
plv |
float
|
The value of the phase-amplitude coupling |
Source code in ephysiopy/common/rhythmicity.py
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 630 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 |
|
spike_phase_plot(cluster, pos_data, KSdata, lfp_data)
Produces a plot of the phase of theta at which each spike was emitted. Each spike is plotted according to the x-y location the animal was in when it was fired and the colour of the marker corresponds to the phase of theta at which it fired.
Source code in ephysiopy/common/rhythmicity.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 |
|
Spike calculations
SpikeCalcsAxona
Bases: SpikeCalcsGeneric
Replaces SpikeCalcs from ephysiopy.axona.spikecalcs
Source code in ephysiopy/common/spikecalcs.py
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
|
half_amp_dur(waveforms)
Calculates the half amplitude duration of a spike.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
A
|
ndarray
|
An nSpikes x nElectrodes x nSamples array. |
required |
Returns:
Name | Type | Description |
---|---|---|
had |
float
|
The half-amplitude duration for the channel (electrode) that has the strongest (highest amplitude) signal. Units are ms. |
Source code in ephysiopy/common/spikecalcs.py
958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 |
|
p2t_time(waveforms)
The peak to trough time of a spike in ms
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int
|
The cluster whose waveforms are to be analysed |
required |
Returns:
Name | Type | Description |
---|---|---|
p2t |
float
|
The mean peak-to-trough time for the channel (electrode) that has the strongest (highest amplitude) signal. Units are ms. |
Source code in ephysiopy/common/spikecalcs.py
1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 |
|
plotClusterSpace(waveforms, param='Amp', clusts=None, bins=256, **kwargs)
Assumes the waveform data is signed 8-bit ints TODO: aspect of plot boxes in ImageGrid not right as scaled by range of values now
Source code in ephysiopy/common/spikecalcs.py
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
|
SpikeCalcsGeneric
Bases: object
Deals with the processing and analysis of spike data. There should be one instance of this class per cluster in the recording session. NB this differs from previous versions of this class where there was one instance per recording session and clusters were selected by passing in the cluster id to the methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spike_times
|
array_like
|
The times of spikes in the trial in seconds |
required |
waveforms
|
array
|
An nSpikes x nChannels x nSamples array |
None
|
Source code in ephysiopy/common/spikecalcs.py
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 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 524 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 627 628 629 630 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 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 772 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 |
|
n_spikes
property
Returns the number of spikes in the cluster
Returns:
Name | Type | Description |
---|---|---|
int |
The number of spikes in the cluster |
acorr(Trange=None)
Calculates the autocorrelogram of a spike train
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ts
|
ndarray
|
The spike times |
required |
Trange
|
ndarray
|
The range of times to calculate the autocorrelogram over |
None
|
Returns:
Name | Type | Description |
---|---|---|
counts |
ndarray
|
The autocorrelogram |
bins |
ndarray
|
The bins used to calculate the autocorrelogram |
Source code in ephysiopy/common/spikecalcs.py
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
|
mean_isi_range(isi_range)
Calculates the mean of the autocorrelation from 0 to n milliseconds Used to help classify a neurons type (principal, interneuron etc)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
isi_range
|
int
|
The range in ms to calculate the mean over |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The mean of the autocorrelogram between 0 and n milliseconds |
Source code in ephysiopy/common/spikecalcs.py
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 |
|
mean_waveform(channel_id=None)
Returns the mean waveform and sem for a given spike train on a particular channel
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster_id
|
int
|
The cluster to get the mean waveform for |
required |
Returns:
Name | Type | Description |
---|---|---|
mn_wvs |
ndarray
|
The mean waveforms, usually 4x50 for tetrode recordings |
std_wvs |
ndarray
|
The standard deviations of the waveforms, usually 4x50 for tetrode recordings |
Source code in ephysiopy/common/spikecalcs.py
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 |
|
psch(bin_width_secs)
Calculate the peri-stimulus count histogram of a cell's spiking against event times.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster_id
|
int
|
The cluster for which to calculate the psth. |
required |
bin_width_secs
|
float
|
The width of each bin in seconds. |
required |
Returns:
Name | Type | Description |
---|---|---|
result |
ndarray
|
Rows are counts of spikes per bin_width_secs. |
ndarray
|
Size of columns ranges from self.event_window[0] to |
|
ndarray
|
self.event_window[1] with bin_width_secs steps; |
|
ndarray
|
so x is count, y is "event". |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
psth(**kwargs)
Calculate the PSTH of event_ts against the spiking of a cell
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster_id
|
int
|
The cluster for which to calculate the psth |
required |
Returns:
Type | Description |
---|---|
x, y (list): The list of time differences between the spikes of the cluster and the events (x) and the trials (y) |
Source code in ephysiopy/common/spikecalcs.py
510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 |
|
responds_to_stimulus(threshold, min_contiguous, return_activity=False, return_magnitude=False, **kwargs)
Checks whether a cluster responds to a laser stimulus.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int
|
The cluster to check. |
required |
threshold
|
float
|
The amount of activity the cluster needs to go beyond to be classified as a responder (1.5 = 50% more or less than the baseline activity). |
required |
min_contiguous
|
int
|
The number of contiguous samples in the post-stimulus period for which the cluster needs to be active beyond the threshold value to be classed as a responder. |
required |
return_activity
|
bool
|
Whether to return the mean reponse curve. |
False
|
return_magnitude
|
int
|
Whether to return the magnitude of the response. NB this is either +1 for excited or -1 for inhibited. |
False
|
Returns:
Name | Type | Description |
---|---|---|
responds |
bool
|
Whether the cell responds or not. |
tuple
|
OR |
|
tuple |
tuple
|
responds (bool), normed_response_curve (np.ndarray). |
tuple
|
OR |
|
tuple |
tuple
|
responds (bool), normed_response_curve (np.ndarray), response_magnitude (np.ndarray). |
Source code in ephysiopy/common/spikecalcs.py
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 630 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 |
|
smooth_spike_train(npos, sigma=3.0, shuffle=None)
Returns a spike train the same length as num pos samples that has been smoothed in time with a gaussian kernel M in width and standard deviation equal to sigma.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
array
|
The pos indices the spikes occurred at. |
required |
npos
|
int
|
The number of position samples captured. |
required |
sigma
|
float
|
The standard deviation of the gaussian used to smooth the spike train. |
3.0
|
shuffle
|
int
|
The number of seconds to shift the spike train by. Default is None. |
None
|
Returns:
Name | Type | Description |
---|---|---|
smoothed_spikes |
array
|
The smoothed spike train. |
Source code in ephysiopy/common/spikecalcs.py
770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 |
|
theta_band_max_freq()
Calculates the frequency with the maximum power in the theta band (6-12Hz) of a spike train's autocorrelogram.
This function is used to look for differences in theta frequency in different running directions as per Blair. See Welday paper - https://doi.org/10.1523/jneurosci.0712-11.2011
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
ndarray
|
The spike train for which the autocorrelogram will be calculated. |
required |
Returns:
Name | Type | Description |
---|---|---|
float |
The frequency with the maximum power in the theta band. |
Raises:
Type | Description |
---|---|
ValueError
|
If the input spike train is not valid. |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
theta_mod_idx()
Calculates a theta modulation index of a spike train based on the cells autocorrelogram.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
array
|
The spike time-series. |
required |
Returns:
Name | Type | Description |
---|---|---|
thetaMod |
float
|
The difference of the values at the first peak |
and trough of the autocorrelogram. |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
theta_mod_idxV2()
This is a simpler alternative to the theta_mod_idx method in that it calculates the difference between the normalized temporal autocorrelogram at the trough between 50-70ms and the peak between 100-140ms over their sum (data is binned into 5ms bins)
Measure used in Cacucci et al., 2004 and Kropff et al 2015
Source code in ephysiopy/common/spikecalcs.py
721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
|
update_KSMeta(value)
Takes in a TemplateModel instance from a phy session and parses out the relevant metrics for the cluster and places into the namedtuple KSMeta
Source code in ephysiopy/common/spikecalcs.py
413 414 415 416 417 418 419 420 421 422 423 424 425 |
|
SpikeCalcsOpenEphys
Bases: SpikeCalcsGeneric
Source code in ephysiopy/common/spikecalcs.py
1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
|
get_channel_depth_from_templates(pname)
Determine depth of template as well as closest channel. Adopted from 'templatePositionsAmplitudes' by N. Steinmetz (https://github.com/cortex-lab/spikes)
Source code in ephysiopy/common/spikecalcs.py
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 |
|
get_template_id_for_cluster(pname, cluster)
Determine the best channel (one with highest amplitude spikes) for a given cluster.
Source code in ephysiopy/common/spikecalcs.py
1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 |
|
get_waveforms(cluster, cluster_data, n_waveforms=2000, n_channels=64, channel_range=None, **kwargs)
Returns waveforms for a cluster.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cluster
|
int
|
The cluster to return the waveforms for. |
required |
cluster_data
|
KiloSortSession
|
The KiloSortSession object for the session that contains the cluster. |
required |
n_waveforms
|
int
|
The number of waveforms to return. Defaults to 2000. |
2000
|
n_channels
|
int
|
The number of channels in the recording. Defaults to 64. |
64
|
Source code in ephysiopy/common/spikecalcs.py
1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 |
|
SpikeCalcsProbe
Bases: SpikeCalcsGeneric
Encapsulates methods specific to probe-based recordings
Source code in ephysiopy/common/spikecalcs.py
1200 1201 1202 1203 1204 1205 1206 |
|
SpikeCalcsTetrode
Bases: SpikeCalcsGeneric
Encapsulates methods specific to the geometry inherent in tetrode-based recordings
Source code in ephysiopy/common/spikecalcs.py
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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 |
|
ifr_sp_corr(x1, speed, minSpeed=2.0, maxSpeed=40.0, sigma=3, shuffle=False, nShuffles=100, minTime=30, plot=False)
Calculates the correlation between the instantaneous firing rate and speed.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1
|
array
|
The indices of pos at which the cluster fired. |
required |
speed
|
array
|
Instantaneous speed (1 x nSamples). |
required |
minSpeed
|
float
|
Speeds below this value are ignored. Defaults to 2.0 cm/s as with Kropff et al., 2015. |
2.0
|
maxSpeed
|
float
|
Speeds above this value are ignored. Defaults to 40.0 cm/s. |
40.0
|
sigma
|
int
|
The standard deviation of the gaussian used to smooth the spike train. Defaults to 3. |
3
|
shuffle
|
bool
|
Whether to shuffle the spike train. Defaults to False. |
False
|
nShuffles
|
int
|
The number of times to shuffle the spike train. Defaults to 100. |
100
|
minTime
|
int
|
The minimum time for which the spike train should be considered. Defaults to 30. |
30
|
plot
|
bool
|
Whether to plot the result. Defaults to False. |
False
|
Source code in ephysiopy/common/spikecalcs.py
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 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 |
|
cluster_quality(waveforms=None, spike_clusters=None, cluster_id=None, fet=1)
Returns the L-ratio and Isolation Distance measures calculated on the principal components of the energy in a spike matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
waveforms
|
ndarray
|
The waveforms to be processed. If None, the function will return None. |
None
|
spike_clusters
|
ndarray
|
The spike clusters to be processed. |
None
|
cluster_id
|
int
|
The ID of the cluster to be processed. |
None
|
fet
|
int, default=1
|
The feature to be used in the PCA calculation. |
1
|
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the L-ratio and Isolation Distance of the cluster. |
Raises:
Type | Description |
---|---|
Exception
|
If an error occurs during the calculation of the L-ratio or Isolation Distance. |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
contamination_percent(x1, x2=None, **kwargs)
Computes the cross-correlogram between two sets of spikes and estimates how refractory the cross-correlogram is.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
st1
|
array
|
The first set of spikes. |
required |
st2
|
array
|
The second set of spikes. |
required |
kwargs
Anything that can be fed into xcorr above
Returns:
Name | Type | Description |
---|---|---|
Q |
float
|
a measure of refractoriness |
R |
float
|
a second measure of refractoriness (kicks in for very low firing rates) |
Notes
Taken from KiloSorts ccg.m
The contamination metrics are calculated based on an analysis of the 'shoulders' of the cross-correlogram. Specifically, the spike counts in the ranges +/-5-25ms and +/-250-500ms are compared for refractoriness
Source code in ephysiopy/common/spikecalcs.py
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 |
|
get_param(waveforms, param='Amp', t=200, fet=1)
Returns the requested parameter from a spike train as a numpy array
Parameters:
Name | Type | Description | Default |
---|---|---|---|
waveforms
|
numpy array
|
Shape of array can be nSpikes x nSamples OR a nSpikes x nElectrodes x nSamples |
required |
param
|
str
|
Valid values are: 'Amp' - peak-to-trough amplitude (default) 'P' - height of peak 'T' - depth of trough 'Vt' height at time t 'tP' - time of peak (in seconds) 'tT' - time of trough (in seconds) 'PCA' - first n fet principal components (defaults to 1) |
'Amp'
|
t
|
int
|
The time used for Vt |
200
|
fet
|
int
|
The number of principal components (use with param 'PCA') |
1
|
Source code in ephysiopy/common/spikecalcs.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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
mahal(u, v)
Returns the L-ratio and Isolation Distance measures calculated on the principal components of the energy in a spike matrix.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
waveforms
|
ndarray
|
The waveforms to be processed. If None, the function will return None. |
required |
spike_clusters
|
ndarray
|
The spike clusters to be processed. |
required |
cluster_id
|
int
|
The ID of the cluster to be processed. |
required |
fet
|
int, default=1
|
The feature to be used in the PCA calculation. |
required |
Returns:
Name | Type | Description |
---|---|---|
tuple |
A tuple containing the L-ratio and Isolation Distance of the cluster. |
Raises:
Type | Description |
---|---|
Exception
|
If an error occurs during the calculation of the L-ratio or Isolation Distance. |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
xcorr(x1, x2=None, Trange=None, binsize=0.001, **kwargs)
Calculates the ISIs in x1 or x1 vs x2 within a given range
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x1,
|
x2 (array_like
|
The times of the spikes emitted by the cluster(s) in seconds |
required |
Trange
|
array_like
|
Range of times to bin up in seconds Defaults to [-0.5, +0.5] |
None
|
binsize
|
float
|
The size of the bins in seconds |
0.001
|
Returns:
Name | Type | Description |
---|---|---|
counts |
ndarray
|
The cross-correlogram of the spike trains x1 and x2 |
bins |
ndarray
|
The bins used to calculate the cross-correlogram |
Source code in ephysiopy/common/spikecalcs.py
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 |
|
Statistics
V_test(angles, test_direction)
The Watson U2 tests whether the observed angles have a tendency to cluster around a given angle indicating a lack of randomness in the distribution. Also known as the modified Rayleigh test.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angles
|
array_like
|
Vector of angular values in degrees. |
required |
test_direction
|
int
|
A single angular value in degrees. |
required |
Notes
For grouped data the length of the mean vector must be adjusted, and for axial data all angles must be doubled.
Source code in ephysiopy/common/statscalcs.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
circ_r(alpha, w=None, d=0, axis=0)
Computes the mean resultant vector length for circular data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
alpha
|
array or list
|
Sample of angles in radians. |
required |
w
|
array or list
|
Counts in the case of binned data. Must be same length as alpha. |
None
|
d
|
array or list
|
Spacing of bin centres for binned data; if supplied, correction factor is used to correct for bias in estimation of r, in radians. |
0
|
axis
|
int
|
The dimension along which to compute. Default is 0. |
0
|
Returns:
Name | Type | Description |
---|---|---|
r |
float
|
The mean resultant vector length. |
Source code in ephysiopy/common/statscalcs.py
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 |
|
duplicates_as_complex(x, already_sorted=False)
Finds duplicates in x
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
array_like
|
The list to find duplicates in. |
required |
already_sorted
|
bool
|
Whether x is already sorted. Default False. |
False
|
Returns:
Name | Type | Description |
---|---|---|
x |
array_like
|
A complex array where the complex part is the count of the number of duplicates of the real value. |
Examples:
>>> x = [9.9, 9.9, 12.3, 15.2, 15.2, 15.2]
>>> ret = duplicates_as_complex(x)
>>> print(ret)
[9.9+0j, 9.9+1j, 12.3+0j, 15.2+0j, 15.2+1j, 15.2+2j]
Source code in ephysiopy/common/statscalcs.py
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 |
|
mean_resultant_vector(angles)
Calculate the mean resultant length and direction for angles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angles
|
array
|
Sample of angles in radians. |
required |
Returns:
Name | Type | Description |
---|---|---|
r |
float
|
The mean resultant vector length. |
th |
float
|
The mean resultant vector direction. |
Source code in ephysiopy/common/statscalcs.py
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
watsonWilliams(a, b)
The Watson-Williams F test tests whether a set of mean directions are equal given that the concentrations are unknown, but equal, given that the groups each follow a von Mises distribution.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a,
|
b (array_like
|
The directional samples |
required |
Returns:
Name | Type | Description |
---|---|---|
F_stat |
float
|
The F-statistic |
Source code in ephysiopy/common/statscalcs.py
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 |
|
watsonsU2(a, b)
Tests whether two samples from circular observations differ significantly from each other with regard to mean direction or angular variance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a,
|
b (array_like
|
The two samples to be tested |
required |
Returns:
Name | Type | Description |
---|---|---|
U2 |
float
|
The test statistic |
Notes
Both samples must come from a continuous distribution. In the case of grouping the class interval should not exceed 5. Taken from '100 Statistical Tests' G.J.Kanji, 2006 Sage Publications
Source code in ephysiopy/common/statscalcs.py
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 |
|
watsonsU2n(angles)
Tests whether the given distribution fits a random sample of angular values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
angles
|
array_like
|
The angular samples. |
required |
Returns:
Name | Type | Description |
---|---|---|
U2n |
float
|
The test statistic. |
Notes
This test is suitable for both unimodal and the multimodal cases. It can be used as a test for randomness. Taken from '100 Statistical Tests' G.J.Kanji, 2006 Sage Publications.
Source code in ephysiopy/common/statscalcs.py
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 |
|
Utility functions
blurImage(im, n, ny=None, ftype='boxcar', **kwargs)
Smooths a 2D image by convolving with a filter.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
im
|
array_like
|
The array to smooth. |
required |
n,
|
ny (int
|
The size of the smoothing kernel. |
required |
ftype
|
str
|
The type of smoothing kernel. Either 'boxcar' or 'gaussian'. |
'boxcar'
|
Returns:
Name | Type | Description |
---|---|---|
res |
array_like
|
The smoothed vector with shape the same as im. |
Source code in ephysiopy/common/utils.py
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 |
|
bwperim(bw, n=4)
Finds the perimeter of objects in binary images.
A pixel is part of an object perimeter if its value is one and there is at least one zero-valued pixel in its neighborhood.
By default the neighborhood of a pixel is 4 nearest pixels, but
if n
is set to 8 the 8 nearest pixels will be considered.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bw
|
array_like
|
A black-and-white image. |
required |
n
|
int
|
Connectivity. Must be 4 or 8. Default is 8. |
4
|
Returns:
Name | Type | Description |
---|---|---|
perim |
array_like
|
A boolean image. |
Source code in ephysiopy/common/utils.py
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 |
|
count_to(n)
This function is equivalent to hstack((arange(n_i) for n_i in n)). It seems to be faster for some possible inputs and encapsulates a task in a function.
Example
Given n = [0, 0, 3, 0, 0, 2, 0, 2, 1], the result would be [0, 1, 2, 0, 1, 0, 1, 0].
Source code in ephysiopy/common/utils.py
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
get_z_score(x, mean=None, sd=None, axis=0)
Calculate the z-scores for array x based on the mean and standard deviation in that sample, unless stated
Source code in ephysiopy/common/utils.py
5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
polar(x, y, deg=False)
Converts from rectangular coordinates to polar ones.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x,
|
y (array_like, list_like
|
The x and y coordinates. |
required |
deg
|
int
|
Radian if deg=0; degree if deg=1. |
False
|
Returns:
Name | Type | Description |
---|---|---|
p |
array_like
|
The polar version of x and y. |
Source code in ephysiopy/common/utils.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
rect(r, w, deg=False)
Convert from polar (r,w) to rectangular (x,y) x = r cos(w) y = r sin(w)
Source code in ephysiopy/common/utils.py
187 188 189 190 191 192 193 194 195 196 |
|
repeat_ind(n)
Examples:
>>> n = [0, 0, 3, 0, 0, 2, 0, 2, 1]
>>> res = repeat_ind(n)
>>> res = [2, 2, 2, 5, 5, 7, 7, 8]
The input specifies how many times to repeat the given index. It is equivalent to something like this:
hstack((zeros(n_i,dtype=int)+i for i, n_i in enumerate(n)))
But this version seems to be faster, and probably scales better. At any rate, it encapsulates a task in a function.
Source code in ephysiopy/common/utils.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
smooth(x, window_len=9, window='hanning')
Smooth the data using a window with requested size.
This method is based on the convolution of a scaled window with the signal. The signal is prepared by introducing reflected copies of the signal (with the window size) in both ends so that transient parts are minimized in the beginning and end part of the output signal.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x
|
array_like
|
The input signal. |
required |
window_len
|
int
|
The length of the smoothing window. |
9
|
window
|
str
|
The type of window from 'flat', 'hanning', 'hamming', 'bartlett', 'blackman'. 'flat' window will produce a moving average smoothing. |
'hanning'
|
Returns:
Name | Type | Description |
---|---|---|
out |
array_like
|
The smoothed signal. |
Example
t=linspace(-2,2,0.1) x=sin(t)+randn(len(t))*0.1 y=smooth(x)
See Also
numpy.hanning, numpy.hamming, numpy.bartlett, numpy.blackman, numpy.convolve, scipy.signal.lfilter
Notes
The window parameter could be the window itself if an array instead of a string.
Source code in ephysiopy/common/utils.py
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 |
|
Axona input/ output
ClusterSession
Bases: object
Loads all the cut file data and timestamps from the data associated with the *.set filename given to init
Meant to be a method-replica of the KiloSortSession class but really both should inherit from the same meta-class
Source code in ephysiopy/axona/axonaIO.py
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 630 631 632 633 634 635 636 637 638 639 640 641 |
|
EEG
Bases: IO
Processes eeg data collected with the Axona recording system
Parameters
filename_root : str The fully qualified filename without the suffix egf: int Whether to read the 'eeg' file or the 'egf' file. 0 is False, 1 is True eeg_file: int If more than one eeg channel was recorded from then they are numbered from 1 onwards i.e. trial.eeg, trial.eeg1, trial.eeg2 etc This number specifies that
Source code in ephysiopy/axona/axonaIO.py
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 524 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 |
|
IO
Bases: object
Axona data I/O. Also reads .clu files generated from KlustaKwik
Parameters
filename_root : str The fully-qualified filename
Source code in ephysiopy/axona/axonaIO.py
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 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 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 |
|
getCluCut(tet)
Load a clu file and return as an array of integers
Parameters
tet : int The tetrode the clu file relates to
Returns
out : ndarray Data read from the clu file
Source code in ephysiopy/axona/axonaIO.py
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
getCut(tet)
Returns the cut file as a list of integers
Parameters
tet : int The tetrode the cut file relates to
Returns
out : ndarray The data read from the cut file
Source code in ephysiopy/axona/axonaIO.py
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 |
|
getData(filename_root)
Returns the data part of an Axona data file i.e. from "data_start" to "data_end"
Parameters
input : str Fully qualified path name to the data file
Returns
output : ndarray The data part of whatever file was fed in
Source code in ephysiopy/axona/axonaIO.py
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 |
|
getHeader(filename_root)
Reads and returns the header of a specified data file as a dictionary
Parameters
filename_root : str Fully qualified filename of Axona type
Returns
headerDict : dict key - value pairs of the header part of an Axona type file
Source code in ephysiopy/axona/axonaIO.py
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 |
|
getHeaderVal(header, key)
Get a value from the header as an int
Parameters
header : dict The header dictionary to read key : str The key to look up
Returns
value : int
The value of key
as an int
Source code in ephysiopy/axona/axonaIO.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
|
setData(filename_root, data)
Writes Axona format data to the given filename
Parameters
filename_root : str The fully qualified filename including the suffix
ndarray
The data that will be saved
Source code in ephysiopy/axona/axonaIO.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 |
|
setHeader(filename_root, header)
Writes out the header to the specified file
Parameters
filename_root : str A fully qualified path to a file with the relevant suffix at the end (e.g. ".set", ".pos" or whatever)
dataclass
See ephysiopy.axona.file_headers
Source code in ephysiopy/axona/axonaIO.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
|
Pos
Bases: IO
Processs position data recorded with the Axona recording system
Parameters
filename_root : str The basename of the file i.e mytrial as opposed to mytrial.pos
Notes
Currently the only arg that does anything is 'cm' which will convert the xy data to cm, assuming that the pixels per metre value has been set correctly
Source code in ephysiopy/axona/axonaIO.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 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 |
|
Stim
Bases: dict
, IO
Processes the stimulation data recorded using Axona
Parameters
filename_root : str The fully qualified filename without the suffix
Source code in ephysiopy/axona/axonaIO.py
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 |
|
Tetrode
Bases: IO
Processes tetrode files recorded with the Axona recording system
Mostly this class deals with interpolating tetrode and position timestamps and getting indices for particular clusters.
Parameters
filename_root : str The fully qualified name of the file without it's suffix tetrode : int The number of the tetrode volts : bool, optional Whether to convert the data values volts. Default True
Source code in ephysiopy/axona/axonaIO.py
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 |
|
getClustIdx(cluster)
Get the indices of the position samples corresponding to the cluster
Parameters
cluster : int The cluster whose position indices we want
Returns
pos_samples : ndarray The indices of the position samples, dtype is int
Source code in ephysiopy/axona/axonaIO.py
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
|
getClustSpks(cluster)
Returns the waveforms of cluster
Parameters
cluster : int The cluster whose waveforms we want
Returns
waveforms : ndarray The waveforms on all 4 electrodes of the tgtrode so the shape of the returned array is [nClusterSpikes, 4, 50]
Source code in ephysiopy/axona/axonaIO.py
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
|
getClustTS(cluster=None)
Returns the timestamps for a cluster on the tetrode
Parameters
cluster : int The cluster whose timestamps we want
Returns
clustTS : ndarray The timestamps
Notes
If None is supplied as input then all timestamps for all clusters is returned i.e. getSpkTS() is called
Source code in ephysiopy/axona/axonaIO.py
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 |
|
getPosSamples()
Returns the pos samples at which the spikes were captured
Source code in ephysiopy/axona/axonaIO.py
420 421 422 423 424 425 426 427 |
|
getSpkTS()
Return all the timestamps for all the spikes on the tetrode
Source code in ephysiopy/axona/axonaIO.py
384 385 386 387 388 |
|
getUniqueClusters()
Returns the unique clusters
Source code in ephysiopy/axona/axonaIO.py
471 472 473 474 475 476 477 478 |
|
Conversion code
OpenEphys to Axona
OE2Axona
Bases: object
Converts openephys data into Axona files
Example workflow:
You have recorded some openephys data using the binary format leading to a directory structure something like this:
M4643_2023-07-21_11-52-02 ├── Record Node 101 │ ├── experiment1 │ │ └── recording1 │ │ ├── continuous │ │ │ └── Acquisition_Board-100.Rhythm Data │ │ │ ├── amplitudes.npy │ │ │ ├── channel_map.npy │ │ │ ├── channel_positions.npy │ │ │ ├── cluster_Amplitude.tsv │ │ │ ├── cluster_ContamPct.tsv │ │ │ ├── cluster_KSLabel.tsv │ │ │ ├── continuous.dat │ │ │ ├── params.py │ │ │ ├── pc_feature_ind.npy │ │ │ ├── pc_features.npy │ │ │ ├── phy.log │ │ │ ├── rez.mat │ │ │ ├── similar_templates.npy │ │ │ ├── spike_clusters.npy │ │ │ ├── spike_templates.npy │ │ │ ├── spike_times.npy │ │ │ ├── template_feature_ind.npy │ │ │ ├── template_features.npy │ │ │ ├── templates_ind.npy │ │ │ ├── templates.npy │ │ │ ├── whitening_mat_inv.npy │ │ │ └── whitening_mat.npy │ │ ├── events │ │ │ ├── Acquisition_Board-100.Rhythm Data │ │ │ │ └── TTL │ │ │ │ ├── full_words.npy │ │ │ │ ├── sample_numbers.npy │ │ │ │ ├── states.npy │ │ │ │ └── timestamps.npy │ │ │ └── MessageCenter │ │ │ ├── sample_numbers.npy │ │ │ ├── text.npy │ │ │ └── timestamps.npy │ │ ├── structure.oebin │ │ └── sync_messages.txt │ └── settings.xml └── Record Node 104 ├── experiment1 │ └── recording1 │ ├── continuous │ │ └── TrackMe-103.TrackingNode │ │ ├── continuous.dat │ │ ├── sample_numbers.npy │ │ └── timestamps.npy │ ├── events │ │ ├── MessageCenter │ │ │ ├── sample_numbers.npy │ │ │ ├── text.npy │ │ │ └── timestamps.npy │ │ └── TrackMe-103.TrackingNode │ │ └── TTL │ │ ├── full_words.npy │ │ ├── sample_numbers.npy │ │ ├── states.npy │ │ └── timestamps.npy │ ├── structure.oebin │ └── sync_messages.txt └── settings.xml
The binary data file is called "continuous.dat" in the continuous/Acquisition_Board-100.Rhythm Data folder. There is also a collection of files resulting from a KiloSort session in that directory.
Run the conversion code like so:
from ephysiopy.format_converters.OE_Axona import OE2Axona from pathlib import Path nChannels = 64 apData = Path("M4643_2023-07-21_11-52-02/Record Node 101/experiment1/recording1/continuous/Acquisition_Board-100.Rhythm Data") OE = OE2Axona(Path("M4643_2023-07-21_11-52-02"), path2APData=apData, channels=nChannels) OE.getOEData()
The last command will attempt to load position data and also load up something called a TemplateModel (from the package phylib) which should grab a handle to the neural data. If that doesn't throw out errors then try:
OE.exportPos()
There are a few arguments you can provide the exportPos() function - see the docstring for it below. Basically, it calls a function called convertPosData(xy, xyts) where xy is the xy data with shape nsamples x 2 and xyts is a vector of timestamps. So if the call to exportPos() fails, you could try calling convertPosData() directly which returns axona formatted position data. If the variable returned from convertPosData() is called axona_pos_data then you can call the function:
writePos2AxonaFormat(pos_header, axona_pos_data)
Providing the pos_header to it - see the last half of the exportPos function for how to create and modify the pos_header as that will need to have user-specific information added to it.
OE.convertTemplateDataToAxonaTetrode()
This is the main function for creating the tetrode files. It has an optional argument called max_n_waves which is used to limit the maximum number of spikes that make up a cluster. This defaults to 2000 which means that if a cluster has 12000 spikes, it will have 2000 spikes randomly drawn from those 12000 (without replacement), that will then be saved to a tetrode file. This is mostly a time-saving device as if you have 250 clusters and many consist of 10,000's of spikes, processing that data will take a long time.
OE.exportLFP()
This will save either a .eeg or .egf file depending on the arguments. Check the docstring for how to change what channel is chosen for the LFP etc.
OE.exportSetFile()
This should save the .set file with all the metadata for the trial.
Source code in ephysiopy/format_converters/OE_Axona.py
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 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 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 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 524 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 627 628 629 630 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 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 772 773 774 775 776 777 778 779 780 781 782 783 784 |
|
settings
property
writable
Loads the settings data from the settings.xml file
__init__(pname, path2APData=None, pos_sample_rate=50, channels=0, **kwargs)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pname
|
Path
|
The base directory of the openephys recording. e.g. '/home/robin/Data/M4643_2023-07-21_11-52-02' |
required |
path2APData
|
Path
|
Path to AP data. Defaults to None. |
None
|
pos_sample_rate
|
int
|
Position sample rate. Defaults to 50. |
50
|
channels
|
int
|
Number of channels. Defaults to 0. |
0
|
**kwargs
|
Variable length argument list. |
{}
|
Source code in ephysiopy/format_converters/OE_Axona.py
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 |
|
convertPosData(xy, xy_ts)
Performs the conversion of the array parts of the data.
Note: As well as upsampling the data to the Axona pos sampling rate (50Hz), we have to insert some columns into the pos array as Axona format expects it like: pos_format: t,x1,y1,x2,y2,numpix1,numpix2 We can make up some of the info and ignore other bits.
Source code in ephysiopy/format_converters/OE_Axona.py
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 |
|
convertSpikeData(hdf5_tetrode_data)
Does the spike conversion from OE Spike Sorter format to Axona format tetrode files.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hdf5_tetrode_data
|
Group
|
This kind of looks like a dictionary and can, it seems, be treated as one more or less. See http://docs.h5py.org/en/stable/high/group.html |
required |
Source code in ephysiopy/format_converters/OE_Axona.py
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 |
|
convertTemplateDataToAxonaTetrode(max_n_waves=2000, **kwargs)
Converts the data held in a TemplateModel instance into tetrode format Axona data files.
For each cluster, there'll be a channel that has a peak amplitude and this contains that peak channel. While the other channels with a large signal in might be on the same tetrode, KiloSort (or whatever) might find channels not within the same tetrode. For a given cluster, we can extract from the TemplateModel the 12 channels across which the signal is strongest using Model.get_cluster_channels(). If a channel from a tetrode is missing from this list then the spikes for that channel(s) will be zeroed when saved to Axona format.
Example
If cluster 3 has a peak channel of 1 then get_cluster_channels() might look like: [ 1, 2, 0, 6, 10, 11, 4, 12, 7, 5, 8, 9] Here the cluster has the best signal on 1, then 2, 0 etc, but note that channel 3 isn't in the list. In this case the data for channel 3 will be zeroed when saved to Axona format.
References
1) https://phy.readthedocs.io/en/latest/api/#phyappstemplatetemplatemodel
Source code in ephysiopy/format_converters/OE_Axona.py
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 524 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 |
|
exportLFP(channel=0, lfp_type='eeg', gain=5000, **kwargs)
Exports LFP data to file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
channel
|
int
|
The channel number. |
0
|
lfp_type
|
str
|
The type of LFP data. Legal values are 'egf' or 'eeg'. |
'eeg'
|
gain
|
int
|
Multiplier for the LFP data. |
5000
|
Source code in ephysiopy/format_converters/OE_Axona.py
351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
|
exportSetFile(**kwargs)
Wrapper for makeSetData below
Source code in ephysiopy/format_converters/OE_Axona.py
267 268 269 270 271 272 273 |
|
getOEData()
Loads the nwb file names in filename_root and returns a dict containing some of the nwb data relevant for converting to Axona file formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename_root
|
str
|
Fully qualified name of the nwb file. |
required |
recording_name
|
str
|
The name of the recording in the nwb file. Note that the default has changed in different versions of OE from 'recording0' to 'recording1'. |
required |
Source code in ephysiopy/format_converters/OE_Axona.py
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 |
|
makeLFPData(data, eeg_type='eeg', gain=5000)
Downsamples the data in data and saves the result as either an egf or eeg file depending on the choice of either eeg_type which can take a value of either 'egf' or 'eeg'. Gain is the scaling factor.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
array
|
The data to be downsampled. Must have dtype as np.int16. |
required |
Source code in ephysiopy/format_converters/OE_Axona.py
619 620 621 622 623 624 625 626 627 628 629 630 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 |
|
resample(data, src_rate=30, dst_rate=50, axis=0)
Resamples data using FFT
Source code in ephysiopy/format_converters/OE_Axona.py
198 199 200 201 202 203 204 205 |
|
OpenEphys to numpy
OE2Numpy
Bases: object
Converts openephys data recorded in the nwb format into numpy files
NB Only exports the LFP and TTL files at the moment
Source code in ephysiopy/format_converters/OE_numpy.py
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 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 |
|
settings
property
writable
Loads the settings data from the settings.xml file
getOEData(filename_root, recording_name='recording1')
Loads the nwb file names in filename_root and returns a dict containing some of the nwb data relevant for converting to Axona file formats.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename_root
|
str
|
Fully qualified name of the nwb file. |
required |
recording_name
|
str
|
The name of the recording in the nwb file. |
'recording1'
|
Source code in ephysiopy/format_converters/OE_numpy.py
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 |
|
resample(data, src_rate=30, dst_rate=50, axis=0)
Upsamples data using FFT
Source code in ephysiopy/format_converters/OE_numpy.py
26 27 28 29 30 31 32 33 |
|