Skip to main content

prevampire

GitHub Tests

PREVAMPIRE is a package made to work in supplementary with the VAMPIRE package. This package contains methods that expedite the user's preparation for the VAMPIRE pipeline, and limits the amount of code interaction needed for someone new to python.

The package was made to turn raw tif images of microglia into numpy arrays so that the vampire package could be applied succesfully. This package also applies and outputs skeletonization on the images after thresholding.

The VAMPIRE package returns a dataframe containing characteristics of each microglia identified within the dataset and return average shape modes.

Cell morphology is used as a support to show the effectivity of therapudics.

Installation

If Python is installed on your machine, type the following line into your command prompt to install via PyPI:

pip install vampire-analysis

Otherwise, clone the package locally and execute below in bash while in the prevampire directory.

python setup.py install

Getting started

Create a file which has all the .tif images you want to analyze.

import prevampire as pv  # recommended import signature
raw_dir = 'file/path'  # file path to .tif images

Applying PREVAMPIRE Package

Below are a list of methods you want to apply to get to the desired skeletonization and vampire df and shape modes. Check out prevampire.py for more in depth method comments.

For a specific dataset, the code uses two .npy arrays to keep track of images while applying thresholding and skeletonization. The image array and the name array. These two arrays are always returned in a specific method.

To go more in depth to skeletonization, check out the Skan package used to find the method desired.

max_imgs, org_names = pv.take_channel(raw_dir, print_image = 1) # maximize image to only include iba

threshall_dir = 'new/file/path' # new file
pv.apply_and_save_all_thresholds(max_imgs, org_names, threshall_dir) # apply all thresholds to a specific subset in the dataset and save them to a defined directory

thresh_imgs, thresh_names = pv.apply_threshold(max_imgs, org_names, label = 'label', method = 'method' print_image = 1) # apply chosen threshold to maximized images (defaults to li)

skel_imgs, skel_names = pv.skeletonize_images(thresh_imgs, thresh_names, print_image = 1) 

skel_df = pv.get_skel_df(skel_imgs, skel_name, show = 1) # get dataframe for skeletonized images

Below are a list of supplementary methods you can use throughout the prevampire pipeline.

thresh_tif_dir = 'new/new/file/path' # new file
pv.save_tif(thresh_imgs, thresh_names, thresh_tif_dir) # save .npy arrays as .tif images in a defined directory

thresh_npy_dir = 'new/new/new/file/path' # new file
pv.save_npy(thresh_imgs, thresh_names, thresh_npy_dir) # save .npy arrays as .npy arrays in a defined directory

thresh_imgs, thresh_names = pv.load_tif_imgs(thresh_tif_dir) # load .tif images as .npy arrays in a defined directory

thresh_imgs, thresh_names = pv.load_npy_imgs(thresh_npy_dir) # load .npy arrays as .npy arrays in a defined directory

pv.display_img_side(thresh_imgs, skel_imgs, 0, 'thresh', 'skel') # put images from respective .npy arrays side to side for comparison

output_dir = 'new/new/new/new/file/path' # new file
pv.save_df(skel_df, 'skel_df', output_dir) # save dataframe in defined directory

Applying to VAMPIRE package

Once you get the thresholded images and names, you can then choose to apply these images to the VAMPIRE package.

import vampire as vp
from vampire import quickstart

## Get VAMPIRE dataframe
copy_thresh_arr = thresh_imgs.copy()
copy_thresh_arr = [item.astype('uint8') for item in copy_thresh_arr] # change to compatible type
vampire_df = vp.extraction.extract_properties_from_img_set(copy_thresh_arr, thresh_names) # get df
pv.save_df(vampire_df, 'vampire_df', output_dir) # saved as .csv file (optionial)

## Get VAMPIRE shape mode
build_info_df = pd.DataFrame({
   'img_set_path': [thresh_tif_dir], # define image directory
   'output_path': [output_dir], # define output directory; saved as .png and .pickle file
   'model_name': ['NAME'],
   'num_points': [np.nan],
   'num_clusters': [np.nan],
   'num_pc': [np.nan],
})

quickstart.build_models(build_info_df, random_state=1) # get shape mode

References

[1] Lin, O. VAMPIRE, (2020), GitHub repository, https://github.com/tengjuilin/vampire-analysis

[2] Lin, C. (2021). Skeletonization and fractal analysis of microglial cells in the neonatal brain. [Doctoral dissertation, University of Washington]. ResearchWorks Archive at the University of Washington. https://digital.lib.washington.edu/researchworks/bitstream/handle/1773/47957/Lin_washington_0250O_23542.pdf?sequence=1&isAllowed=y

[3] Juan Nunez-Iglesias, Adam J. Blanch, Oliver Looker, Matthew W. Dixon, and Leann Tilley. A new Python library to analyse skeleton images confirms malaria parasite remodelling of the red blood cell membrane skeleton. PeerJ, 6:e4312, 2018. doi:10.7717/peerj.4312.

Metadata

Release files for prevampire 0.1.0

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

Source distribution (sdist)

Source distribution for prevampire 0.1.0
File Size Uploaded
prevampire-0.1.0.tar.gz 11.8 kB Details

Built distribution (wheel)

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

Total release size: 22.4 kB

Release files / prevampire-0.1.0.tar.gz

Download URL prevampire-0.1.0.tar.gz
Size 11.8 kB
Tags Source
SHA-256 checksum
How to use checksums
80facdb16aa8500e06bc647f870ca59b26be1e0e82dc4cf59e922fab44b3c487
BLAKE2b-256 checksum
How to use checksums
7ca0d5090a58065fd6ca25b0446b9dfbd1fc6c134a8731c13939b04296e5e430
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / prevampire-0.1.0-py3-none-any.whl

Download URL prevampire-0.1.0-py3-none-any.whl
Size 10.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d569c5af2dc5ec473fd4c33bbcdaf903df5bda5776807c7682ea7207f26b9fcb
BLAKE2b-256 checksum
How to use checksums
8650fe74e0484c9569e92912736b3a49cedae2bdd89c3f5a74369c01f8f09108
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.0 This release

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