Skip to main content

xptools

PyPI version

Analysis tools for experimental sciences to display images, detect particles (cells, bubbles, crystals), moving fronts and analyze their shape, size and distibution.

Installation

xptools is on PyPI so you can install it straight from pip with the command

pip install xptools

Alternatively, you can clone the repository to your local computer and install from source

git clone https://github.com/hlgirard/xptools
cd xptools
pip install .

Scripts

  • analyze_front - This scipt takes a directory containing video files. For each file, it asks the user to select a region of interest and processes the selected area with a minimum threshold to find the largest area. It then plots the height of this area as a function of time.
analyze_front --plotly --scale 60 --framerate 30 moviedirectory/

screenshot

  • analyze_bubbles - This script takes a movie (or directory of movies) showing bubbles on a surface (bright on dark). It uses a watershed segmentation algorithm to identify the bubbles and characterize their size. It then plots the bubble density and mean size as a function of time.
analyze_bubbles --plotly --scale 60 bubble_movie.avi

screenshot

  • analyze_crystals - This script takes a directory containing pictures of droplets containing crystals (under cross polarization). It uses a thresholding algorithm to segment the crystals, count them and measure their size.
analyze_crystals --plotly --key funct_key.txt imagedirectory/

screenshot

  • display_image_matrix - Arranges all the images in a directory as a matrix and saves the resulting image
display_image_matrix --lines 10 --compress imagedirectory/

Utilities

Several utilities are included in the submodule utils including:

  • select_roi:select_rectangle - Prompts the user to make a rectangular selection on the passed image and returns the coordinates of the selection.

  • videotools:open_video - Opens a video file as a list of np.arrays each containing one frame of the video.

  • videotools:determine_threshold - Determines the threshold to use for a video based on the minimum threshold algorithm.

  • videotools:obtain_cropping_boxes - Prompts the user to select the region of interest for each video file. Returns a dataframe containing the coordinates of the selected area for each file.

  • imagetools:open_all_images - Opens all the images in a folder and returns a list of cv2 images.

Example usage

import pandas as pd
from xptools.utils import videotools

video_list = ['Film1.avi','Film2.avi']

dict_crop = videotools.obtain_cropping_boxes(video_list)

for key, val in dict_crop:
    stack = videotools.open_video(key)
    (minRow, minCol, maxRow, maxCol) = val
    stack = [img[minRow:maxRow,minCol:maxCol] for img in stack]
    process(stack)

Notebooks

  • SegmentationBroadSpectrum.ipynb - Tests different image segmentation techniques to determine which is most appropriate
  • SegmentationFocused.ipynb - Implements a specific analysis and plots the resulting size and number distributions for the particles
  • Watershed_Segmentation.ipynb - Implements Watershed segmentation.

Credits

Code for display_image_matrix adapted from https://gist.github.com/pgorczak/95230f53d3f140e4939c#file-imgmatrix-py

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Release files for xptools 0.38.post1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for xptools 0.38.post1
File Interpreter ABI Platform
xptools-0.38.post1-py3-none-any.whl Python 3 none any Details

Release files / xptools-0.38.post1-py3-none-any.whl

Download URL xptools-0.38.post1-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4c27ab039ff0b147a9e3c6838846fc2036f1c07d4b7f84cc154cb65a7bfb3c5
BLAKE2b-256 checksum
How to use checksums
2682011ee3d2f5324e49183b0b092ac0b0873d19b717476cae45691b763f0c93
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1

Release history Release notifications | RSS feed

This release

0.38.post1 This release

1 release file

0.38

1 release file

0.37

1 release file

0.36

1 release file

0.35

1 release file

0.3

2 release files

0.2

2 release files

0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page