Skip to main content

Supplementary Package to Apply to existing VAMPIRE package pipeline.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

prevampire-0.1.0.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

prevampire-0.1.0-py3-none-any.whl (10.6 kB view details)

Uploaded Python 3

File details

Details for the file prevampire-0.1.0.tar.gz.

File metadata

  • Download URL: prevampire-0.1.0.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for prevampire-0.1.0.tar.gz
Algorithm Hash digest
SHA256 80facdb16aa8500e06bc647f870ca59b26be1e0e82dc4cf59e922fab44b3c487
MD5 c029301686a8214c5787e7d5d5d3c18e
BLAKE2b-256 7ca0d5090a58065fd6ca25b0446b9dfbd1fc6c134a8731c13939b04296e5e430

See more details on using hashes here.

File details

Details for the file prevampire-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: prevampire-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for prevampire-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d569c5af2dc5ec473fd4c33bbcdaf903df5bda5776807c7682ea7207f26b9fcb
MD5 e378a150462821a43e42482b8fe6c5d8
BLAKE2b-256 8650fe74e0484c9569e92912736b3a49cedae2bdd89c3f5a74369c01f8f09108

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page