Skip to content

Commit dcf1036

Browse files
pierrot0The TensorFlow Datasets Authors
authored andcommitted
Fix duke_ultrasound dataset timestamp_id from %Y%m%d%H%M%S to posix timestamp.
PiperOrigin-RevId: 668520921
1 parent baa7fe0 commit dcf1036

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tensorflow_datasets/datasets/duke_ultrasound/duke_ultrasound_dataset_builder.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"""DAS beamformed phantom images and paired clinical post-processed images."""
1717

1818
import csv
19+
import datetime
1920
import os
20-
2121
from etils import epath
2222
import numpy as np
2323
from tensorflow_datasets.core.utils import bool_utils
@@ -44,6 +44,7 @@ class Builder(tfds.core.GeneratorBasedBuilder):
4444

4545
VERSION = tfds.core.Version('1.0.1')
4646
RELEASE_NOTES = {
47+
'2.0.0': r'Fix timestamp_id from %Y%m%d%H%M%S to posix timestamp.',
4748
'1.0.1': 'Fixes parsing of boolean field `harmonic`.',
4849
'1.0.0': 'Initial release.',
4950
}
@@ -124,6 +125,11 @@ def _generate_examples(self, datapath, csvpath):
124125
iq = iq / iq.max()
125126
iq = 20 * np.log10(iq)
126127

128+
timestamp_id = datetime.datetime.strptime(
129+
row['timestamp_id'], '%Y%m%d%H%M%S'
130+
)
131+
timestamp = int(timestamp_id.timestamp())
132+
127133
yield row['filename'], {
128134
'das': {
129135
'dB': iq.astype(np.float32),
@@ -143,6 +149,6 @@ def _generate_examples(self, datapath, csvpath):
143149
'probe': row['probe'],
144150
'scanner': row['scanner'],
145151
'target': row['target'],
146-
'timestamp_id': row['timestamp_id'],
152+
'timestamp_id': timestamp,
147153
'harmonic': bool_utils.parse_bool(row['harm']),
148154
}

0 commit comments

Comments
 (0)