Giter VIP home page Giter VIP logo

afmreader's Introduction

AFMReader

PyPI version PyPI - Python Version Code style: Ruff Code style: black Code style: flake8

pre-commit.ci status

A library for loading various Atomic Force Microscopy (AFM) file formats into Python. This library is primarily intended for use with TopoStats.

Supported file formats

File format Description
.asd High-speed AFM
.ibw WaveMetrics
.spm Bruker's Format
.jpk Bruker
.topostats TopoStats
.gwy [Gwydion] (http://gwyddion.net)

Support for the following additional formats is planned. Some of these are already supported in TopoStats and are awaiting refactoring to move their functionality into AFMReader these are denoted in bold below.

File format Description Status
.nhf Nanosurf To Be Implemented.
.aris Imaris Oxford Instruments To Be Implemented.
.tiff Park Systems To Be Implemented.

Usage

If you wish to process AFM images supported by AFMReader it is recommend you use TopoStats to do so, however the library can be used on its own.

.topostats

You can open .topostats files using the load_topostats function. Just pass in the path to the file.

from AFMReader.topostats import load_topostats

image, pixel_to_nanometre_scaling_factor, metadata = load_topostats(file_path="./my_topostats_file.topostats")

.spm

You can open .spm files using the load_spm function. Just pass in the path to the file and the channel name that you want to use. (If in doubt use one of the following: "Height", "ZSensor", "Height Sensor").

from AFMReader.spm import load_spm

image, pixel_to_nanometre_scaling_factor = load_spm(file_path="./my_spm_file.spm", channel="Height")

.gwy

You can open .gwy files using the load_gwy function. Just pass in the path to the file and the channel name that you want to use. (If in doubt use one one of the following: "Height", "ZSensor", "Height Sensor").

from AFMReader.gwy import load_gwy

image, pixel_to_nanometre_scaling_factor = load_gwy(file_path="./my_gwy_file.gwy", channel="Height")

.asd

You can open .asd files using the load_asd function. Just pass in the path to the file and the channel name that you want to use. (If in doubt use the "TP" topography channel).

Note: For .asd files, there seem to only ever be two channels in one file. "TP" (topography) is the main one you will want to use unless you know you specifically want something else.

Other channels: "ER" - Error, "PH" - Phase

from AFMReader.asd import load_asd

frames, pixel_to_nanometre_scaling_factor, metadata = load_asd(file_path="./my_asd_file.asd", channel="TP")

.ibw

You can open .ibw files using the load_ibw function. Just pass in the path to the file and the channel name that you want to use. (If in doubt, use HeightTracee (yes, with the extra 'e'), ZSensorTrace, or ZSensor).

from AFMReader.ibw import load_ibw

image, pixel_to_nanometre_scaling_factor = load_ibw(file_path="./my_ibw_file.ibw", channel="HeightTracee")

.jpk

You can open .jpk files using the load_jpk function. Just pass in the path to the file and the channel name you want to use. (If in doubt, use height_trace or measuredHeight_trace).

from AFMReader.jpk import load_jpk

image, pixel_to_nanometre_scaling_factor = load_jpk(file_path="./my_jpk_file.jpk", channel="height_trace")

Contributing

Bug reports and feature requests are welcome. Please search for existing issues, if none relating to your bug/feature are found then feel free to create a new issue detailing what went wrong or the feature you would like to see implemented.

Pull requests are also welcome, please note that we have a Code of Conduct.

Setup

We use pre-commit to apply linting via ruff and pylint pre-commit hooks and use the Black and Flake8 code styles. To set yourself up for contributing after cloning the package and creating a Python virtual environment you should install the development dependencies and pre-commit as shown below.

# Activate your virtual environment, this will depend on which system you use e.g. conda or virtualenvwrapper
# Clone the repository
git clone [email protected]:AFM-SPM/AFMReader.git
# Change directories into the newly cloned directory
cd AFMReader
# Install the package along with the optional development (dev) dependencies
pip install -e .[dev]
# Install pre-commit
pre-commit install

This will ensure that any commits and pull requests you make will pass the Pre-commit Continuous Integration. Where possible ruff will correct the changes it can, but it may require you to address some issues manually, before adding any changes and attempting to commit again.

afmreader's People

Contributors

sylviawhittle avatar ns-rse avatar pre-commit-ci[bot] avatar ahobbs7 avatar maxgamill-sheffield avatar slackline avatar

Stargazers

warm tan avatar  avatar Yasuhiro Matsunaga avatar  avatar

Watchers

Alice Pyne avatar  avatar

afmreader's Issues

Build documentation in Sphinx

Should include...

  • Overview
  • Supported File Formats
  • Usage
  • Contributing Guidelines
  • API
  • Multiple versions

Deploy either on GitHub Pages (in which case use sphinx multiversion) or ReadTheDocs.org in which case a unique .readthedocs.yaml is required and the account configuration should indicate which versions the documentation should be built for.

[feature] : ASD - Add support for 9.99 volt images

Is your feature request related to a problem?

A collaborator sent over a file that cannot be loaded using our .asd reader, as its analogy-digital range hex value is 0x00000003 which has not yet been added to the list of known values. Strangely, when experimenting with this file, the voltage range is 0 to 9.99 volts (precisely this value, no more, no less else the image height scales break).

Describe the solution you would like.

Add an option in the asd loader for the 0x00000003 hex code and corresponding unipolar voltage range 0 - 9.99V. I have MVP code, just needs cleaning up.

Describe the alternatives you have considered.

N/A

Sample Image

I do not have permission to share the image, but I have a working fix, so I just need to formalise it.

Additional context

No response

[chore] : Bump minimum python version

Python 3.8 reaches end of life in 2024-10 and is currently in security mode.

We should bump the minimum version AFMReader depends on along with the other tools (e.g. black and ruff config) in pyproject.toml.

[chore] : Split test and development dependencies

In TopoStats we have separate [project.optional-dependencies] sections for dev, test and pypi as its possible some may want to run tests but not publish to PyPI.

We should perhaps consider splitting the optional dependencies here too so that installs only pull in what is required.

Suggest the following which adds build to pip (required if manually building the package locally rather than relying on CI) and pre-commit to dev.

[project.optional-dependencies]
dev = [
  "black",
  "pre-commit",
  "pylint",
  "ruff",
]
pip = [
  "build",
  "setuptools_scm[toml]",
  "wheel",
]
tests = [
  "pytest",
  "pytest-cov",
]

Caveat - its arguable that if someone is developing tests they should also have dev installed so that code is linted and passes pre-commit.ci, but don't want to force people to adopt this from the off.

Add test case for asd file version 2

Currently we only have tests verifying that file types 0 and 1 will load properly. I did not add one for file version 2 as I could not find any files for version 2.

I should ask around to see if anybody has a file of version 2.

Automate tests in CI

It would be useful to have tests run automatically in GitHub Workflows as part of the Continuous Integartion to ensure
that changes and new features do not break anything.

Apply a License to the code

We need a license to be applied to the code, otherwise it is not openly licensed.

Suggest GNU GPLv3 to align with TopoStats.

Add pre-commit and linting

It would be useful/beneficial to apply the same suite of pre-commit hooks to this repository
as we do to TopoStats to ensure consistent coding styles and standards. Similarly integrating
pre-commit.ci to the Continuous Integration would also make sense.

[feature] : Rename package to AFMReader

Is your feature request related to a problem?

It has been suggested by Alice that this repo be renamed to AFMFileFormats as this may be more representative. Is this possible? Are there metadata that cannot change? Likely the PyPI identifier?

Describe the solution you would like.

Rename the repo to afmfileformats along with the PyPI identifier if possible. Discuss before doing it.

Describe the alternatives you have considered.

Not renaming it if this isn't possible or if remnants of the old name would cause confusion for users.

Sample Image

No response

Additional context

No response

Tasks

  • Rename GitHub repository (and update local clones configuration of origin to point to the renamed repository).
  • Update package...
    • pyproject.toml
    • CITATION.cff (don't currently have one though!).
    • topofileformats > AFMReader for package directory.
    • Update all import topofileformats to import AFMReader (files include AFMReader/*.py, tests/test_*.py, README.md, examples/example_01.ipynb).
  • Upload renamed package AFMReader to PyPI
  • Update topofileformats to have a single dependency AFMReader so that the new package is installed if anyone tries to install the old package.
    • Publish updated package to PyPI. Opted to delete topofileformats from PyPI completed by @SylviaWhittle 2024-06-05 15:22
  • Update TopoStats to depend on AFMReader rather than topofileformats see #22 instead.

[feature] : Add topostats file format support

Is your feature request related to a problem?

Migrate the .topostats (HDF5 format) file format reader from TopoStats to AFMReader. This is the initial proposal for an open & interoperable AFM file format in HDF5 standard for AFM images. It will be iterated upon and likely re-designed but we need something to start with.

Describe the solution you would like.

Migrate the .topostats file format to AFMReader as-is.

Describe the alternatives you have considered.

N/A

Sample Image

N/A

Additional context

No response

Migrate IO class from TopoStats

We should migrate the functionality in the topostats.io.LoadScan class from TopoStats to topofileformats AFMReader.

This will supersede issues #1 , #16 and #17 which are all file formats that are currently supported by TopoStats.

The migration should be done in two stages...

  • Firstly copy the class and methods over to topofileformats `AFMReader along with tests and ensure that the functionality works as a stand alone aspect of this package.
    • .asd (in-progress see comment below)
    • .ibw
    • .gwy (in-progress, PR due soon 2024-05-07).
    • .jpk
    • `.spm
    • .topostats
  • Remove the use of topostats.io.LoadScan from TopoStats and instead import the class from topofileformats.io.LoadScan AFMReader.io.LoadScan.

Another thing to consider is to integrate the current .asd support into the migrated class and make it a method available in the LoadScan class.

[feature] : Automate publishing to PyPI

Is your feature request related to a problem?

We should use the .github/workflows/pypi.yaml workflow/GitHub Action to automate publishing of AFMReader to PyPI when new tags are applied to this repository of the form v#.#.#.

Describe the solution you would like.

Making a release with a tag of the form v#.#.# should trigger publishing to PyPI via GitHub Action.

Describe the alternatives you have considered.

Could be done manually but this is a chore, once setup it "Just Works(tm)".

Sample Image

N/A

Additional context

N/A

Implement logging

Currently progress is reported using print() it would be good to have true logging implemented that indicates the stage and function each command comes from.

Two options...

Lint existing code base

Further to #5 and #6 we should lint the existing code base.

I have this waiting in the wings but want to keep it separate from introducing the configuration files so that the
changes can be added to .git-blame-ignore-revs (see Who's to Blame?).

[feature] : Migrate .jpk support from topostats

Is your feature request related to a problem?

No response

Describe the solution you would like.

Add support for the jpg file format as laid out in topostats

Describe the alternatives you have considered.

No response

Sample Image

No response

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.