Skip to content

Commit

Permalink
Handle an exceptional case when the loaded morphology does not have a…
Browse files Browse the repository at this point in the history
…ny basal dendrites.
  • Loading branch information
marwan-abdellah committed Oct 8, 2018
1 parent 5dc855b commit a99c6de
Show file tree
Hide file tree
Showing 4 changed files with 177 additions and 131 deletions.
60 changes: 33 additions & 27 deletions neuromorphovis/builders/mesh/piecewise_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,33 +286,36 @@ def build_arbors(self,
# Draw the basal dendrites
if not self.options.morphology.ignore_basal_dendrites:

# Do it dendrite by dendrite
for i, basal_dendrite in enumerate(self.morphology.dendrites):
nmv.logger.info('Dendrite [%d]' % i)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

basal_dendrite_objects = []
# Do it dendrite by dendrite
for i, basal_dendrite in enumerate(self.morphology.dendrites):
nmv.logger.info('Dendrite [%d]' % i)

# Draw the basal dendrites as a set connected sections
basal_dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=basal_dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=True,
caps=caps,
sections_objects=basal_dendrite_objects,
roots_connection=roots_connection)
basal_dendrite_objects = []

# Ensure that basal dendrite objects were reconstructed
if len(basal_dendrite_objects) > 0:
# Draw the basal dendrites as a set connected sections
basal_dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=basal_dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=True,
caps=caps,
sections_objects=basal_dendrite_objects,
roots_connection=roots_connection)

# Add a reference to the mesh object
self.morphology.dendrites[i].mesh = basal_dendrite_objects[0]
# Ensure that basal dendrite objects were reconstructed
if len(basal_dendrite_objects) > 0:

# Add a reference to the mesh object
self.morphology.dendrites[i].mesh = basal_dendrite_objects[0]

# Add the sections (tubes) of the basal dendrite to the list
arbors_objects.extend(basal_dendrite_objects)
# Add the sections (tubes) of the basal dendrite to the list
arbors_objects.extend(basal_dendrite_objects)

# Draw the axon as a set connected sections
if not self.options.morphology.ignore_axon:
Expand Down Expand Up @@ -377,11 +380,14 @@ def connect_arbors_to_soma(self):
# Connecting basal dendrites
if not self.options.morphology.ignore_basal_dendrites:

# Do it dendrite by dendrite
for i, basal_dendrite in enumerate(self.morphology.dendrites):
nmv.logger.detail('Dendrite [%d]' % i)
nmv.skeleton.ops.connect_arbor_to_soma(
self.soma_mesh, basal_dendrite)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

# Do it dendrite by dendrite
for i, basal_dendrite in enumerate(self.morphology.dendrites):
nmv.logger.detail('Dendrite [%d]' % i)
nmv.skeleton.ops.connect_arbor_to_soma(
self.soma_mesh, basal_dendrite)

# Connecting axon
if not self.options.morphology.ignore_axon:
Expand Down
174 changes: 98 additions & 76 deletions neuromorphovis/builders/skeleton/skeleton_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,18 +477,23 @@ def draw_morphology_as_disconnected_segments(self,

# Draw the basal dendrites
if not self.options.morphology.ignore_basal_dendrites:
basal_dendrites_segments_objects = []
for i, basal_dendrite in enumerate(self.morphology.dendrites):
dendrite_name = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
self.draw_section_as_disconnected_segments(
basal_dendrite, name=dendrite_name,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
segments_objects=basal_dendrites_segments_objects)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_segments_objects)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

basal_dendrites_segments_objects = []

for i, basal_dendrite in enumerate(self.morphology.dendrites):
dendrite_name = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
self.draw_section_as_disconnected_segments(
basal_dendrite, name=dendrite_name,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
segments_objects=basal_dendrites_segments_objects)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_segments_objects)

# Draw the apical dendrite
if not self.options.morphology.ignore_apical_dendrite:
Expand Down Expand Up @@ -553,19 +558,24 @@ def draw_morphology_as_disconnected_sections(self,

# Draw the basal dendrites
if not self.options.morphology.ignore_basal_dendrites:
basal_dendrites_sections_objects = []
for i, basal_dendrite in enumerate(self.morphology.dendrites):
dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
self.draw_root_as_disconnected_sections(
basal_dendrite,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
sections_objects=basal_dendrites_sections_objects)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

basal_dendrites_sections_objects = []

for i, basal_dendrite in enumerate(self.morphology.dendrites):
dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
self.draw_root_as_disconnected_sections(
basal_dendrite,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
sections_objects=basal_dendrites_sections_objects)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)

