Writer
openseize.file_io.edf.Writer
Bases: bases.Writer
A writer of European Data Format (EDF/EDF+) files.
This Writer is a context manager for writing EEG data and metadata to an EDF binary file. Unlike Readers it must be opened under the context management protocol. Importantly, this writer does not currently support writing annotations to an EDF file.
Attributes:
Name | Type | Description |
---|---|---|
path |
Path
|
A python path instance to target file to write data to. |
Examples:
>>> from openseize.demos import paths
>>> filepath = paths.locate('recording_001.edf')
>>> # Create a reader that will read only channels [0, 1]
>>> # and write out these channels to a new file
>>> writepath = paths.data_dir.joinpath('subset_001.edf')
>>> with Reader(filepath) as reader:
>>> with Writer(writepath) as writer:
>>> writer.write(reader.header, reader, channels=[0, 1])
Source code in openseize/file_io/edf.py
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 |
|
__init__(path)
write(header, data, channels, verbose=True)
Write header metadata and data for channel in channels to this Writer's file instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
header |
Header
|
A mapping of EDF compliant fields and values. |
required |
data |
Union[np.ndarray, Reader]
|
An array with shape (channels, samples) or Reader instance. |
required |
channels |
Sequence[int]
|
Channel indices to write to this Writer's open file. |
required |
verbose |
bool
|
An option to print progress of write. |
True
|
Raises:
Type | Description |
---|---|
ValueErrror
|
An error occurs if samples to be written is not divisible by the number of records in the Header instance. |
Source code in openseize/file_io/edf.py
Bases and Mixins
Writer Base
Bases: abc.ABC
, mixins.ViewInstance
Abstract base class for all writers of EEG data.
This ABC defines all EEG writers as context managers that write data to a file path. Inheritors must override the 'write' method.
Attributes:
Name | Type | Description |
---|---|---|
path |
Python path instance to an EEG data file. |
|
mode |
A str mode for writing the eeg file. Must be 'r' for plain text files and 'rb' for binary files. |