Skip to content

Commit

Permalink
Working in serial
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Oct 20, 2023
1 parent 305f2ab commit 236f473
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
42 changes: 26 additions & 16 deletions examples/notebooks/bend_morphologies.ipynb

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion snudda/place/bend_morphologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def bend_morphology(self, morphology: NeuronMorphologyExtended, k=30e-6, n_rando

# Cache the random numbers for segments in the section...
if dist > parent_dist and self.rng.uniform() < P_move:
# if self.rng.uniform() < P_move:

morphology_changed = True
parent_moved = True
Expand Down Expand Up @@ -340,9 +341,10 @@ def write_swc(self, morphology: MorphologyData, output_file, comment=None):

print(f"Wrote {output_file}")

def edge_avoiding_morphology(self, swc_file, new_file):
def edge_avoiding_morphology(self, swc_file, new_file, original_position, original_rotation):

md = MorphologyData(swc_file=swc_file)
md.place(rotation=original_rotation, position=original_position)
rot_rep, morphology_changed = self.bend_morphology(md)

if morphology_changed:
Expand Down
4 changes: 3 additions & 1 deletion snudda/place/place.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,9 @@ def avoid_edges(self, neuron_id=None):
# Returns None if unchanged
new_morph_name = os.path.join(bend_morph_path, f"{neuron.name}-{neuron.neuron_id}.swc")
new_morphology = bend_morph[volume_id].edge_avoiding_morphology(swc_file=neuron.swc_filename,
new_file=new_morph_name)
new_file=new_morph_name,
original_position=neuron.position,
original_rotation=neuron.rotation)

if new_morphology:
# Replace the original morphology with the warped morphology, morphology includes rotation
Expand Down

0 comments on commit 236f473

Please sign in to comment.