cloud-volume: Skeleton.from_swc breaks with KeyError parent value 0

Hi,

I’ve recently updated CloudVolume (8.18.1) and realized a couple of things broke while converting to precomputed format.

  1. Skeleton.from_swc() throws KeyError in this line for swc files containing a parent_id value 0

Changed this line to avoid the the error.

      if parent_id > 0:
        if vid < parent_id:
          edge = [vid, parent_id]
        else:
          edge = [parent_id, vid]

Sample data:

# id type x y z radius parent
1 1 10662.0 1035.0 4095.0 11.0 0
2 3 10650.999 1040.0 4098.258 5.0 1
3 3 10649.728 1042.636 4100.0 4.0 2
4 3 10648.539 1041.539 4102.154 3.0 3
5 3 10646.334 1041.0 4103.333 1.0 4
6 3 10645.667 1042.333 4105.445 3.0 5

In other cases, parent value takes -1 and they convert ok. Would it be possible to allow 0 parent value in swc files?

  1. scales value in info file

Has the “scales” definition changed lately? It seems I need to change the value in an array of dict type now. Do you have an latest example of the placeholder I can use for skeleton?

        # info = {"@type": "neuroglancer_skeletons", "vertex_attributes": [{"id": "radius", "data_type": "float32","num_components": 1}], "scales":"um"}  
        info = {"@type": "neuroglancer_skeletons", "vertex_attributes": [{"id": "radius", "data_type": "float32","num_components": 1}], "scales":[{'key':'um','resolution':[1000,1000,1000]}]}

Thank you, -m

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 19 (10 by maintainers)

Most upvoted comments

Hi m,

Unfortunately, not at this time. We’ll need to fix Neuroglancer. You can make two copies of the data to preserve the attribute and also make it Neuroglancer viewable.

I did do some experiments with Neuroglancer a while back but didn’t test them. You can try this old branch: https://github.com/william-silversmith/neuroglancer/tree/wms_int_skel

Will

On Mon, Apr 24, 2023 at 6:02 PM manoaman @.***> wrote:

Hi Will,

So by setting and keeping uint8 vertex_types attribute in the skel.extra_attributes, I was able to save a skeleton with CloudVolume.

[{‘id’: ‘radius’, ‘data_type’: ‘float32’, ‘num_components’: 1}, {‘id’: ‘vertex_types’, ‘data_type’: ‘uint8’, ‘num_components’: 1}]

However, on the Neuroglancer side, this attribute prevents from viewing. Is there another way to configure this vertex_types?

[image: Screenshot 2023-04-24 at 2 54 13 PM] https://user-images.githubusercontent.com/47464840/234125194-4bc91928-b583-463a-93ad-84bb576170e3.png

— Reply to this email directly, view it on GitHub https://github.com/seung-lab/cloud-volume/issues/575#issuecomment-1520887246, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGQSKYMLSVFZF3ZHAKCXLXC32AZANCNFSM6AAAAAAUQ4V2YU . You are receiving this because you were mentioned.Message ID: @.***>

yes

On Wed, Apr 19, 2023, 3:13 PM manoaman @.***> wrote:

It looks like {‘id’: ‘vertex_types’, ‘data_type’: ‘uint8’, ‘num_components’: 1} get removed from skel.extra_attributes. Should I allow uint8?

— Reply to this email directly, view it on GitHub https://github.com/seung-lab/cloud-volume/issues/575#issuecomment-1515242513, or unsubscribe https://github.com/notifications/unsubscribe-auth/AATGQSJ2AZIF3WWIULA3G3DXCA2PJANCNFSM6AAAAAAUQ4V2YU . You are receiving this because you were mentioned.Message ID: @.***>

Hi m,

At a glance, the problem seems to be that vertex_types is not included in the vertex_attributes list.

[
      {
        "id": "radius",
        "data_type": "float32",
        "num_components": 1,
      }, 
      {
        "id": "vertex_types",
        "data_type": "uint8",
        "num_components": 1,
      }
    ]```

Oh yea, the entire system is designed around the images. You need to have a valid image info in the directory above the skeletons. We can maybe change that, but for now you just need to make a fake info.

Interesting. It looks like the 0 corresponds to the eswc format, but now to swc. The SWC format is defined in this paper: https://www.sciencedirect.com/science/article/pii/S0165027098000910

It looks like eswc is used in this field. If there’s more demand for its support, I’ll consider it, but I’d like to keep things to a tighter scope if possible.

As for the example above, I’m surprised that you need to add and delete the scales attribute. The simple assignment operator for the info shouldn’t be triggering any additional behavior.

Hi m!

Thank you! I think if you can adjust the conversion script that would be best, but then again, I’ve never heard of eswc before. Can you link me to some documentation?

I’m not totally sure, but I think that error means you have the info file in the main directory. The skeleton info file should be in the skeletons directory. A normal image describing info file should be in the top level directory.

Will

Hi m! Sorry, I was on vacation for a few weeks. I’ll take a look into this soon.