SPM Modules
For decoding and loading .spm AFM file format into Python Numpy arrays.
get_spm_channels(file_path: Path | str) -> list
Get the list of channels available in the .spm file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path or str
|
Path to the .spm file. |
required |
Returns:
| Type | Description |
|---|---|
list
|
List of available channels. |
Source code in AFMReader/spm.py
load_spm(file_path: Path | str, channel: str) -> AFMScan
Extract image and pixel to nm scaling from the Bruker .spm file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file_path
|
Path or str
|
Path to the .spm file. |
required |
channel
|
str
|
Channel name to extract from the .spm file. |
required |
Returns:
| Type | Description |
|---|---|
AFMScan
|
An AFMScan object containing the image, its pixel to nanometre scaling value, and z-axis units. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the file is not found. |
ValueError
|
If the channel is not found in the .spm file. |
Examples:
Load the image and pixel to nanometre scaling factor, available channels are 'Height', 'ZSensor' and 'Height Sensor'.
>>> from AFMReader.spm import load_spm
>>> afm_scan = load_spm(file_path="path/to/file.spm", channel="Height")
>>> image = afm_scan.image
>>> pixel_to_nm = afm_scan.pixel_to_nanometre_scaling
>>> z_units = afm_scan.z_units
```
Source code in AFMReader/spm.py
spm_pixel_to_nm_scaling(filename: str, channel_data: pySPM.SPM.SPM_image) -> float
Extract pixel to nm scaling from the SPM image metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
File name. |
required |
channel_data
|
SPM_image
|
Channel data from PySPM. |
required |
Returns:
| Type | Description |
|---|---|
float
|
Pixel to nm scaling factor. |