knossos-project / knossos

KNOSSOS is a software tool for the visualization and annotation of 3D image data and was developed for the rapid reconstruction of neural morphology and connectivity.
https://knossos.app
GNU General Public License v2.0
73 stars 19 forks source link

.swc file of skeletons is empty #507

Closed smcelroy97 closed 1 year ago

smcelroy97 commented 1 year ago

I am trying to export .swc files from a segmented EM dataset of neuron skeletons. For both options (save as um and save as px) the swc file contains zero bytes and is empty.

my-tien commented 1 year ago

Hi, the swc export does not work on segmentation, it exports KNOSSOS skeletons into swc format. Since conversion from segmentation to skeleton can have multiple possible solutions depending on the input we have so far not implemented this feature.

smcelroy97 commented 1 year ago

Hello,

When I right click on my merged trees on the skeleton tab of the annotation window I have the option to save as SWC. That skeleton contains zero bytes when saved, do I need to do something else to save this skeleton?

Scott

From: My-Tien Nguyen @.> Date: Saturday, June 24, 2023 at 11:24 AM To: knossos-project/knossos @.> Cc: Scott McElroy @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507)

Hi, the swc export does not work on segmentation, it exports KNOSSOS skeletons into swc format. Since conversion from segmentation to skeleton can have multiple possible solutions depending on the input we have so far not implemented this feature.

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1605585199, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKTH4QA7KQWUJV3BIMTXM4BBHANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

No, as long as you have a skeleton with nodes inside, that should be enough. Do you mind sharing the skeleton here? Or any dummy skeleton that doesn't work for you.

smcelroy97 commented 1 year ago

Should I save as a kzip?

Scott

On Mon, Jun 26, 2023 at 4:16 PM My-Tien Nguyen @.***> wrote:

No, as long as you have a skeleton with nodes inside, that should be enough. Do you mind sharing the skeleton here? Or any dummy skeleton that doesn't work for you.

— Reply to this email directly, view it on GitHub https://github.com/knossos-project/knossos/issues/507#issuecomment-1608183899, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAXWKTPXYLMFS2FSNAU24TXNHU3HANCNFSM6AAAAAAZQNEP4I . You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

Yes, exactly

smcelroy97 commented 1 year ago

Here's a random cell I grabbed.

On Tue, Jun 27, 2023 at 10:52 AM Scott McElroy @.***> wrote:

Should I save as a kzip?

Scott

On Mon, Jun 26, 2023 at 4:16 PM My-Tien Nguyen @.***> wrote:

No, as long as you have a skeleton with nodes inside, that should be enough. Do you mind sharing the skeleton here? Or any dummy skeleton that doesn't work for you.

— Reply to this email directly, view it on GitHub https://github.com/knossos-project/knossos/issues/507#issuecomment-1608183899, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAXWKTPXYLMFS2FSNAU24TXNHU3HANCNFSM6AAAAAAZQNEP4I . You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

You seem to have forgotten the attachment

smcelroy97 commented 1 year ago

Weird it shows that I did attach it.

On Tue, Jun 27, 2023 at 2:30 PM My-Tien Nguyen @.***> wrote:

You seem to have forgotten the attachment

— Reply to this email directly, view it on GitHub https://github.com/knossos-project/knossos/issues/507#issuecomment-1610022563, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAXWKVEAHUNFVLWZU3P2UDXNMRFJANCNFSM6AAAAAAZQNEP4I . You are receiving this because you authored the thread.Message ID: @.***>

smcelroy97 commented 1 year ago

Were you able to see the attachment? It was attached in the last two emails and this one.

From: Scott McElroy @.> Date: Tuesday, June 27, 2023 at 3:30 PM To: knossos-project/knossos @.> Cc: knossos-project/knossos @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507) Weird it shows that I did attach it.

On Tue, Jun 27, 2023 at 2:30 PM My-Tien Nguyen @.**@.>> wrote:

You seem to have forgotten the attachment

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1610022563, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKVEAHUNFVLWZU3P2UDXNMRFJANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

