connectome-neuprint / neuVid

Generates neuroscience videos from high-level descriptions using Blender or VVDViewer.
Other
26 stars 7 forks source link

Import neurons using Codex? #191

Open Specom opened 1 month ago

Specom commented 1 month ago

First of all, thanks for this awesome tool. The way of importing neurons from neuPRINT is super straight forward. I was wondering if there is a similar method using the “Copy view URL to clipboard” button in codex, which does not exist in codex NGL. So far I tried several combinations for importMeshes.py, e.g.: { "neurons": { "source": "precomputed://gs://flywire_v141_m783", "neuron": [NEURONID] },

With neuron ID being a random cell ID. However, I am always getting an error that the OBJ file for this neuron can not be found. I also tried putting it into ‘ ” ’. Do I need to download the swc files for the neurons instead and convert them to OBJs? If so, do you know of any pipeline to get the swc files for these neurons? Best wishes,

Sander

hubbardp commented 1 month ago

I'm happy to see what I can get to work.

But I haven't been able to find the "Copy view URL to clipboard" button. I tried going to flywire.ai, pressing "Explore the Connectome in Codex", enter "MBON" in the "search cells and annotations" box, and then looking through the results page, e.g., https://codex.flywire.ai/app/search?filter_string=MBON .

Would you be able to give a few more instructions, and post a screen shot with that button circled? Thanks.

Specom commented 1 month ago

Dear Philip,

Thanks for the quick response. That button or a similar button is exactly what I was looking for to use your workflow (as in your YouTube videos and documentation of neuVID: point 4 of usage with neuPrint) for flywire data. Basically, when you click 3D viewer on one of the neurons of your link you can access the source and ID of the neurons (ctrl + left click on “cell” in top left corner). In the documentation, I found one section that uses the flywire data:

“Example: Create two groups, "U" containing neurons 3 and 7, "J" containing 6, 4 and 9. The neuron meshes come from the FlyWire FAFB server per the "source". ``json

{
  "neurons": {
    "source": "precomputed://gs://flywire_v141_m783",
    "U": [3, 7],
    "J": [6, 4, 9]
  },”

However, whenever I run the script, the neurons can not be found.

I therefore downloaded all neurons swc files from flywire and tried to use these instead for mesh import with the code provided in the documentation:

{
  "neurons": {
    "source": "./directory-of-swc-files",
    "cerebellum": ["AA0431.swc", "AA0964.swc"]
  },
  ...
}

I get the following error: “Importing 3 neuron meshes Traceback (most recent call last): File "", line 1, in File "C:\Users\Sander\neuVid\neuVid\importMeshes.py", line 269, in objPath = fileToImportForNeuron(neuronSources[i], id, parentForDownloadDir, args.swcCapVertexCount, args.swcAxonRadiusFactor, args.swcDendriteRadiusFactor, File "C:\Users\Sander\neuVid\neuVid\utilsMeshes.py", line 77, in fileToImportForNeuron swcObj = build_swc_obj(swcJson, swcCapVertexCount, swcAxonRadiusFactor, swcDendriteRadiusFactor) File "C:\Users\Sander\neuVid\neuVid\utilsSwc.py", line 120, in build_swc_obj radius1 = parent_item["radius"] * radius_factor[item["type"]] KeyError: 0”

Hope you can help me with this.

Cheers

Sander

hubbardp commented 1 month ago

Ah, I thought you were saying there was already a "Copy view URL to clipboard" button on the FlyWire Codex UI that I could not find. If, instead, you want to know how you can import from Codex into neuVid as if there were such a button, take a look at these instructions (which I just updated a bit):

https://github.com/connectome-neuprint/neuVid?tab=readme-ov-file#usage-with-neuroglancer-eg-flywire-codex-openorganelle

The key first step is to find the NGL↗ button near the top of the codex.flywire.ai app. Pressing that button launches Neuroglancer in a separate browser tab, with the full URL in the browser address bar. Click in that address bar and copy the URL, and then follow the rest of the directions. Make sure you are using the latest version of neuVid, as I had to fix a little detail of copying the clipboard.

Working with FlyWire Codex requires a few more steps not required with neuPrint, due to the way Codex stores its meshes, but I think my instructions are thorough.

Specom commented 1 month ago

Dear Philip,

Thanks for the updated documentation. I sticked exactly to the description, however, I am getting dependecy problems:

python D:/neuVid/neuVid/fetchMeshes.py -i ex4.json

(neuVid-NG) C:\Users\Sander>python D:/neuVid/neuVid/fetchMeshes.py -i ex4.json neuVid 1.44.4 Using input file: ex4.json Using decimation fraction: 0.5 Fetching 120 neurons meshes from source precomputed://gs://flywire_v141_m783 Fetching with CloudVolume

A module that was compiled using NumPy 1.x cannot be run in NumPy 2.0.1 as it may crash. To support both 1.x and 2.x versions of NumPy, modules must be compiled with NumPy 2.0. Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to downgrade to 'numpy<2' or try to upgrade the affected module. We expect that some modules will need time to support NumPy 2.

Traceback (most recent call last): File "D:\neuVid\neuVid\fetchMeshes.py", line 309, in fetch_with_cloudvolume(source, ids[i], args.decim_fraction, input_json_dir, args.force) File "D:\neuVid\neuVid\fetchMeshes.py", line 66, in fetch_with_cloudvolume from meshparty import trimesh_io File "C:\Users\Sander\anaconda3\envs\neuVid-NG\lib\site-packages\meshparty\trimesh_io.py", line 32, in import DracoPy Failed to import meshparty and/or trimesh. Run this script in a Conda environment with meshparty and open3d.

Conda list shows me that both meshparty and open3d are installed. Could you specify which version of DracoPy and Numpy you are using?

Running: ipython from meshparty import trimesh_io

gives a similar error:

ImportError Traceback (most recent call last) Cell In[1], line 1 ----> 1 from meshparty import trimesh_io

File ~\anaconda3\envs\neuVid-NG\lib\site-packages\meshparty\trimesh_io.py:32 30 from pymeshfix import _meshfix 31 from tqdm import trange ---> 32 import DracoPy 33 from meshparty import utils, trimesh_repair 35 try:

File src\DracoPy.pyx:1, in init DracoPy()

ImportError: numpy.core.multiarray failed to import (auto-generated because you didn't call 'numpy.import_array()' after cimporting numpy; use 'numpy._import_array' to disable if you are certain you don't need it).

Do you have any idea how to fix this? :)

Thanks for your support