Skip to content

Commit

Permalink
Create apiimagedownload.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbie1977 committed May 16, 2023
1 parent 3e0894d commit 6ae76af
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions content/en/docs/Tutorials/APIs/apiimagedownload.md
@@ -0,0 +1,54 @@
---
title: "Downloading Images from VFB Using VFBconnect"
linkTitle: "Downloading Images via API"
weight: 5
description: >
This guide will show you how to use VFBconnect to download images from the Virtual Fly Brain (VFB) based on a dataset.
---

## Introduction

VFBconnect is a Python package that provides an interface to the Virtual Fly Brain (VFB) API. It allows users to query the VFB database and download data, including images.

## Installation

Before you can use VFBconnect, you need to install it. You can do this using pip:

\`\`\`bash
pip install vfb-connect
\`\`\`

## Downloading Images

To download images from VFB using VFBconnect, you need to first import the package and create a client:

\`\`\`python
from vfb_connect.cross_server_tools import VfbConnect
vc = VfbConnect()
\`\`\`

Next, you can use the `get_images` method to download images. This method requires the dataset ID as an argument:

\`\`\`python
dataset_id = 'your_dataset_id'
images = vc.get_images(dataset_id)
\`\`\`

This will return a list of images from the specified dataset. Each image is represented as a dictionary with information such as the image ID, title, and URL.

To download the images, you can loop through the list and use the `urlretrieve` function from the `urllib.request` module:

\`\`\`python
import urllib.request

for image in images:
url = image['image_url']
filename = image['image_id'] + '.jpg'
urllib.request.urlretrieve(url, filename)
\`\`\`

This will download each image and save it as a JPEG file in the current directory. The filename is the image ID.

## Conclusion

This guide showed you how to use VFBconnect to download images from the Virtual Fly Brain based on a dataset. With VFBconnect, you can easily access and download data from VFB for your research.

0 comments on commit 6ae76af

Please sign in to comment.