Skip to content

Commit b10e0d8

Browse files
authored
Merge pull request #3 from thennen/fix-module-file-structure
Fix module file structure
2 parents a951445 + 40b9eca commit b10e0d8

10 files changed

+51
-21
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

+17-7
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,44 @@
22

33
This project is a set of functions to automate the counting and categorization of molecules, specifically tailored for data generated from low temperature scanning probe microscopes.
44

5-
We wrote about our approach to this problem here: <CITE ARTICLE>
5+
We wrote about our approach to this problem at [this ArXiv article to be posted](arxiv.org/abs/).
66

77
The functionality of this code was used to generate Fig. 3 of [this publication.](https://onlinelibrary.wiley.com/doi/abs/10.1002/anie.201812334)
88

99
## Getting Started
1010

1111
This is a glorified script that makes use of existing python libraries. Written in python 3+, if unsure, start by installing [Anaconda](https://www.anaconda.com/download).
1212

13-
### Prerequisites
13+
### Dependencies
1414

1515
* [Python 3+](https://www.anaconda.com/download)
1616
* [SciPy](https://www.scipy.org/)
1717
* [NumPy](http://www.numpy.org/)
1818
* [Matplotlib](https://matplotlib.org/)
19+
* [matplotlib-scalebar](https://pypi.org/project/matplotlib-scalebar/)
1920
* [Scikit-image](https://scikit-image.org/)
2021
* [Scikit-learn](https://scikit-learn.org/stable/)
21-
* [Nanonispy](http://ysebastien.me/nanonispy-my-first-python-package.html)
22+
* [Nanonispy](https://github.com/underchemist/nanonispy)
2223
* [Mahotas](https://mahotas.readthedocs.io/en/latest/)
2324

2425
### Installing
2526

26-
Clone this repository.
27+
Clone this repository, navigate to said directory, and run:
28+
29+
```
30+
pip install .
31+
```
2732

2833
### Examples
2934

30-
`Helicene_example`, `APT_example` and `APT_2_example` are three example scripts that generate the figures in <CITE ARTICLE>.
35+
`Helicene_example`, `APT_example` and `APT_2_example` are three example scripts that generate the figures in [the ArXiv article to be posted](arxiv.org/abs/).
36+
37+
Steps to reproduce:
38+
39+
1. Download the data files from this [figshare repo](https://doi.org/10.6084/m9.figshare.19217556) into the examples folder.
40+
2. Run the individual script files in the examples folder to generate each figure.
41+
3142

32-
The data files they analyze can be downloaded [here](some data dump URL).
3343

3444
## Versioning
3545

@@ -46,6 +56,6 @@ This project is licensed under the MIT License.
4656

4757
## Acknowledgements
4858

49-
This project was inspired by the need to analyze the data that eventually resulted in [this publication.](https://onlinelibrary.wiley.com/doi/abs/10.1002/anie.201812334).
59+
This project was inspired by the need to analyze the data that eventually resulted in [this publication](https://onlinelibrary.wiley.com/doi/abs/10.1002/anie.201812334).
5060
We also made use of the data available from [this work.](https://www.nature.com/articles/nchem.2662)
5161
This happened at the [Nanosurf lab.](https://nanosurf.fzu.cz/)

counting_molecules/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__pycache__/

counting_molecules/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from .counting_molecules import *

counting_molecules.py renamed to counting_molecules/counting_molecules.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from skimage.filters import gaussian, threshold_otsu, threshold_local
3030
from skimage.measure import find_contours
3131

32-
import pairwise_chirality
32+
from . import pairwise_chirality
3333

3434
### read sxm file, requires nanonispy
3535

@@ -467,15 +467,8 @@ def manual_resorting(pickle_file=None, filename=None, im=None, contours=None, pa
467467

468468
extent = (0, im.shape[1]*rescale[1], im.shape[0]*rescale[0], 0)
469469
ax.imshow(im, cmap='gray', extent=extent) #, vmin=np.amin(im)*.1)
470-
471-
ax.axis('off')
472-
473-
font_properties = dict()
474-
font_properties['size'] = 12
475-
scalebar = ScaleBar(dx=1, units='m', length_fraction=.5,
476-
font_properties=font_properties, frameon=False, location=4, color='w')
477-
478-
ax.add_artist(scalebar)
470+
ax.set_xlabel('x (m)')
471+
ax.set_ylabel('y (m)')
479472

480473
cmap = matplotlib.cm.get_cmap('viridis')
481474
cmap2 = matplotlib.cm.get_cmap('plasma_r')
@@ -646,8 +639,8 @@ def default_sort(filename, sort_by_chirality=False):
646639
""" Saves png images of sorted molecule histogram using default sorting parameters. """
647640
im, rescale = read_data(filename)
648641
im = filter_image(im)
649-
contours, otsu_output, templates, contour_lengths, max_pixels, zernike_moments = get_contours(im, rescale=rescale, minimum_separation=0)
650-
sorted_labels = sort_contours(zernike_moments, damping=.3, method='Birch')
642+
contours_dict = get_contours(im, rescale=rescale, minimum_separation=0)
643+
sorted_labels = sort_contours(contours_dict['zernike_moments'], damping=.3, method='Birch')
651644
if sort_by_chirality == True:
652-
sorted_labels = sort_chirality(templates, sorted_labels)
653-
plot_contours_histogram(im, contours, rescale, sorted_labels, saveplot=True, filename=filename)
645+
sorted_labels = sort_chirality(contours_dict['templates'], sorted_labels)
646+
plot_contours_histogram(im, contours_dict['contours'], contours_dict['rescale'], sorted_labels, saveplot=True, filename=filename)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

setup.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env python
2+
3+
from setuptools import setup, find_packages
4+
5+
with open("README.md", "r", encoding="utf-8") as fh:
6+
long_description = fh.read()
7+
8+
version = '0'
9+
10+
setup(
11+
name='counting_molecules',
12+
version=version,
13+
author='Jack Hellerstedt and Tyler Hennen',
14+
author_email='[email protected]',
15+
description='Library to count molecules in STM images',
16+
long_description=long_description,
17+
url='https://github.com/thennen/counting-molecules',
18+
project_urls = {
19+
"Bug Tracker": "https://github.com/thennen/counting-molecules/issues"
20+
},
21+
license='MIT',
22+
packages=find_packages(),
23+
install_requires=['numpy', 'matplotlib', 'matplotlib_scalebar', 'nanonispy', 'mahotas', 'scipy', 'scikit-image', 'sklearn'],
24+
)

0 commit comments

Comments
 (0)