Unfortunately no. Alternatively, you could also choose export to nml instead of saving to kzip. Then you can open the saved file in any text editor and copy-paste us the content per email.

smcelroy97 commented 1 year ago

The file has very many lines, so I only copied a snippet of the text. The nml file is also attached.

Scott Mcelroy <?xml version="1.0" encoding="UTF-8"?>

From: My-Tien Nguyen ***@***.***> Date: Wednesday, June 28, 2023 at 5:48 PM To: knossos-project/knossos ***@***.***> Cc: Scott McElroy ***@***.***>, Author ***@***.***> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507) Unfortunately no. Alternatively, you could also choose export to nml instead of saving to kzip. Then you can open the saved file in any text editor and copy-paste us the content per email. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: ***@***.***>
my-tien commented 1 year ago

Okay, so the issue is that none of your trees contain any nodes. So there isn't really anything to export. Could you explain what you are trying to achieve?

smcelroy97 commented 1 year ago

Essentially, I'd just like to export the morphologies of all cells within a certain nucleus as swc files, but am currently just trying to get it to work for one cell. I was given a tutorial by the group who collected the data and segmentation, and followed the steps listed on this google doc: https://docs.google.com/document/d/e/2PACX-1vQg9CaH5TTZKeT6wLHxG-HzZBAebpa40LNyLOWRw50JsC681xIDiWQyNT3M-er22grwJGAfp5mKpPr4/pub I have never worked with EM data so I'm not sure what I am doing wrong.

Best, Scott

On Thu, Jun 29, 2023 at 2:17 PM My-Tien Nguyen @.***> wrote:

Okay, so the issue is that none of your trees contain any nodes. So there isn't really anything to export. Could you explain what you are trying to achieve?

— Reply to this email directly, view it on GitHub https://github.com/knossos-project/knossos/issues/507#issuecomment-1613596892, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARAXWKVPKFDDOQPBAXNA5PDXNXBB3ANCNFSM6AAAAAAZQNEP4I . You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

There are 3 formats that can be exported from KNOSSOS. Below you can see how they look like and how to export them. Since in your case no skeleton data has been created, you will get the best impression of the morphology by going for the mesh:

1. Skeleton data

a graph with vertices and optionally edges, can be exported as .swc image

2. Segmentation

a pixel/voxel-labeling that is visualized as colored areas/volumes. Can be converted to numpy matrices with https://github.com/knossos-project/knossos_utils image

3. Mesh

a 3D surface. After saving as .k.zip, there will be a .ply file within the .k.zip that you can extract and open in any 3D viewer such as Blender or Meshlab. image

smcelroy97 commented 1 year ago

I plan to use these morphologies for network modeling, but the modeling package only accepts .swc and .hoc. Basically, what you’re saying is that for me to export cells directly to swc I would need to manually label the skeletons of these cells rather than use the already segmented data? If that is the case I will need to figure out how to convert the mesh/numpy array into one of the filetypes that works for me.

From: My-Tien Nguyen @.> Date: Thursday, June 29, 2023 at 3:11 PM To: knossos-project/knossos @.> Cc: Scott McElroy @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507)

There are 3 formats that can be exported from KNOSSOS. Below you can see how they look like and how to export them. Since in your case no skeleton data has been created, you will get the best impression of the morphology by going for the mesh:

  1. Skeleton data

a graph with vertices and optionally edges, can be exported as .swc [Image removed by sender. image]https://user-images.githubusercontent.com/3898364/249868630-83ff47ac-ec20-45f0-ad5b-86d15ea09544.png

  1. Segmentation

a pixel/voxel-labeling that is visualized as colored areas/volumes. Can be converted to numpy matrices with https://github.com/knossos-project/knossos_utils [Image removed by sender. image]https://user-images.githubusercontent.com/3898364/249869326-c6e8b8e9-6d9b-401f-b047-a2bad3bf9dc6.png

  1. Mesh

a 3D surface. After saving as .k.zip, there will be a .ply file within the .k.zip that you can extract and open in any 3D viewer such as Blender or Meshlab. [Image removed by sender. image]https://user-images.githubusercontent.com/3898364/249869868-3f8c3627-63b9-41e9-9d17-35992bbd6cb6.png

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1613664562, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKV6DJQH26LUPVPTJRTXNXHP3ANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

