JustasB / BlenderNEURON

Exports 3D structure and activity from NEURON simulator to Blender
http://blenderNEURON.org
MIT License
27 stars 7 forks source link

Create classes and an API for the `Cell` and `Branch`/`Section` object #21

Closed Helveg closed 3 years ago

Helveg commented 3 years ago

I'm going to start simple and create a Cell class that is constructed from an iterable of root Sections (or Branches if we want to sound less NEURON-y). Other functionality that now exists can be added on later, I think therefor it's best that I merge to a next branch ;p

The blenderneuron module should contain a _cells attribute that stores them and the following functions:

Any calls to blenderlike stuff should be done from functions within the _blender.controller

Next step will be to give both the Cell and the Section some fancy properties; When the positional properties like the x_vector of a Section or the position/rotation of a Cell is written to, Blender should update, and when it is read we should read from the Blender object, rather than keeping the coords somewhere on the object (should half our memory consumption ;p )

Helveg commented 3 years ago

@JustasB is it OK if we call the old blenderneuron.section.Section a Branch instead? Sounds more spatially and avoids confusion when working with the Neuron RPC

JustasB commented 3 years ago

Yes we can call it Branch

JustasB commented 3 years ago

When the positional properties like the x_vector of a Section or the position/rotation of a Cell is written to, Blender should update, and when it is read we should read from the Blender object, rather than keeping the coords somewhere on the object (should half our memory consumption ;p )

So I like the idea of optimizing mem usage -- this becomes even more important with larger models.

One thing to keep in mind is that there are other features in BN (that I use when constructing the OB model) that rely on being able to quickly switch between different display views of a cell group (e.g. change interaction level from cell to section and back, or save a particular 3d state as JSON "view").

At the expense of increased mem usage, I stored the section hierarchy/coords in an internal version ("a model from MVC"), which could be displayed as different views ("views from MVC"). When cells were modified within a view, the coords from that view format could be read back into the internal format, and then translated back to any other view format.

To preserve flexibility AND reduce mem usage, maybe the internal representation could be stored on HDD instead of internally in Blender's mem?

Helveg commented 3 years ago

Ok, I don't mind storing it in file, I think it will be mostly the same as using the data stored in Blender, so once I get to that point I'll do some profiling and benchmarking to see how both approaches scale!