meshparty_skeletonize not working

129 views
Skip to first unread message

Ibrahim Taştekin

unread,
Mar 4, 2022, 6:35:24 AM3/4/22
to nat-user
Hi all, 

Suddenly the meshparty_skeletonize function stopped working for me with the following error. Thanks for helping in advance!

Fetching meshes
Skeletonising meshes
Error in py_call_impl(callable, dots$args, dots$keywords) :
  AttributeError: 'NoneType' object has no attribute 'mesh'


dr_fafbseg()
FlyWire
----
Valid FlyWire ChunkedGraph token is set!
Flywire API access via python+cloudvolume is working.
1 FlyWire/CloudVolume credential files available at
/Users/ibrahimtastekin/.cloudvolume/secrets
[1] "cave-secret.json"

Flywire cloudvolume URL: graphene://https://prodv1.flywire-daf.com/segmentation/table/fly_v31
Google FFN1 segmentation
----
• Set the `fafbseg.skelziproot` option:
   `options(fafbseg.skelziproot="/path/to/zips")`
  if you want to use FFN1 skeleton files!

Python
----
python:         /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/bin/python
libpython:      /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/libpython3.8.dylib
pythonhome:     /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate:/Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate
version:        3.8.12 | packaged by conda-forge | (default, Jan 30 2022, 23:36:06)  [Clang 11.1.0 ]
numpy:          /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/numpy
numpy_version:  1.22.2

           module available version                                                                                                    path
1     cloudvolume      TRUE   8.5.0    /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/cloudvolume
2         DracoPy      TRUE                                                                                                                
3       meshparty      TRUE  1.15.0      /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/meshparty
4        skeletor      TRUE   1.1.0       /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/skeletor
5        pykdtree      TRUE               /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/pykdtree
6        pyembree      TRUE   0.1.6       /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/pyembree
7      caveclient      TRUE  4.12.3     /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/caveclient
8  pychunkedgraph      TRUE 0.1.113 /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/pychunkedgraph
9         igneous      TRUE                /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/igneous
10        pyarrow      TRUE   7.0.0        /Users/ibrahimtastekin/Library/r-miniconda/envs/r-reticulate/lib/python3.8/site-packages/pyarrow

rJava
----
The rJava package is linked to the following JVM
java.version: 11.0.12
java.home: /Library/Java/JavaVirtualMachines/jdk-11.0.12.jdk/Contents/Home
java.class.version: 55.0

System java
----
(used as a fallback when rJava not available)
java run time found at: /usr/bin/java
java.version: 11.0.12

h5reg test
----
h5reg xform infrastructure OK!
xform test gave correct results

Greg Jefferis

unread,
Mar 4, 2022, 6:36:56 AM3/4/22
to Ibrahim Taştekin, nat-user
Hi Ibrahim,

Thanks for the report. Can you give a specific example of a neuron id you are trying to skeletonise?

Best,

Greg.



--
You received this message because you are subscribed to the Google Groups "nat-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nat-user+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/nat-user/2ad3ceaf-986a-43ed-94c9-5be40f63b05an%40googlegroups.com.

Greg Jefferis

unread,
Mar 4, 2022, 8:21:50 AM3/4/22
to Ibrahim Taştekin, nat-...@googlegroups.com
Hi Ibrahim,

I'm not using meshparty_skeletonize at the moment and trying to install I run into some python dependency version mismatch issues that look like they will take a little while to resolve.

Can you 

1. Report the results of running 

traceback()

immediately after the error is triggered?

2. Do debug(meshparty_skeletonize) and step through the function call 

In particular reporting on the values of 

tm
mm

Thanks,

Greg.


On 4 Mar 2022, at 12:26, Ibrahim Taştekin <ibrahim....@research.fchampalimaud.org> wrote:

Hi Greg,

Here is an example neuron id: 720575940634209934

Thank you!
Ibo

Ibrahim Taştekin

unread,
Mar 7, 2022, 3:44:41 AM3/7/22
to Greg Jefferis, nat-user
Hi Greg,

traceback()

