Upload an Image
In this example, we will show you how to use the BQAPI to upload one of the over 100+ supported Biological formats from a Jupyter Notebook.
The API call goes as follows:
- Instantiate a BisQue session
- Login using
- Upload the Image
STEP 0. Import Dependencies
Before we can even attempt anything cool with the API, we need to import the necessary packages. In this case, we need the following packages:
import os from bqapi.comm import BQSession
Place these at the top of your Jupyter notebook or
Python script to ensure these run first. If you have not installed the BQAPI via pip, then install the BQAPI here.
STEP 1. Instantiate a BisQue session
This instantiation enables the user to effectively communicate with BisQue. Without this, you will not be able to login and interact with the API.
STEP 2. Login using BisQue Credentials
Here is where we will login into our BisQue account to upload the data to our account. We show an alternative chained version (line 2) of the commands here to instantiate the BQSession and login at the same time.
=root) bq.init_local(user, pwd, bisque_root# bq = BQSession().init_local(user, pwd, bisque_root=root)
If you do not have an account on BisQue, make an account here.
=amil_khan, pass=bisque1234, bq.init_local(user="https://bisque.ece.ucsb.edu") bisque_root
STEP 3. Upload the Image
The final step is to upload the image on your local system to BisQue. To do this, we will use the instantiated session
bq along with the
postblob function to upload the
NIFTI image below.
# Post image to BisQue and get the response = '/PATH/TO/IMAGE/supercoolscientificimage.DICOM' image_path = bq.postblob(image_path) img_upload
If your image is in the current directory of your Jupyter Notebook, then simply input the filename. Otherwise, specify the full path
= bq.postblob('T1_brain.nii.gz') img_upload