Data Sharing

  • We can now warmly share data and get credits for it as a paper publication.
  • We are going to illustrate this process for the case of Figshare.
  • Keep in mind that other data sharing sites may exist for your discipline.

Locate your Image

  • Find in your local filesystem the images that you just acquired.
  • We will upload on of these images to Figshare.

Log into Figshare

Upload Image

  • Click on the Upload link at the top of the page
  • Follow the instructions and browse to the location of your acquired images in your filesystem
  • Upload only one Image at this point

Publish the Image

  • Go to the My Data link at the top of the page and find your new uploaded image in the list
  • On the Status column, click on the "DRAFT" button
    • Select a title for the image (use a serious and descriptive title)
      • This is important since the image will get a real DOI, just like an article
    • Select a Category, from the dropdown menu
      • In our case, we could use "Biological Techniques"
    • Enter a serious description in the "Description" field.
    • Click on the "Public" button, on the bottom right, to make the image publicly available
    • Save the changes
    • Click on the "Publish" link, on the bottom right.
    • Answer the confirmation by clicking on the "Yes, publish" button
    • Click on "Preview" the article

Find Reference to the Image

We need to be able to refer programatically to this image.

Here we do this with the Figshare's REST API.

Do The Following


    {"count": 1, "items": [{"article_id": 1050595, "title": "Image 002", "figshare_url": "http://figshare.com/articles/Image_002/1050595", "views": 1, "downloads": 0, "shares": 0, "doi": "http://dx.doi.org/10.6084/m9.figshare.1050595", "publisher_doi": "", "publisher_citation": "", "master_publisher_id": 0, "defined_type": "figure", "status": "Public", "version": 1, "published_date": "23:09, Jun 14, 2014", "description": "

Image of Tardigrade acquired with a cell phone water drop microscope

", "description_nohtml": "Image of Tardigrade acquired with a cell phone water drop microscope", "total_size": "85.10 KB", "owner": {"id": 97454, "full_name": "Luis Ibanez"}, "authors": [{"first_name": "Luis", "last_name": "Ibanez", "id": 97454, "full_name": "Luis Ibanez"}], "tags": [{"id": 247678, "name": "diy microscopy"}, {"id": 98329, "name": "tardigrades"}], "categories": [{"id": 12, "name": "Cell Biology"}, {"id": 8, "name": "Microbiology"}], "files": [{"thumb": "http://previews.figshare.com/1526484/250_1526484.jpg", "download_url": "http://files.figshare.com/1526484/IMG_20140331_131717.jpeg", "name": "IMG_20140331_131717.jpeg", "id": 1526484, "mime_type": "image/jpeg", "size": "87 KB"}], "links": []}]}
  • Look for the "download_url" tag.
    • Is the sixth from the end of the JSON structure.

Test the Download

Programatic Download

We now use the urllib module to download the image.

We do this in several stages

Get the Article's URL


In [ ]:
import urllib
import json

destination_file = '/tmp/myimage.jpg'

figshare_id = '1066744'

figshare_url = "http://api.figshare.com/v1/articles/%s" % figshare_id

Request Article Details from Figshare

We do this using the REST API

The response comes in the form of a JSON structure


In [ ]:
jsonresponse = urllib.urlopen(figshare_url)

Find the Download URL

We can now load the JSON structure into an object


In [ ]:
article_info = json.load(jsonresponse)

and extract the "download_url" from it


In [ ]:
image_download_url = article_info['items'][0]['files'][0]['download_url']

Finally Download the Image

Using this URL we now download the image into the local file system.


In [ ]:
urllib.urlretrieve(image_download_url, destination_file)

Check for the Image Presence

Simly use the "ls" command and the expected destination of the file.


In [ ]:
ls  -l    /tmp/myimage.jpg

Hands On

  • Repeat this process with your image in Figshare
  • Print out the raw content of the JSON response
  • Verify that the file appears in your file system