AllenInstitute / neuron_morphology

Tools for working with single-neuron morphological reconstructions
https://neuron-morphology.readthedocs.io/en/latest/
Other
19 stars 8 forks source link

use snap_polygons without pia/wm paths #189

Open tmchartrand opened 3 years ago

tmchartrand commented 3 years ago

Describe the use case that is addressed by this feature. Many cells outside of the IVSCC pipeline (particularly from synaptic physiology) have layer drawings but no pia/wm paths recorded (or paths may be incomplete). The snap_polygons functionality can still be useful to prepare layer polygons for depth calculations, but currently requires the pia/wm path.

Describe the solution you'd like The pia/wm paths are only required to trim the layer polygons to the bounds of the pia/wm convex hull. This step is not strictly necessary, and can safely be skipped for missing pia/wm. A few other minor tweaks to schemas and error cases etc. are also required.

Describe alternatives you've considered Any alternative solutions or features you've considered.

Additional context This is primarily to enable a use case for synaptic physiology that I currently have fully working on my fork.

Do you want to work on this issue? Yes, will submit PR shortly.

gouwens commented 2 years ago

Hey Tom, just looking this issue and associated PR (#191) over - it's true that you don't need pia/wm drawings for snapping the layer polygons, but you do need them for actually running the streamlines function here: https://github.com/AllenInstitute/neuron_morphology/blob/24109d924b6caf51dd7d204d264c8888825f2d6d/neuron_morphology/transforms/pia_wm_streamlines/calculate_pia_wm_streamlines.py#L32 which passes that info to: https://github.com/AllenInstitute/neuron_morphology/blob/24109d924b6caf51dd7d204d264c8888825f2d6d/neuron_morphology/transforms/streamline.py#L57

One of the reasons I was looking at this again is that I find myself in a similar situation - I'm pulling layer boundaries out of the CCF atlas volume for full morphology cells, and I need to get pia/wm lines from the layer drawings. I was hoping you had code in the PR to do that. :) But maybe that still needs to be done.

tmchartrand commented 2 years ago

@gouwens I have code (not in here) that will adapt the streamlines to using layer boundaries rather than pia/wm. I can definitely add it here soon, I'd previously been trying to make the minimal internal changes needed to use the module for that separate code. In that code don't try to infer the upper boundary of L1, so have to skip L1 cells, but it worked well for synphys cells where we didn't have L1 and rarely had pia/wm drawings.

gouwens commented 2 years ago

But you're still using the gradient fields from the streamlines? Or you're using a different method to figure out the paths between layer edges?

tmchartrand commented 2 years ago

using gradient fields from streamlines, by calling generate_laplace_field directly (essentially rewrote a more flexible run_streamlines).