# Return a reference to the list of drawn objects
return morphology_objects
Expand Down Expand Up @@ -609,18 +619,22 @@ def draw_morphology_as_articulated_sections(self,

# Draw the basal dendrites joints
if not self.options.morphology.ignore_basal_dendrites:
basal_dendrites_spheres_objects = []
for i, basal_dendrite in enumerate(self.morphology.dendrites):

# Draw the basal dendrites as a set connected sections
self.draw_section_terminals_as_spheres(
root=basal_dendrite,
sphere_objects=basal_dendrites_spheres_objects,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
material_list=self.articulation_materials)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_spheres_objects)
basal_dendrites_spheres_objects = []
for i, basal_dendrite in enumerate(self.morphology.dendrites):

# Draw the basal dendrites as a set connected sections
self.draw_section_terminals_as_spheres(
root=basal_dendrite,
sphere_objects=basal_dendrites_spheres_objects,
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
material_list=self.articulation_materials)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_spheres_objects)

# Draw the apical dendrite joints
if not self.options.morphology.ignore_apical_dendrite:
Expand Down Expand Up @@ -696,29 +710,33 @@ def draw_morphology_as_connected_sections(self,
# Draw the basal dendrites
if not self.options.morphology.ignore_basal_dendrites:

# A list to keep all the drawn objects of the basal dendrites
basal_dendrites_sections_objects = []
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

# A list to keep all the drawn objects of the basal dendrites
basal_dendrites_sections_objects = []

# Draw each basal dendrites as a set connected sections
for i, basal_dendrite in enumerate(self.morphology.dendrites):

dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=repair_morphology,
caps=True,
sections_objects=basal_dendrites_sections_objects,
render_frame=self.options.morphology.render_progressive,
frame_destination=self.progressive_frames_directory,
camera=self.progressive_rendering_camera,
roots_connection=self.options.morphology.arbors_to_soma_connection,
ignore_branching_samples=disconnect_skelecton)

# Draw each basal dendrites as a set connected sections
for i, basal_dendrite in enumerate(self.morphology.dendrites):
dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=repair_morphology,
caps=True,
sections_objects=basal_dendrites_sections_objects,
render_frame=self.options.morphology.render_progressive,
frame_destination=self.progressive_frames_directory,
camera=self.progressive_rendering_camera,
roots_connection=self.options.morphology.arbors_to_soma_connection,
ignore_branching_samples=disconnect_skelecton)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)
# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)

# Draw the apical dendrite
if not self.options.morphology.ignore_apical_dendrite:
Expand Down Expand Up @@ -849,28 +867,32 @@ def draw_morphology_as_disconnected_skeleton(self,
# Draw the basal dendrites
if not self.options.morphology.ignore_basal_dendrites:

basal_dendrites_sections_objects = []
for i, basal_dendrite in enumerate(self.morphology.dendrites):

# Draw the basal dendrites as a set connected sections
dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=repair_morphology,
caps=True,
sections_objects=basal_dendrites_sections_objects,
render_frame=self.options.morphology.render_progressive,
frame_destination=self.progressive_frames_directory,
camera=self.progressive_rendering_camera,
roots_connection=self.options.morphology.arbors_to_soma_connection,
ignore_branching_samples=True)
# Ensure tha existence of basal dendrites
if self.morphology.dendrites is not None:

basal_dendrites_sections_objects = []

for i, basal_dendrite in enumerate(self.morphology.dendrites):

# Draw the basal dendrites as a set connected sections
dendrite_prefix = '%s_%d' % (nmv.consts.Arbors.BASAL_DENDRITES_PREFIX, i)
nmv.skeleton.ops.draw_connected_sections(
section=copy.deepcopy(basal_dendrite),
max_branching_level=self.options.morphology.basal_dendrites_branch_order,
name=dendrite_prefix,
material_list=self.basal_dendrites_materials,
bevel_object=bevel_object,
repair_morphology=repair_morphology,
caps=True,
sections_objects=basal_dendrites_sections_objects,
render_frame=self.options.morphology.render_progressive,
frame_destination=self.progressive_frames_directory,
camera=self.progressive_rendering_camera,
roots_connection=self.options.morphology.arbors_to_soma_connection,
ignore_branching_samples=True)

# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)
# Extend the morphology objects list
morphology_objects.extend(basal_dendrites_sections_objects)

# Draw the apical dendrite
if not self.options.morphology.ignore_apical_dendrite:
Expand Down
Loading

0 comments on commit a99c6de

Please sign in to comment.