Yes, almost. This is what I hinted at in my first message: There is no trivial solution for a conversion from segmentation to skeleton because every small bump in the segmentation could in theory be turned into a branch of the skeleton. There are algorithms like skeletonize_3d from scikit-image or maybe you can have a look at https://github.com/seung-lab/kimimaro (haven't worked with it myself yet).

smcelroy97 commented 1 year ago

Great, I’ll begin looking at these. Thank you for the help and patience, I really appreciate it!

Scott

From: My-Tien Nguyen @.> Date: Thursday, June 29, 2023 at 5:18 PM To: knossos-project/knossos @.> Cc: Scott McElroy @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507)

Yes, almost. This is what I hinted at in my first message: There is no trivial solution for a conversion from segmentation to skeleton because every small bump in the segmentation could in theory be turned into a branch of the skeleton. There are algorithms like skeletonize_3d from scikit-image or maybe you can have a look at https://github.com/seung-lab/kimimaro (haven't worked with it myself yet).

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1613822625, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKQTQQYAR6VKSAI5LW3XNXWKPANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

smcelroy97 commented 1 year ago

Hello,

I’m getting an error message when trying to load my k.zip files that reads “xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 17, column 128” Do you know if this is an issue with what you mentioned about the data containing no nodes? Or is this a different issue?

Scott

From: Scott McElroy @.> Date: Thursday, June 29, 2023 at 5:36 PM To: knossos-project/knossos @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507) Great, I’ll begin looking at these. Thank you for the help and patience, I really appreciate it!

Scott

From: My-Tien Nguyen @.> Date: Thursday, June 29, 2023 at 5:18 PM To: knossos-project/knossos @.> Cc: Scott McElroy @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507)

Yes, almost. This is what I hinted at in my first message: There is no trivial solution for a conversion from segmentation to skeleton because every small bump in the segmentation could in theory be turned into a branch of the skeleton. There are algorithms like skeletonize_3d from scikit-image or maybe you can have a look at https://github.com/seung-lab/kimimaro (haven't worked with it myself yet).

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1613822625, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKQTQQYAR6VKSAI5LW3XNXWKPANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

smcelroy97 commented 1 year ago

Sorry, I didn’t mention I am trying to use load_kzip_seg from knossos_utils. If this is not your area of expertise, no problem.

From: Scott McElroy @.> Date: Friday, June 30, 2023 at 1:39 PM To: knossos-project/knossos @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507) Hello,

I’m getting an error message when trying to load my k.zip files that reads “xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 17, column 128” Do you know if this is an issue with what you mentioned about the data containing no nodes? Or is this a different issue?

Scott

From: Scott McElroy @.> Date: Thursday, June 29, 2023 at 5:36 PM To: knossos-project/knossos @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507) Great, I’ll begin looking at these. Thank you for the help and patience, I really appreciate it!

Scott

From: My-Tien Nguyen @.> Date: Thursday, June 29, 2023 at 5:18 PM To: knossos-project/knossos @.> Cc: Scott McElroy @.>, Author @.> Subject: Re: [knossos-project/knossos] .swc file of skeletons is empty (Issue #507)

Yes, almost. This is what I hinted at in my first message: There is no trivial solution for a conversion from segmentation to skeleton because every small bump in the segmentation could in theory be turned into a branch of the skeleton. There are algorithms like skeletonize_3d from scikit-image or maybe you can have a look at https://github.com/seung-lab/kimimaro (haven't worked with it myself yet).

— Reply to this email directly, view it on GitHubhttps://github.com/knossos-project/knossos/issues/507#issuecomment-1613822625, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ARAXWKQTQQYAR6VKSAI5LW3XNXWKPANCNFSM6AAAAAAZQNEP4I. You are receiving this because you authored the thread.Message ID: @.***>

my-tien commented 1 year ago

Please file an issue over at https://github.com/knossos-project/knossos_utils for this.