Command line programmes are searched for in order looking along the paths in $PATH.
A “virtual environment” is an isolated set of commands that take precedence over system commands.
You can have multiple virtual environments and switch between them.
Create and Activate Virtual Environment
echo$PATH# Locations programmes are searched for BEFOREwhich python # Show version of python used BEFOREconda create --name topostats-git python=3.10conda activate topostats-gitecho$PATH# Show locations programmes are searched for AFTERwhich python # Show version of python used AFTER
Virtual Environments
Version Control… a digression
Hopefully you have already…
Setup GitHub account (https://github.com) using University email address.
Downloaded and installed GitKraken using GitHub account associated with University email address.
GitHub is an online service which hosts software projects and facilitates…
Distributed software development
Tracking bugs/features
Project management
GitKraken is a client that interfaces to Git and GitHub and communicates between the two.
Git & GitHub
Cloning TopoStats
We’ll now clone TopoStats using GitKraken.
File > Clone Repository (Ctrl + N)
GitHub.com
Select directory to clone to.
Under Repository to Clone start typing TopoStats
Select TopoStats
Clone the repo!
Installing TopoStats under Virtual Environments
We have…
Setup and activated a Virtual Environment.
Cloned the TopoStats repository.
Next…
Install TopoStats from cloned repository.
Installing TopoStats under Virtual Environments
cd ~/tmp/topostats-tutorial/TopoStatswhich pythonconda activate topostats-gitgit statuspip install -e .[notebooks] # Install additional requirements e.g. .[tests]run_topostats-h
run_topostats -h
❱ run_topostats -husage: run_topostats [-h] [-c CONFIG_FILE] [--create-config-file CREATE_CONFIG_FILE] [-s SUMMARY_CONFIG] [-b BASE_DIR] [-j CORES] [-l LOG_LEVEL] [-f FILE_EXT][--channel CHANNEL] [-o OUTPUT_DIR] [--save_plots SAVE_PLOTS] [-m MASK] [-q QUIET] [-v] [-w WARNINGS]Process AFM images. Additional arguments over-ride those in the configuration file.options:-h,--help show this help message and exit-c CONFIG_FILE, --config_file CONFIG_FILEPath to a YAML configuration file.--create-config-file CREATE_CONFIG_FILEFilename to write a sample YAML configuration file to (should end in '.yaml').-s SUMMARY_CONFIG, --summary_config SUMMARY_CONFIGPath to a YAML configuration file for summary plots and statistics.-b BASE_DIR, --base_dir BASE_DIRBase directory to scan for images.-j CORES, --cores CORESNumber of CPU cores to use when processing.-l LOG_LEVEL, --log_level LOG_LEVELLogging level to use, default is 'info' for verbose output use 'debug'.-f FILE_EXT, --file_ext FILE_EXTFile extension to scan for.--channel CHANNEL Channel to extract.-o OUTPUT_DIR, --output_dir OUTPUT_DIROutput directory to write results to.--save_plots SAVE_PLOTSWhether to save plots.-m MASK, --mask MASK Mask the image.-q QUIET, --quiet QUIETToggle verbosity.-v,--version Report the current version of TopoStats that is installed.-w WARNINGS, --warnings WARNINGSWhether to ignore warnings.
run_topostats -q
(topostats)❱ run_topostats --log_level warning[Mon, 13 Mar 2023 14:01:01] [INFO ] [topostats] Updated config config[log_level] : info > warningProcessing images from /home/neil/work/projects/topostats/TopoStats, results are under output: 100%|████████|1/1 [00:00<?, ?it/s]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ COMPLETE ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~TopoStats Version : 2.0.1.dev384+g365c6dd.d20230310Base Directory : /home/neil/work/projects/topostats/TopoStatsFile Extension : .spmFiles Found : 1Successfully Processed^1 : 1 (100.0%)Configuration : output/config.yamlAll statistics : output/all_statistics.csvDistribution Plots : output/summary_distributionsEmail : topostats@sheffield.ac.ukDocumentation : https://afm-spm.github.io/topostats/Source Code : https://github.com/AFM-SPM/TopoStats/Bug Reports/Feature Request : https://github.com/AFM-SPM/TopoStats/issues/new/chooseCitation File Format : https://github.com/AFM-SPM/TopoStats/blob/main/CITATION.cff^1 Successful processing of an image is detection of grains and calculation of at leastgrain statistics. If these have been disabled the percentage will be 0.If you encounter bugs/issues or have feature requests please report them at the above URLor email us.If you have found TopoStats useful please consider citing it. A Citation File Format islinked above and available from the Source Code page.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
run_topostats --create-config-file
run_topostats--create-config-file dummy_config.yaml[Fri, 10 Mar 2023 20:09:26] [INFO ] [topostats] The YAML configuration file is valid.[Fri, 10 Mar 2023 20:09:26] [INFO ] [topostats] A sample configuration has been written to : dummy_config.yaml[Fri, 10 Mar 2023 20:09:26] [INFO ] [topostats] Please refer to the documentation on how to use the configuration file :https://afm-spm.github.io/TopoStats/usage.html#configuring-topostatshttps://afm-spm.github.io/TopoStats/configuration.html❱ cat ~/tmp/dummy_config.yaml# Sample configuration file auto-generated : 2023-03-10 20:09:26base_dir: /home/neil/work/git/hub/design-patternsoutput_dir: outputlog_level: infocores: 2file_ext: .spmloading:channel: Heightfilter:run: truerow_alignment_quantile: 0.5threshold_method: std_devotsu_threshold_multiplier: 1.0threshold_std_dev:lower: 10.0upper: 1.0threshold_absolute:lower:-1.0upper: 1.0gaussian_size: 1.0121397464510862gaussian_mode: nearestremove_scars:run: trueremoval_iterations: 2threshold_low: 0.25threshold_high: 0.666max_scar_width: 4min_scar_length: 16grains:run: truethreshold_method: std_devotsu_threshold_multiplier: 1.0threshold_std_dev:lower: 10.0upper: 1.0threshold_absolute:lower:-1.0upper: 1.0direction: uppersmallest_grain_size_nm2: 50absolute_area_threshold:upper:- 300- 3000lower:--grainstats:run: trueedge_detection_method: binary_erosioncropped_size: 40.0dnatracing:run: trueplotting:run: truesave_format: pngimage_set: corezrange:--colorbar: trueaxes: truecmap: nanoscopemask_cmap: bluhistogram_log_axis: falsehistogram_bins: 200summary_stats:run: trueconfig:
You can use GitKraken to switch branches use switch to topostats-git.
Make sure you re-install TopoStats after switching branches (sometimes pip install -e .doesn’t pick up the changes Git makes).
cd ~/tmp/TopoStatspip install -e .
Re-run run_topostats
Re-run run_topostats
Traceback(most recent call last):File"/home/neil/.virtualenvs/topostats/bin/run_topostats", line 8, in <module>sys.exit(main())File"/home/neil/work/projects/topostats/TopoStats/topostats/run_topostats.py", line 213, in mainprint(f"Can we divide 5 by 0? {5/0}")ZeroDivisionError: division by zero
GitHub - Reporting Issues
Reporting bugs helps with feature development.
Removes them not just for you but for all users.
Can seem cumbersome at first but it gets easier with practice.
Install TopoStats and include the test dependencies.
Run the test suite with pytest
Exercise 1 - Tests (Solution)
conda create --name test python=3.10git checkout topostats-test # This is the commandline version, use GitKraken to switchpip install -e .[tests] # Install the test dependencies as wellpytest
conda create --name test python=3.10git checkout topostats-test # This is the commandline version, use GitKraken to switchpip install -e .[tests] # Install the test dependencies as welljupyter notebook
Jupyter Notebooks
Interactive execution of Python Code.
Early development.
Walk-through for running TopoStats (00-Walthrough-minicircle.ipynb)
Summary Statistics and Plotting (02-Summary-statistics-and-plots.ipynb)
Plotting Scans (03-Plotting-scans.ipynb)
Try going through them to process images (some require run_topostats) to have been run.