4: stop(structure(list(message = "AttributeError: 'NoneType' object has no attribute 'mesh'\n",
       call = py_call_impl(callable, dots$args, dots$keywords),
       cppstack = structure(list(file = "", line = -1L, stack = c("1   reticulate.so                       0x000000011baae204 _ZN4Rcpp9exceptionC2EPKcb + 196",
       "2   reticulate.so                       0x000000011bab6995 _ZN4Rcpp4stopERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 53",
       "3   reticulate.so                       0x000000011bac401c _Z12py_call_impl11PyObjectRefN4Rcpp6VectorILi19ENS0_15PreserveStorageEEES3_ + 684",
       "4   reticulate.so                       0x000000011baa2d93 _reticulate_py_call_impl + 147",
       "5   libR.dylib                          0x0000000104ec9f52 R_doDotCall + 1458",
       "6   libR.dylib                          0x0000000104f150ed bcEval + 104317",
       "7   libR.dylib                          0x0000000104efb2c1 Rf_eval + 385",
       "8   libR.dylib                          0x0000000104f1b139 R_execClosure + 2169",
       "9   libR.dylib                          0x0000000104f19f27 Rf_applyClosure + 471",
       "10  libR.dylib                          0x0000000104f0220e bcEval + 26782",
       "11  libR.dylib                          0x0000000104efb2c1 Rf_eval + 385",
       "12  libR.dylib                          0x0000000104f1b139 R_execClosure + 2169",
       "13  libR.dylib                          0x0000000104f19f27 Rf_applyClosure + 471",
       "14  libR.dylib                          0x0000000104f0220e bcEval + 26782",
       "15  libR.dylib                          0x0000000104efb2c1 Rf_eval + 385",
       "16  libR.dylib                          0x0000000104f1b139 R_execClosure + 2169",
       "17  libR.dylib                          0x0000000104f19f27 Rf_applyClosure + 471",
       "18  libR.dylib                          0x0000000104efb77b Rf_eval + 1595",
    ...
3: py_call_impl(callable, dots$args, dots$keywords)
2: mm$mesh(filename = f)
1: meshparty_skeletonize(pegs.latest[11], savedir = "/Volumes/GoogleDrive/My Drive/Research /EM_Flywire/20220303_peg_nerve")

Here are the mm and tm values:

debugging in: meshparty_skeletonize(pegs.latest[11], savedir = "/Volumes/GoogleDrive/My Drive/Research /EM_Flywire/20220303_peg_nerve")
debug: {
    if (is.null(savedir)) {
        savedir <- tempfile()
        on.exit(unlink(savedir, recursive = TRUE))
    }
    else {
        if (!file.exists(savedir))
            dir.create(savedir, recursive = TRUE)
    }
    if (!is.character(segments) || isFALSE(all(tools::file_ext(segments) ==
        "obj"))) {
        segments <- ngl_segments(segments, as_character = TRUE,
            include_hidden = FALSE)
        if (interactive())
            message("Fetching meshes")
        segments <- save_cloudvolume_meshes(segments = segments,
            savedir = savedir, ...)
    }
    mp <- check_meshparty_reticulate()
    tm <- mp$trimesh_io
    sk <- mp$skeletonize
    mm = tm$MeshMeta()
    use_progress = interactive()
    if (use_progress) {
        pb <- progress_bar$new(format = "  downloading [:bar] :current/:total eta: :eta",
            total = length(segments), clear = F, show_after = 1)
    }
    swcs = paste0(tools::file_path_sans_ext(segments), ".swc")
    if (interactive())
        message("Skeletonising meshes")
    for (f in segments) {
        if (use_progress)
            pb$tick()
        mesh = mm$mesh(filename = f)
        skel = sk$skeletonize_mesh(mesh, invalidation_d = invalidation_d)
        outf = paste0(tools::file_path_sans_ext(f), ".swc")
        skel$export_to_swc(outf)
    }
    swcs
}



Debugging gets stuck at:

debug: mesh = mm$mesh(filename = f)
Browse[2]>
Error in py_call_impl(callable, dots$args, dots$keywords) :
  AttributeError: 'NoneType' object has no attribute 'mesh'




Thanks a lot,

Ibo

Ibrahim Taştekin

unread,
Mar 24, 2022, 6:55:57 AM3/24/22
to nat-user
Hi Greg,

I wonder if you had time to have a look at the issue with meshparty? 

All the best,
Ibo

Greg Jefferis

unread,
Mar 30, 2022, 7:10:26 PM3/30/22
to nat-user
Hi Ibo, Sorry I missed this message. This seems like a complex issue with your environment that I could not reproduce on my machine. It might require a remote debug to check out your environment. I'm not sure if I'll have time in the next couple of days, but I'll contact you directly if I can help. Best, Greg.

Ibrahim Taştekin

unread,
Apr 1, 2022, 1:09:50 PM4/1/22
to Greg Jefferis, nat-user
Thanks a lot Greg!

I really appreciate that!

Best
Ibo 

31 Mar 2022 Per 00:10 tarihinde Greg Jefferis <jeff...@gmail.com> şunu yazdı:

Ibrahim Taştekin

unread,
Sep 5, 2022, 10:14:06 AM9/5/22
to nat-user
Hi Greg, 

I have been having the skeletonization issue with meshparty where I get the following error (see below as well):

Fetching meshes
Skeletonising meshes
Error in py_call_impl(callable, dots$args, dots$keywords) :
AttributeError: 'NoneType' object has no attribute 'mesh'


I have been trying to troubleshoot it and found an issue on meshparty github by Sven: 


I traced the meshparty_skeletonize code in R and found that a cv_path is not defined:

mm = tm$MeshMeta()

I wonder if using a cloudvolume path would solve the problem? I tried it on python in the miniconda environment and it solved the issue.

mm = trimesh_io.MeshMeta(cv_path = "precomputed://gs://neuroglancer-public-data/kasthuri2011/ground_truth",disk_cache_path = "test_meshes",map_gs_to_https=True)

for file in dirlist:
    mesh_path = os.path.join(path,file)
    print(mesh_path)
    swc_name = file[:-4] + '.swc'
    mesh = mm.mesh(mesh_path)
    skel = skeletonize.skeletonize_mesh(mesh, invalidation_d =12000)
    skeleton_io.export_to_swc(skel, os.path.join(path,swc_name), node_labels=None, radius=None, header=None, xyz_scaling=1000)
   
This piece of code basically skeletonized all the .obj files in the path. 

Best
Ibo

Ibrahim Taştekin

unread,
Sep 5, 2022, 10:36:38 AM9/5/22
to nat-user
I just edited the meshparty_skeletonize code with trace(meshparty_skeletonize, edit =TRUE) and it works now! I just added the cloudvolume path for flywire


function (segments, savedir = NULL, invalidation_d = 12000, ...)
{
    if (is.null(savedir)) {
        savedir <- tempfile()
        on.exit(unlink(savedir, recursive = TRUE))
    }
    else {
        if (!file.exists(savedir))
            dir.create(savedir, recursive = TRUE)
    }
    if (!is.character(segments) || isFALSE(all(tools::file_ext(segments) ==
        "obj"))) {
        segments <- ngl_segments(segments, as_character = TRUE,
            include_hidden = FALSE)
        if (interactive())
            message("Fetching meshes")
        segments <- save_cloudvolume_meshes(segments = segments,
            savedir = savedir, ...)
    }
    mp <- check_meshparty_reticulate()
    tm <- mp$trimesh_io
    sk <- mp$skeletonize
    mm = tm$MeshMeta(cv_path = "graphene://https://prodv1.flywire-daf.com/segmentation/table/fly_v31") ## add the cloudvolume path for flywire

    use_progress = interactive()
    if (use_progress) {
        pb <- progress_bar$new(format = "  downloading [:bar] :current/:total eta: :eta",
            total = length(segments), clear = F, show_after = 1)
    }
    swcs = paste0(tools::file_path_sans_ext(segments), ".swc")
    if (interactive())
        message("Skeletonising meshes")
    for (f in segments) {
        if (use_progress)
            pb$tick()
        mesh = mm$mesh(filename = f)
        skel = sk$skeletonize_mesh(mesh, invalidation_d = invalidation_d)
        outf = paste0(tools::file_path_sans_ext(f), ".swc")
        skel$export_to_swc(outf)
    }
    swcs
}

On Friday, April 1, 2022 at 6:09:50 PM UTC+1 Ibrahim Taştekin wrote:

Greg Jefferis

unread,
Sep 15, 2022, 5:21:00 AM9/15/22
to nat-user
That's great, Ibo. I have added (I hope) a slightly more general fix based on what you found. https://github.com/natverse/fafbseg/issues/164
Reply all
Reply to author
Forward
0 new messages