Python frontend
ADS1299
A class representing the ADS1299 driver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
str
|
The serial port to communicate with the ADS1299. |
required |
baudrate
|
int
|
The baud rate for serial communication. Defaults to 115200. |
115200
|
Attributes:
| Name | Type | Description |
|---|---|---|
channels |
list
|
A list of available channels. |
gains |
list
|
A list of available gains. |
input_modes |
list
|
A list of available input modes. |
test_signal_conf |
dict
|
A dictionary containing the configuration for the test signal. |
Source code in eeg_acquisition\ADS1299driver.py
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 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 | |
__init__(port, baudrate=115200)
Initializes the ADS1299driver object.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
port
|
str
|
The serial port to connect to. |
required |
baudrate
|
int
|
The baud rate for the serial communication. Defaults to 115200. |
115200
|
Source code in eeg_acquisition\ADS1299driver.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 | |
bias_measure(connect, channel=None)
Connects the bias to a channel to be measured or disconnects the bias measurement.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
connect
|
bool
|
True to enable bias measurement, False to disable it. |
required |
channel
|
int
|
The channel number. Required if connect is True. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If connect is not a boolean or if the channel is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.bias_measure(True, 1)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
close()
Closes the serial connection.
Example
>>> ads = ADS1299('COM8')
>>> ads.close()
Source code in eeg_acquisition\ADS1299driver.py
662 663 664 665 666 667 668 669 670 671 672 | |
disable_all_channels()
Disables all channels.
Example
>>> ads = ADS1299('COM8')
>>> ads.disable_all_channels()
Source code in eeg_acquisition\ADS1299driver.py
499 500 501 502 503 504 505 506 507 508 509 510 | |
disable_channel(channel)
Disables a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
The channel number. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the channel is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.disable_channel(1)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
enable_all_channels()
Enables all channels.
Example
>>> ads = ADS1299('COM8')
>>> ads.enable_all_channels()
Source code in eeg_acquisition\ADS1299driver.py
460 461 462 463 464 465 466 467 468 469 470 471 | |
enable_channel(channel)
Enables a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
The channel number. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the channel is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.enable_channel(1)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
get_batch_read()
Gets the batch data from the ADS1299.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A numpy array of data read from the ADS1299. |
Raises:
| Type | Description |
|---|---|
TaskAbortedError
|
If the operation takes more than its timeout. |
Example
>>> ads = ADS1299('COM8')
>>> data = ads.get_batch_read()
[[123, 456, 789, ...], [123, 456, 789, ...], ...]
Source code in eeg_acquisition\ADS1299driver.py
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 | |
live_plot(buffer_width=1000)
Creates a live plot of the 8 channels' data over the last width seconds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
buffer_width
|
int
|
The time window to display in the plot. |
1000
|
Example
>>> ads = ADS1299('COM8')
>>> ads.live_plot()
Source code in eeg_acquisition\ADS1299driver.py
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 | |
log_data(filename, duration=10)
Logs data from the ADS1299 to a file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
The name of the file to log the data to. |
required |
duration
|
int
|
The duration of the logging in seconds. Defaults to 10. If set to -1, the logging will continue indefinitely. |
10
|
Example
>>> ads = ADS1299('COM8')
>>> ads.log_data('data_log.txt', 10)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
print_all_registers()
Prints all registers from the ADS1299.
Example
>>> ads = ADS1299('COM8')
>>> ads.print_all_registers()
ID, 0x00, 0x3E, 0, 0, 1, 1, 1, 1, 1, 0
CONFIG1, 0x01, 0x96, 1, 0, 0, 1, 0, 1, 1, 0
CONFIG2, 0x02, 0xC0, 1, 1, 0, 0, 0, 0, 0, 0
CONFIG3, 0x03, 0xE0, 1, 1, 1, 0, 0, 0, 0, 0
LOFF, 0x04, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
CH1SET, 0x05, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH2SET, 0x06, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH3SET, 0x07, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH4SET, 0x08, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH5SET, 0x09, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH6SET, 0x0A, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH7SET, 0x0B, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
CH8SET, 0x0C, 0x61, 0, 1, 1, 0, 0, 0, 0, 1
BIAS_SENSP, 0x0D, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
BIAS_SENSN, 0x0E, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
LOFF_SENSP, 0x0F, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
LOFF_SENSN, 0x10, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
LOFF_FLIP, 0x11, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
LOFF_STATP, 0x12, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
LOFF_STATN, 0x13, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
GPIO, 0x14, 0x0F, 0, 0, 0, 0, 1, 1, 1, 1
MISC1, 0x15, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
MISC2, 0x16, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
CONFIG4, 0x17, 0x00, 0, 0, 0, 0, 0, 0, 0, 0
Source code in eeg_acquisition\ADS1299driver.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 795 796 797 798 799 800 801 802 803 804 805 806 807 | |
rdatac()
Enables Read Data Continuous mode in the ADS1299.
Example
>>> ads = ADS1299('COM8')
>>> ads.rdatac()
Source code in eeg_acquisition\ADS1299driver.py
512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
read_ASCII_data(normalized=True)
Reads data from the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
normalized
|
bool
|
True to normalize the data, False to return raw data. |
True
|
Returns:
| Type | Description |
|---|---|
array
|
np.array: A numpy array of data read from the ADS1299. |
Raises:
| Type | Description |
|---|---|
TaskAbortedError
|
If the operation takes more than its timeout. |
Example
>>> ads = ADS1299('COM8')
>>> data = ads.read_ASCII_data(True)
[0.123, 0.456, 0.789, ...]
Source code in eeg_acquisition\ADS1299driver.py
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 | |
read_line()
Reads a line from the serial port.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The line read from the serial port. |
Source code in eeg_acquisition\ADS1299driver.py
103 104 105 106 107 108 109 110 | |
sdatac()
Disables Read Data Continuous mode in the ADS1299.
Example
>>> ads = ADS1299('COM8')
>>> ads.sdatac()
Source code in eeg_acquisition\ADS1299driver.py
527 528 529 530 531 532 533 534 535 536 537 538 539 540 | |
set_batch_read(n_samples)
Sets a read of N samples from the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
n_samples
|
int
|
The number of samples to read. |
required |
Raises:
| Type | Description |
|---|---|
TaskAbortedError
|
If the read operation takes more than its timeout. |
Example
>>> ads = ADS1299('COM8')
>>> data = ads.set_batch_read(10)
Source code in eeg_acquisition\ADS1299driver.py
608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 | |
set_bias(mode)
Enables or disables the bias for the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
bool
|
True to enable the bias, False to disable it. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the mode is not a boolean. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_bias(True)
Source code in eeg_acquisition\ADS1299driver.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
set_biasrefint(mode)
Enables or disables the internal bias reference for the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
bool
|
True to enable the internal bias reference, False to disable it. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the mode is not a boolean. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_biasrefint(True)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
set_channel_bias_connections(channel, positive, negative)
Sets the connections of the desired channel to the input of bias drive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
The channel number. |
required |
positive
|
bool
|
True to connect the positive input to the bias drive. |
required |
negative
|
bool
|
True to connect the negative input to the bias drive. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the channel is invalid or if positive/negative is not a boolean. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_channel_bias_connections(1, True, False)
>>> ads.set_channel_bias_connections(2, False, True)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
set_channel_bias_connections_for_all(positive, negative)
Sets the connections of all channels to the input of bias drive.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
positive
|
bool
|
True to connect the positive inputs to the bias drive. |
required |
negative
|
bool
|
True to connect the negative inputs to the bias drive. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If positive/negative is not a boolean. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_channel_bias_connections_for_all(True, False)
Source code in eeg_acquisition\ADS1299driver.py
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
set_data_rate(data_rate)
Sets the data rate for the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_rate
|
int
|
The data rate in Hz. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the data rate is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_data_rate(1000)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
set_gain(channel, gain)
Sets the gain for a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
The channel number. |
required |
gain
|
int
|
The gain value. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the channel or gain is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_gain(1, 24)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
set_gain_for_all(gain)
Sets the gain for all channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gain
|
int
|
The gain value. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the gain is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_gain_for_all(24)
Source code in eeg_acquisition\ADS1299driver.py
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
set_input_mode(channel, mode)
Sets the input mode for a specific channel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
channel
|
int
|
The channel number. |
required |
mode
|
str
|
The input mode. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the channel or mode is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_input_mode(1, 'normal')
>>> ads.set_input_mode(2, 'shorted')
>>> ads.set_input_mode(3, 'test')
Source code in eeg_acquisition\ADS1299driver.py
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 | |
set_input_mode_for_all(mode)
Sets the input mode for all channels.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mode
|
str
|
The input mode. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the mode is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_input_mode_for_all('normal')
Source code in eeg_acquisition\ADS1299driver.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 | |
set_reference(reference, mode, channel=None)
Sets the references for the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
reference
|
str
|
The reference to set. Must be 'SRB1' or 'SRB2'. |
required |
mode
|
bool
|
True to enable the reference, False to disable it. |
required |
channel
|
int
|
The channel number. Required for 'SRB2'. |
None
|
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the reference or channel is invalid, or if mode is not a boolean. |
Example
>>> ads = ADS1299('COM8')
>>> ads.set_reference('SRB1', True)
Source code in eeg_acquisition\ADS1299driver.py
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 | |
single_read()
Starts a single conversion and reads the data from the ADS1299.
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: A list of data read from the ADS1299. |
Raises:
| Type | Description |
|---|---|
TaskAbortedError
|
If the read operation takes more than its timeout. |
Example
>>> ads = ADS1299('COM8')
>>> data = ads.single_read()
[123, 456, 789, ...]
Source code in eeg_acquisition\ADS1299driver.py
588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 | |
single_shot_mode(enable)
Enables or disables single-shot mode.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
enable
|
bool
|
True to enable single-shot mode, False to disable it. |
required |
Example
>>> ads = ADS1299('COM8')
>>> ads.single_shot_mode(True)
Source code in eeg_acquisition\ADS1299driver.py
569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 | |
start_streaming()
Starts streaming data from the ADS1299.
Example
>>> ads = ADS1299('COM8')
>>> ads.start_streaming()
Source code in eeg_acquisition\ADS1299driver.py
542 543 544 545 546 547 548 549 550 551 552 | |
stop_streaming()
Stops the stream of data from the ADS1299.
Example
>>> ads = ADS1299('COM8')
>>> ads.stop_streaming()
Source code in eeg_acquisition\ADS1299driver.py
554 555 556 557 558 559 560 561 562 563 564 565 566 567 | |
test_signal(amplitude, frequency)
Configures the test signal to the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
amplitude
|
str
|
The amplitude of the test signal. |
required |
frequency
|
str
|
The frequency of the test signal. |
required |
Raises:
| Type | Description |
|---|---|
AssertionError
|
If the amplitude or frequency is invalid. |
Example
>>> ads = ADS1299('COM8')
>>> ads.test_signal('1', 'fast')
Source code in eeg_acquisition\ADS1299driver.py
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 | |
verbosity(value)
Sets the verbose mode for the ADS1299.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
bool
|
True to enable verbose mode, False to disable it. |
required |
Source code in eeg_acquisition\ADS1299driver.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |