knossos-project / knossos_utils

Python library for interacting with KNOSSOS data sets and annotation files
GNU General Public License v2.0
9 stars 9 forks source link

DatasetUtils cube2matrix inefficient matrix assignment #1

Open orenshatz opened 9 years ago

orenshatz commented 9 years ago

Each cube file content is reshaped and then swapped axes. It is unclear why this swapping is necessary, given that knossos never does it and presents a coherent supercube. Anyway, as the strides of the resulting matrix are incompatible with the large output matrix, assignment is voxel-wise rather than block-wise, i.e. extremely inefficient.

As proof of concept I simply cancelled the swapaxes (which by itself took nothing much), then the assignment dropped from something to practically nothing.

xeray commented 8 years ago

If you remove the swap simply, it won't work. But the swap becoms unnecessary if in this line the order of current coordinates is changed from 0,1,2 to 2,1,0. Then the resulting array has axis order z,y,x and the sub-arrays are assembled in a consistent manner.