@@ -500,7 +500,7 @@ def write_info_file(data, filepath, add_props={}):
500
500
u = 1
501
501
tr = np .zeros ((4 , 3 ), dtype = int )
502
502
tr [:3 , :3 ] = np .diag ([u , u , u ])
503
- info ['transform' ] = tr .flatten ().tolist ()
503
+ info ['transform' ] = tr .T . flatten ().tolist ()
504
504
505
505
else :
506
506
raise TypeError (f'Unable to write info file for data of type "{ type (data )} "' )
@@ -539,14 +539,15 @@ def _write_skeleton(x, filename, radius=False):
539
539
# Below code modified from:
540
540
# https://github.com/google/neuroglancer/blob/master/python/neuroglancer/skeleton.py#L34
541
541
result = io .BytesIO ()
542
- vertex_positions = x .nodes [['x' , 'y' , 'z' ]].values .astype ('float32' )
542
+ vertex_positions = x .nodes [['x' , 'y' , 'z' ]].values .astype ('float32' , order = 'C' )
543
543
# Map edges node IDs to node indices
544
544
node_ix = pd .Series (x .nodes .reset_index (drop = True ).index , index = x .nodes .node_id )
545
- edges = x .edges .copy ().astype ('uint32' )
545
+ edges = x .edges .copy ().astype ('uint32' , order = 'C' )
546
546
edges [:, 0 ] = node_ix .loc [edges [:, 0 ]].values
547
547
edges [:, 1 ] = node_ix .loc [edges [:, 1 ]].values
548
+ edges = edges [:, [1 , 0 ]] # For some reason we have to switch direction
548
549
549
- result .write (struct .pack ('<II' , vertex_positions .shape [0 ], edges .shape [0 ] // 2 ))
550
+ result .write (struct .pack ('<II' , vertex_positions .shape [0 ], edges .shape [0 ]))
550
551
result .write (vertex_positions .tobytes ())
551
552
result .write (edges .tobytes ())
552
553
0 commit comments