nat icon indicating copy to clipboard operation
nat copied to clipboard

speed up xform.neuronlist by chunking points

Open jefferis opened this issue 10 years ago • 3 comments

could chunk e.g. 10 neurons at once and get major speedup if reg has length 1

jefferis avatar Apr 14 '14 22:04 jefferis

Hmm turns out this was a bit optimistic since much of the transform time seems to be spent reading and writing text files. @ajdm has details.

jefferis avatar Apr 15 '14 22:04 jefferis

An attempt at this (with a little speed-up) can be found at 7d37202.

jdmanton avatar Apr 16 '14 14:04 jdmanton

I'm actually coming back to the idea of doing this because we now have some xform backends that have a significant overhead for each external operation. For a specific example, the https://github.com/jefferis/nat.h5reg package may become increasingly useful as the Saalfeld Lab h5reg format is a pretty generic and efficient way to distribute deformation field based registrations. BUT the current implementation of applying these registrations depends on starting a JVM for each individual neuron, and this means a lot of time lost. It would be great if we could chunk these transformations to avoid this overhead. We could just make a special xform.neuronlist method that extracts all the points transforms them in one shot and then puts them back again. There is an example of doing this here:

https://github.com/jefferis/nat/blob/7d37202dbedbefd39138e13eb7a7a5ee7b059b56/R/xform.R#L85-L101

However this does not work well and was dropped in the current version:

https://github.com/jefferis/nat/blob/f4af0b1c831ec721d7a05526deca389bfe11b285/R/xform.R#L199-L230

because it assumes a specific type of object inside the neuronlist, normally neurons. This means that it is not flexible - for example xform.catmaidneuron also looks after synapse positions and this would not be possible without .

I think what we actually need is an interface that somehow allows xformpoints calls with the same arguments (other than the actual points) to be intercepted and batched together. I wonder if this is something that some kind of interface like futures/promises could be helpful.

jefferis avatar Mar 27 '19 18:03 jefferis