#NEWLINE# def createSpecificSynapse( annoid , syn_segments , cutout ) : #NEWLINE# #INDENT# tmpfile = tempfile . NamedTemporaryFile ( ) #NEWLINE# h5fh = h5py . File ( tmpfile . name ) #NEWLINE# idgrp = h5fh . create_group ( str ( annoid ) ) #NEWLINE# idgrp . create_dataset ( 'ANNOTATION_TYPE' , ( 1 , ) , np . uint32 , data = 2 ) #NEWLINE# mdgrp = idgrp . create_group ( 'METADATA' ) #NEWLINE# ann_status = random . randint ( 0 , 4 ) #NEWLINE# ann_confidence = random . random ( ) #NEWLINE# ann_author = 'randal' #NEWLINE# mdgrp . create_dataset ( 'STATUS' , ( 1 , ) , np . uint32 , data = ann_status ) #NEWLINE# mdgrp . create_dataset ( 'CONFIDENCE' , ( 1 , ) , np . float , data = ann_confidence ) #NEWLINE# mdgrp . create_dataset ( 'AUTHOR' , ( 1 , ) , dtype = h5py . special_dtype ( vlen = str ) , data = ann_author ) #NEWLINE# syn_weight = ( random . random ( ) * 1000.0 ) #NEWLINE# syn_synapse_type = random . randint ( 1 , 9 ) #NEWLINE# [ resstr , xstr , ystr , zstr ] = cutout . split ( '/' ) #NEWLINE# ( xlowstr , xhighstr ) = xstr . split ( ',' ) #NEWLINE# ( ylowstr , yhighstr ) = ystr . split ( ',' ) #NEWLINE# ( zlowstr , zhighstr ) = zstr . split ( ',' ) #NEWLINE# resolution = int ( resstr ) #NEWLINE# xlow = int ( xlowstr ) #NEWLINE# xhigh = int ( xhighstr ) #NEWLINE# ylow = int ( ylowstr ) #NEWLINE# yhigh = int ( yhighstr ) #NEWLINE# zlow = int ( zlowstr ) #NEWLINE# zhigh = int ( zhighstr ) #NEWLINE# anndata = np . ones ( [ ( zhigh - zlow ) , ( yhigh - ylow ) , ( xhigh - xlow ) ] ) #NEWLINE# mdgrp . create_dataset ( 'WEIGHT' , ( 1 , ) , np . float , data = syn_weight ) #NEWLINE# mdgrp . create_dataset ( 'SYNAPSE_TYPE' , ( 1 , ) , np . uint32 , data = syn_synapse_type ) #NEWLINE# mdgrp . create_dataset ( 'SEGMENTS' , ( len ( syn_segments ) , 2 ) , np . uint32 , data = syn_segments ) #NEWLINE# idgrp . create_dataset ( 'RESOLUTION' , ( 1 , ) , np . uint32 , data = resolution ) #NEWLINE# idgrp . create_dataset ( 'XYZOFFSET' , ( 3 , ) , np . uint32 , data = [ xlow , ylow , zlow ] ) #NEWLINE# idgrp . create_dataset ( 'CUTOUT' , anndata . shape , np . uint32 , data = anndata ) #NEWLINE# h5fh . flush ( ) #NEWLINE# tmpfile . seek ( 0 ) #NEWLINE# return tmpfile