playnano.io.formats.read_asd module

Module to decode and load .asd high-speed AFM data files as an AFMImageStack.

Files containing multiple image frames are read together. Height data (channel ‘TP’) is converted to nm from the guessed source unit.

Timing (per-frame): asd files record a uniform frame time in the header, so timestamp (seconds from frame 0) and frame_duration_s are the same for every frame. Absolute time (start_epoch_ms) is derived from the header date, which is the END of acquisition (the file’s write time), backdated by num_frames * frame_duration_s to place frame 0 at the true start.

Frame direction (scan_direction) is left as None, asd files don’t encode slow-axis direction. Anecdotally, the asd scan_direction is usually topDown (or Ygo).

The asd scan_direction integer in the header encodes an acquisition mode plus channel-1 fast-axis direction, although I’ve not found formal documentation of this. The raw value, file version and channel signature are preserved in stack.acquisition for later decoding.

playnano.io.formats.read_asd.load_asd_file(file_path: Path | str, channel: str) → AFMImageStack[source]

Load an .asd HS-AFM file into an AFMImageStack, with height data in nm.

Parameters:
  • file_path (Path | str) – Path to the .asd file.

  • channel (str) – Channel to extract (‘TP’ topography, ‘ER’ error, or ‘PH’ phase).

Returns:

Loaded stack.

Data is held in data as a 3D array (N, H, W). The stack’s pixel_size_nm is the constant pixel size in nanometres, and channel is the channel name.

Per-frame frame_metadata populates timestamp, frame_pixel_size_nm, line_rate, frame_duration_s and start_epoch_ms; scan_direction stays None.

Stack-level acquisition records asd-specific provenance: asd_file_version, asd_scan_direction_raw (undecoded int), asd_channels (tuple). bidirectional is not set, asd files don’t encode slow-axis alternation.

Return type:

AFMImageStack