I/O¶
On-disk RF storage and interchange. RFDataset is the internal, crash-safe
checkpoint format (one compressed .npz per TX event); save_rf_hdf5 exports a
self-describing, UFF/MATLAB-compatible HDF5 file.
RFDataset¶
RFDataset
¶
Resumable folder of per-event RF files with a JSON contents file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Dataset folder. Created if missing. |
required |
config
|
dict
|
Configuration identifying the simulation (see |
None
|
meta
|
dict
|
Free-form JSON-serializable info stored once at creation
(e.g. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
write_event
¶
Atomically store one TX event's RF and mark it completed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
TX event index in the sequence. |
required |
rf
|
(Erx, Nt) numpy.ndarray
|
Per-receive-channel RF of this event. |
required |
t0
|
float
|
Beam-axis time reference of this event (s), as returned by the reception simulator: echoes peak at their geometric round-trip time. |
required |
dt
|
float
|
Sample period (s). |
required |
**info
|
Extra JSON-serializable fields recorded in the contents file
(e.g. |
{}
|
read_event
¶
Load one event's RF.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int
|
TX event index. |
required |
verify
|
bool
|
Re-hash the file and compare with the contents file checksum. |
False
|
Returns:
| Name | Type | Description |
|---|---|---|
rf |
(Erx, Nt) numpy.ndarray
|
Per-receive-channel RF of the event. |
t0 |
float
|
Beam-axis time origin of the first sample (s). |
dt |
float
|
Sample period (s). |
Raises:
| Type | Description |
|---|---|
KeyError
|
If the event is not in the contents file. |
ValueError
|
If |
load_all
¶
Assemble all completed events into the sequence_rf return format.
Traces are zero-padded at the end to the longest event (only the
time origin differs between events; dt is shared).
When the dataset was written with checkpoint_chunks > 1 (each TX
event split into scatterer chunks, one file per chunk), the chunk RFs
of each event share one time grid and are summed here — the RF is
linear in the scatterers, so the sum equals the unchunked event.
Returns:
| Name | Type | Description |
|---|---|---|
rf |
(N_events, Erx, Nt) numpy.ndarray
|
Per-event, per-channel RF (float32). |
coords |
dict
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dataset has no completed events, or if it is chunked and not yet complete (partial chunk groups cannot be summed). |
to_hdf5
¶
Export the whole dataset to one interchange HDF5 file.
Consolidates the per-event .npz checkpoint store into a single
self-describing .h5 (channel data + timing) that MATLAB, USTB and
other Python tools read natively — see save_rf_hdf5.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Output |
required |
probe_geometry_mm
|
(Erx, 3) numpy.ndarray
|
Receive-element centres in mm, stored so the file is beamformable on its own. |
None
|
sound_speed
|
float
|
Speed of sound (m/s) recorded in the file. |
1540.0
|
Returns:
| Type | Description |
|---|---|
Path
|
The written file path. |
summary
¶
Human-readable status table (also returned as a string).
Returns:
| Type | Description |
|---|---|
str
|
The status table text (printed and returned). |
save_rf_hdf5¶
save_rf_hdf5
¶
save_rf_hdf5(
path,
rf: NDArray[floating],
coords: dict,
*,
probe_geometry_mm: NDArray[floating] | None = None,
sound_speed: float = 1540.0,
meta: dict | None = None,
) -> Path
Write per-channel RF and its timing to a single HDF5 file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Output |
required |
rf
|
(N_events, Erx, Nt) or (Erx, Nt) numpy.ndarray
|
Per-event, per-receive-channel RF, as returned by |
required |
coords
|
dict
|
Timing from the reception simulator / |
required |
probe_geometry_mm
|
(Erx, 3) numpy.ndarray
|
Receive-element centres in mm ( |
None
|
sound_speed
|
float
|
Speed of sound (m/s), stored as the |
1540.0
|
meta
|
dict
|
Any extra JSON-serializable acquisition info; stored as a JSON string
in the |
None
|
Returns:
| Type | Description |
|---|---|
Path
|
The written file path. |