|
41 | 41 | ) |
42 | 42 | from pyceps.datatypes.signals import Trace |
43 | 43 | from pyceps.visualize import get_dash_app |
| 44 | +from pyceps.utils import console_progressbar |
44 | 45 |
|
45 | 46 |
|
46 | 47 | TEPStudy = TypeVar('TEPStudy', bound='EPStudy') # workaround to type hint self |
@@ -916,37 +917,39 @@ def export_point_ecg( |
916 | 917 | output_folder = self.resolve_export_folder(output_folder) |
917 | 918 | basename = os.path.join(output_folder, self.name) |
918 | 919 |
|
919 | | - # prepare data |
920 | | - data = np.full((len(points), 2500, len(which)), |
921 | | - np.nan, |
922 | | - dtype=np.float32) |
923 | | - |
924 | | - # append point ECG data |
925 | | - for i, point in enumerate(points): |
926 | | - point_data = np.array( |
927 | | - [t.data for t in point.ecg for chn in which if t.name == chn] |
928 | | - ) |
929 | | - data[i, :, :] = point_data.T |
930 | | - |
931 | | - # save data channel-wise |
932 | 920 | writer = FileWriter() |
933 | | - for i, channel in enumerate(which): |
934 | | - channel_data = data[:, :, i] |
| 921 | + for n, chn in enumerate(which): |
| 922 | + # prepare data |
| 923 | + data = np.full((len(points), 2500), |
| 924 | + np.nan, |
| 925 | + dtype=np.float32) |
| 926 | + |
| 927 | + for i, point in enumerate(points): |
| 928 | + point_data = np.array( |
| 929 | + [t.data for t in point.ecg if (t.name == chn)] |
| 930 | + ) |
| 931 | + data[i, :] = point_data |
| 932 | + |
935 | 933 | # save data to igb |
936 | 934 | # Note: this file cannot be loaded with the CARTO mesh but rather |
937 | 935 | # with the exported mapped nodes |
938 | | - header = {'x': channel_data.shape[0], |
939 | | - 't': channel_data.shape[1], |
| 936 | + header = {'x': data.shape[0], |
| 937 | + 't': data.shape[1], |
940 | 938 | 'unites_t': 'ms', |
941 | 939 | 'unites': 'mV', |
942 | 940 | 'dim_t': data.shape[1] - 1, |
943 | 941 | 'org_t': 0, |
944 | 942 | 'inc_t': 1 |
945 | 943 | } |
946 | 944 |
|
947 | | - filename = '{}.ecg.{}.pc.igb'.format(basename, channel) |
948 | | - f = writer.dump(filename, header, channel_data) |
949 | | - log.info('exported ecg trace {} to {}'.format(channel, f)) |
| 945 | + filename = '{}.ecg.{}.pc.igb'.format(basename, chn) |
| 946 | + f = writer.dump(filename, header, data) |
| 947 | + |
| 948 | + # update progress bar |
| 949 | + console_progressbar( |
| 950 | + n + 1, len(which), |
| 951 | + suffix='exported ecg trace {} to {}'.format(chn, f) |
| 952 | + ) |
950 | 953 |
|
951 | 954 | return |
952 | 955 |
|
|
0 commit comments