Esempio n. 1
0
    def test_convert_defaults(self):
        """Test default behavior"""
        path = convert_to_edf(self.temp_dir)
        self.assertTrue(os.path.exists(path))

        with warnings.catch_warnings():
            warnings.simplefilter('ignore')
            edf = read_raw_edf(path, preload=True)

        self.assertTrue(len(edf.get_data()) > 0)

        for ch_name in ['c1', 'c2', 'c3']:
            self.assertTrue(ch_name in edf.ch_names)
Esempio n. 2
0
def plot_edf(edf_path: str, auto_scale: bool = False):
    """Plot data from the raw edf file. Note: this works from an iPython
    session but seems to throw errors when provided in a script.

    Parameters
    ----------
        edf_path - full path to the generated edf file
        auto_scale - optional; if True will scale the EEG data; this is
            useful for fake (random) data but makes real data hard to read.
    """
    edf = read_raw_edf(edf_path, preload=True)
    if auto_scale:
        edf.plot(scalings='auto')
    else:
        edf.plot()


if __name__ == '__main__':
    import argparse

    parser = argparse.ArgumentParser()
    parser.add_argument(
        '-p',
        '--path',
        help='Path to the directory with raw_data to be converted',
        required=True)
    args = parser.parse_args()
    edf_path = convert_to_edf(args.path)
    print(f"\nWrote edf file to {edf_path}")
Esempio n. 3
0
    def test_overwrite_false(self):
        """Test overwriting fails"""

        convert_to_edf(self.temp_dir)
        with self.assertRaises(OSError):
            convert_to_edf(self.temp_dir, overwrite=False)
Esempio n. 4
0
    def test_with_custom_path(self):
        """Test creating the EDF without event annotations"""
        path = convert_to_edf(self.temp_dir,
                              edf_path=Path(self.temp_dir, 'mydata.edf'))

        self.assertEqual(Path(path).name, 'mydata.edf')
Esempio n. 5
0
    def test_overwrite_true(self):
        """Test that overwriting can be configured"""

        convert_to_edf(self.temp_dir)
        convert_to_edf(self.temp_dir, overwrite=True)