Package: biovida
BioVida is a library designed to make it easy to gain access to existing
data sets of biomedical images as well as build brand new, custom-made
ones.It is hoped that by automating the tedious data munging that is
typically involved in this process, more people will become interested
in applying machine learning to biomedical images and, in turn,
advancing insights into human disease.In a nod to recursion, BioVida tries to accomplish some of this
automation with machine learning itself, using tools like convolutional
neural networks.InstallationPython Package Index:$pipinstallbiovidaLatest Build:$pipinstallgit+git://github.com/TariqAHassan/BioVida@masterRequires Python 3.4+Images: StableIn just a few lines of code, you can gain access to biomedical databases
which store tens of millions of images.Please note that you are bound to adhere to the copyright and other
usage restrictions under which this data is provided to you by its
creators.Open-i BioMedical Image Search Engine# 1. Import the Interface for the NIH's Open-i API.frombiovida.imagesimportOpeniInterface# 2. Create an Instance of the Toolopi=OpeniInterface()# 3. Perform a search for x-rays and cts of lung canceropi.search(query='lung cancer',image_type=['x_ray','ct'])# Results Found: 9,220.# 4. Pull the datasearch_df=opi.pull()Cancer Imaging Archive# 1. Import the interface for the Cancer Imaging Archivefrombiovida.imagesimportCancerImageInterface# 2. Create an Instance of the Toolcii=CancerImageInterface(YOUR_API_KEY_HERE)# 3. Perform a searchcii.search(cancer_type='esophageal')# 4. Pull the datacdf=cii.pull()BothCancerImageInterfaceandOpeniInterfacecache images for
later use. When data is ‘pulled’, arecords_dbis generated, which
is a dataframe of all text data associated with the images. They are
provided as class attributes, e.g.,cii.records_db. Whilerecords_dbonly stores data from the most recent data pull,cache_records_dbdataframes provides an account of all image data
currently cached.Splitting ImagesBioVida can divide cached images into train/validation/test.frombiovida.imagesimportimage_divvy# 1. Define a rule to 'divvy' up images in the cache.defmy_divvy_rule(row):ifrow['image_modality_major']=='x_ray':return'x_ray'elifrow['image_modality_major']=='ct':return'ct'# 2. Define Proportions and Divide Datatt=image_divvy(opi,my_divvy_rule,action='ndarray',train_val_test_dict={'train':0.8,'test':0.2})# 3. The resultant ndarrays can be unpacked as follows:train_ct,train_xray=tt['train']['ct'],tt['train']['x_ray']test_ct,test_xray=tt['test']['ct'],tt['test']['x_ray']Images: ExperimentalAutomated Image Data CleaningUnfortunately, the data pulled from Open-i above is likely to contain a
large number of images unrelated to the search query and/or are
unsuitable for machine learning.TheexperimentalOpeniImageProcessingclass can be used to
completely automate this data cleaning process, which is partly powered
by a Convolutional Neural Network.# 1. Import Image Processing Toolsfrombiovida.imagesimportOpeniImageProcessing# 2. Instantiate the Tool using the OpeniInterface Instanceip=OpeniImageProcessing(opi)# 3. Analyze the Imagesidf=ip.auto()# 4. Use the Analysis to Clean Imagesip.clean_image_dataframe()It is easy to split these images into training and test sets.frombiovida.imagesimportimage_divvydefmy_divvy_rule(row):ifrow['image_modality_major']=='x_ray':return'x_ray'elifrow['image_modality_major']=='ct':return'ct'tt=image_divvy(ip,my_divvy_rule,action='ndarray',train_val_test_dict={'train':0.8,'test':0.2})# These ndarrays can be unpack as shown above.Genomic DataWhile primarily focused on images, BioVida also provides a simple
interface for obtaining related information, such genomic data.# 1. Import the Interface for DisGeNET.orgfrombiovida.genomicsimportDisgenetInterface# 2. Create an Instance of the Tooldna=DisgenetInterface()# 3. Pull a Databasegdf=dna.pull('curated')Diagnostic DataBioVida also makes it easy to obtain diagnostics data.Information on disease definitions, families and synonyms:# 1. Import the Interface for DiseaseOntology.orgfrombiovida.diagnosticsimportDiseaseOntInterface# 2. Create an Instance of the Tooldoi=DiseaseOntInterface()# 3. Pull the Databaseddf=doi.pull()Information on symptoms associated with diseases:# 1. Import the Interface for Disease-Symptoms Informationfrombiovida.diagnosticsimportDiseaseSymptomsInterface# 2. Create an Instance of the Tooldsi=DiseaseSymptomsInterface()# 3. Pull the Databasedsdf=dsi.pull()Unifying InformationTheunify_against_imagesfunction integrates image data information
againstDisgenetInterface,DiseaseOntInterfaceandDiseaseSymptomsInterface.frombiovida.unificationimportunify_against_imagesunify_against_images(interfaces=[cii,opi],db_to_extract='cache_records_db')Left side of DataFrame: Image Data Alonearticle_typeimage_idimage_ca
ptionmodality_best_guessagesexdisease…0case_re
port1…Magnetic Resonance
Imaging (MRI)73malefibroma…1case_re
port2…Magnetic Resonance
Imaging (MRI)73malefibroma…2case_re
port1…Computed Tomography
(CT): angiography45femal
ebile duct
cancer…Right side of DataFrame: Added Informationdisease_famil
ydisease_sy
nonymdisease_d
efinitionknown_associ
ated_symptom
smentioned_symptomsknown_assoc
iated_genes(cell type
benign
neoplasm,)nannan(abdominal
pain,…)(pain,)((ANTXR2,
0.12), …)(cell type
benign
neoplasm,)nannan(abdominal
pain,…)(pain,)((ANTXR2,
0.12), …)(biliary tract
cancer,)(bile duct
tumor,…)A biliary
tract…(abdominal
obesity,..)(colic,)nanDocumentationGetting
StartedTutorialsAPI
DocumentationContributingFor more information on how to contribute, see thecontributingdocument.Bug reports and feature requests are always welcome and can be provided
through theIssuespage.ResourcesTheresourcesdocument provides an account of all data sources and scholarly work used
by BioVida.