Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feature] : Return list of available .asd channels #75

Open
MaxGamill-Sheffield opened this issue Nov 13, 2024 · 2 comments
Open

[feature] : Return list of available .asd channels #75

MaxGamill-Sheffield opened this issue Nov 13, 2024 · 2 comments
Labels
enhancement New feature or request v0.1.0

Comments

@MaxGamill-Sheffield
Copy link
Collaborator

Is your feature request related to a problem?

When you've typed in the wrong channel name or it has a typo, it would eb preferable if a list of found channel names could be returned.

Describe the solution you would like.

Something akin to the following which is returned for the wrong channel in ..spm

[minicircle] : dosfbipqeb not in .spm channel list: ['Height Sensor', 'Peak Force Error', 'DMTModulus', 'LogDMTModulus', 'Adhesion', 'Deformation', 'Dissipation', 'Height']

Describe the alternatives you have considered.

Written in the TopoStats issues before AFMReader:
Trying to process a ASD file it was found that it did not have the existing set of channels that we are aware of.

They were instead listed as...

  • 0
  • 20564
  • 21061

Whilst we can add these as possible validated channels for the .asd file format it points to/suggests a wider problem in so much as there may be file specifications in use in the wild that we are not aware of.

To which end attempting to obtain a comprehensive sample of target file formats currently in use and that have been produced in the past would be beneficial so that we can enhance the channels that are supported.

This has scope for being compounded further as hardware manufacturers may change or modify their file specifications.


Would a potential solution be to say if no height channel is found it just
tries to process the first channel in the data?

Sample Image

No response

Additional context

No response

@MaxGamill-Sheffield MaxGamill-Sheffield added the enhancement New feature or request label Nov 13, 2024
@ns-rse ns-rse added the v0.1.0 label Dec 16, 2024
@ns-rse
Copy link
Collaborator

ns-rse commented Dec 16, 2024

Likely fit in at line AFMReader/asd.pyL248

The mentioned TopoStats issue that is quoted is issue #422.

@ns-rse
Copy link
Collaborator

ns-rse commented Feb 4, 2025

This functionality appears to already be present. In AFMReader/asd.py we have within the load_asd.py file on lines 262-266...

        else:
            raise ValueError(
                f"Channel {channel} not found in this file's available channels: "
                f"{header_dict['channel1']}, {header_dict['channel2']}"
            )

...which @SylivaWhittle added in commit #4a3849b5f243c1e1b00eb30dd30c0c380c565233 when the asd file loader was first
added.

from AFMReader import asd
asd_0 = asd.load_asd("tests/resources/sample_0.asd", channel="non-existant-channel")
10:31:14 | INFO |asd.py:asd:read_file_version:310 | file version: 0
10:31:14 | DEBUG |asd.py:asd:load_asd:238 | header dict:
{'channel1': 'TP', 'channel2': 'PH', 'header_length': 131, 'frame_header_length': 32, 'user_name_size': 14, 'comment_offset_size': 88, 'comment_size': 8, 'x_pixels': 256, 'y_pixels': 256, 'x_nm': 200, 'y_nm': 200, 'frame_time': 412.6285705566406, 'z_piezo_extension': 45.0, 'z_piezo_gain': 2.0, 'analogue_digital_range': '0x40000', 'analogue_digital_data_bits_size': 12, 'analogue_digital_resolution': 14, 'is_averaged': True, 'averaging_window': 1, 'year': 2022, 'month': 7, 'day': 15, 'hour': 16, 'minute': 44, 'second': 10, 'rounding_degree': 15, 'max_x_scan_range': 9900.0, 'max_y_scan_range': 4500.0, 'initial_frames': 142, 'num_frames': 142, 'afm_id': 0, 'file_id': 1110, 'user_name': 'biophys', 'scanner_sensitivity': 0.0, 'phase_sensitivity': 0.0, 'scan_direction': 10, 'comment_without_null': 'mica'}
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[29], line 1
----> 1 asd_0 = asd.load_asd("tests/resources/sample_0.asd", channel="non-existant-channel")

File ~/work/git/hub/AFM-SPM/AFMReader/AFMReader/asd.py:263, in load_asd(file_path, channel)
    261     _ = open_file.read(length_of_all_first_channel_frames)
    262 else:
--> 263     raise ValueError(
    264         f"Channel {channel} not found in this file's available channels: "
    265         f"{header_dict['channel1']}, {header_dict['channel2']}"
    266     )
    268 scaling_factor = calculate_scaling_factor(
    269     channel=channel,
    270     z_piezo_gain=header_dict["z_piezo_gain"],
   (...)
    273     phase_sensitivity=header_dict["phase_sensitivity"],
    274 )
    276 analogue_digital_converter = create_analogue_digital_converter(
    277     analogue_digital_range=header_dict["analogue_digital_range"],
    278     scaling_factor=scaling_factor,
    279 )

ValueError: Channel non-existant-channel not found in this file's available channels: TP, PH

...it points to/suggests a wider problem in so much as there may be file specifications in use in the wild that we are
not aware of.

To which end attempting to obtain a comprehensive sample of target file formats currently in use and that have been
produced in the past would be beneficial so that we can enhance the channels that are supported.

This has scope for being compounded further as hardware manufacturers may change or modify their file specifications.

These values are read directly from the file that is being loaded which is a sensible option given we don't know
what channels will be available in a given file. If we were to list all channels across all possible files (which we
don't have access to and are subject to change) we would have to introduce logic to subset that based on the file
version detected which is unnecessary work I feel when we @Sylivawhittle solution grabs the available channels directly.

Does that address this issue ok @MaxGamill-Sheffield?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request v0.1.0
Projects
None yet
Development

No branches or pull requests

2 participants