dbbs-lab / bsb-core

The Brain Scaffold Builder
https://bsb.readthedocs.io
GNU General Public License v3.0
22 stars 16 forks source link

Adding morphologies -> ValueError: setting an array element with a sequence #512

Open dariosannino opened 2 years ago

dariosannino commented 2 years ago

_I added two different morphologies after saving them from neuromorpho.org as .swc files (cell005_GroundTruth.swc; myneuron.swc). I did this with the following procedure:

from bsb.storage import Storage
from bsb.morphologies import Morphology, Branch

morphologies = Storage("hdf5", "morphologies.hdf5").morphologies

morpho = Morphology.from_swc("cell005_GroundTruth.swc")
morphologies.save("cell005_GroundTruth", morpho)

_and then I did this also for myneuron.swc (not showed here) and I ran both the script to allow them to be added into "morphologies.hdf5". _Then I used connection strategies that use morphologies, such as VoxelIntersection and in the end my networkconfiguration.json file looks like this:

{
  "name": "Starting example",
  "storage": {
    "engine": "hdf5",
    "root": "network.hdf5"
  },
  "network": {
    "x": 400.0,
    "y": 600.0,
    "z": 400.0
  },
  "regions": {
    "brain_region": {
      "children": ["base_layer", "top_layer"],
      "type": "stack"
    }
  },
  "partitions": {
    "base_layer": {
      "type": "layer",
      "thickness": 100,
      "stack_index": 0
    },
    "top_layer": {
      "type": "layer",
      "thickness": 100,
      "stack_index": 1
    }  
  },
  "cell_types": {
    "base_type": {
      "spatial": {
        "radius": 2,
        "density": 1e-3,
        "morphologies": [
          {
            "names": [
              "cell005_GroundTruth"
            ]
          }
        ]
      },
      "plotting": {
        "display_name": "Base type cell",
        "color": "#E62314",
        "opacity": 0.5
      }
    },
    "top_type": {
      "spatial": {
        "radius": 7,
        "count": 100,
        "morphologies": [
          {
            "names": [
              "my_neuron"
            ]
          }
        ]
      },
      "plotting": {
        "display_name": "Top type cell",
        "color": "#23E614",
        "opacity": 0.5
      }
    }
  },
  "placement": {
    "base_placement": {
      "strategy": "bsb.placement.ParticlePlacement",
      "cell_types": ["base_type"],
      "partitions": ["base_layer"]
    },
    "top_placement": {
      "strategy": "bsb.placement.ParticlePlacement",
      "cell_types": ["top_type"],
      "partitions": ["top_layer"]
    }
  },
  "after_placement": {

  },
  "connectivity": {
    "A_to_B": {
      "strategy": "bsb.connectivity.VoxelIntersection",
      "presynaptic": {
        "cell_types": [
          "base_type"
        ]
      },
      "postsynaptic": {
        "cell_types": [
          "top_type"
        ]
      }
    }  
  },
  "after_connectivity": {

  },
  "simulations": {

  }
}

When I type "bsb compile -v 3 -p --clear" on Ubuntu I get the following error:

**Traceback (most recent call last):**
  File "/home/dariosannino010797/.pyenv/versions/my-project/bin/bsb", line 8, in <module>
    sys.exit(handle_cli())
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/cli/__init__.py", line 10, in handle_cli
    handle_command(sys.argv[1:], exit=True)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/cli/__init__.py", line 30, in handle_command
    namespace.handler(namespace, dryrun=dryrun)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/cli/commands/__init__.py", line 98, in execute_handler
    self.handler(context)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/cli/commands/_commands.py", line 137, in handler
    network.compile(
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/core.py", line 326, in compile
    self.run_connectivity(c_strats)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/core.py", line 239, in run_connectivity
    pool.execute(loop)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/_pool.py", line 253, in execute
    job.execute(self.owner, job.f, job._args, job._kwargs)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/_pool.py", line 174, in execute
    return f(connectivity, *collections, **kwargs)
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/connectivity/detailed/voxel_intersection.py", line 59, in connect
    self._match_voxel_intersection(
  File "/home/dariosannino010797/.pyenv/versions/3.9.12/envs/my-project/lib/python3.9/site-packages/bsb/connectivity/detailed/voxel_intersection.py", line 111, in _match_voxel_intersection
    tlocs[s:e] = tblock
**ValueError: setting an array element with a sequence. The requested array would exceed the maximum number of dimension of 2.**

What should I do now? How can I solve this problem?

Helveg commented 2 years ago

I put the code blocks in code block formatting, it causes me less pain that way ;p

I'll look into the bug after finishing #473

Can you send me your HDF5 file?

dariosannino commented 2 years ago

I tried to send you an email, because on GitHub is not possible to upload the HDF5 file, but it seems that neither an email works (I tried also with a zip), because I receive an email in which it is written that I cannot deliver such a heavy file and I should reduce the dimension. Do you need the morphology file or also the network one? Because the morphology one is much smaller and it can probably be sent.

On GitHub this is the error:

No file chosen
We don’t support that file type. Try again with a GIF, JPEG, JPG, MOV, MP4, PNG, SVG, CSV, DOCX, FODG, FODP, FODS, FODT, GZ, LOG, MD, ODF, ODG, ODP, ODS, ODT, PDF, PPTX, TXT, XLS, XLSX or ZIP.

Please, if you have some advice tell me how I can send you the file. Should I convert them?

Helveg commented 2 years ago

Do you have an institutional email at UniPV? We have 1TB Google Drive per user, you can upload them there. If not, perhaps on your personal Google Drive?

dariosannino commented 2 years ago

Ok, now I share with you the files from my google drive.

https://drive.google.com/drive/folders/1s2VCNUu-HYsToNQ212IMFUrwVD4B_CWm?usp=sharing