Skip to content

Adding an Output Format v1

John Hoffer edited this page Mar 9, 2017 · 1 revision

To add a new type of output that you want to support, add to _butterfly/webserver.py in the block starting with the line if output_format ==. As an example, the support for binary zipped data output is done as follows:

if output_format == 'zip' and not color:
    #Rotate out of numpy array
    volume = volume.transpose(1, 0, 2)
    zipped_data = zlib.compress(volume.astype(out_dtype).tostring('F'))
    output = StringIO.StringIO()
    output.write(zipped_data)

    content = output.getvalue()
    content_type = 'application/octet-stream'

Simply:

  • Set content = the converted data
  • Set content_type = 'application/octect-stream' for most packaged data formats (or the appropriate MIME type for images)
  • Check that color is supported, or create an exception
    • Color segmentations returned from get() are 4D volumes [y, x, z, RGB] (as in [:,:,:,1] is the Green channel)

No other additions or changes should be necessary.

Version 2

Version 1

Clone this wiki locally