Skip to content

Commit

Permalink
Updated old code
Browse files Browse the repository at this point in the history
  • Loading branch information
Hjorthmedh committed Nov 27, 2024
1 parent 80a9128 commit be6bf01
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 6 deletions.
9 changes: 8 additions & 1 deletion snudda/neurons/neuron_morphology_extended.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,14 @@ def get_section_coordinates(self, section_id, section_x):
if "neuron" not in self.morphology_data or 3 not in self.morphology_data["neuron"].sections:
raise ValueError(f"No dendrites loaded for neuron {self.swc_filename}")

section = self.morphology_data["neuron"].sections[3][section_id]
try:
section = self.morphology_data["neuron"].sections[3][section_id]
except:
import traceback
print(traceback.format_exc())
import pdb
pdb.set_trace()

sec_x = section.section_x
pos = section.position

Expand Down
26 changes: 23 additions & 3 deletions snudda/plotting/plot_degeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,30 @@

class PlotDegeneration:

def __init__(self, original_network_path, degenerated_network_path):
def __init__(self, original_network_path, degenerated_network_path,
original_input=None, degenerated_input=None,
original_snudda_data=None, degenerated_snudda_data=None):

self.original_plot = SnuddaPlotInputLocations(network_path=original_network_path)
self.degenerated_plot = SnuddaPlotInputLocations(network_path=degenerated_network_path)
if os.path.isfile(original_network_path):
original_network_file = original_network_path
original_network_path = os.path.dirname(original_network_path)
else:
original_network_file = None

if os.path.isfile(degenerated_network_path):
degenerated_network_file = degenerated_network_path
degenerated_network_path = os.path.dirname(degenerated_network_path)
else:
degenerated_network_file = None

self.original_plot = SnuddaPlotInputLocations(network_path=original_network_path,
network_file=original_network_file,
input_file=original_input,
snudda_data=original_snudda_data)
self.degenerated_plot = SnuddaPlotInputLocations(network_path=degenerated_network_path,
network_file=degenerated_network_file,
input_file=degenerated_input,
snudda_data=degenerated_snudda_data)

self.fig_path = os.path.join(degenerated_network_path, "figures")
if not os.path.exists(self.fig_path):
Expand Down
6 changes: 5 additions & 1 deletion snudda/plotting/plot_input_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ def get_input_soma_distance_summary(self, neuron_type, input_name):

def load_input_config(self):

self.input_config = deepcopy(self.input_data["config"])
self.input_config = deepcopy(self.input_data["config"][()])

def get_max_dendrite_distance(self, neuron_type):

Expand Down Expand Up @@ -359,6 +359,8 @@ def load_neuron(self, neuron_id):
if neuron_id not in self.neuron_cache:
neuron_info = self.snudda_load.data["neurons"][neuron_id]

# print(f"Loading: {snudda_parse_path(neuron_info['neuron_path'], self.snudda_data)}")

prot = NeuronPrototype(neuron_path=neuron_info["neuron_path"], neuron_name=neuron_info["name"],
snudda_data=self.snudda_data)

Expand All @@ -373,6 +375,8 @@ def load_neuron(self, neuron_id):
position=position, rotation=rotation)
self.neuron_cache[neuron_id] = nm

print(f"Loading morphology: {nm.swc_filename}")

return self.neuron_cache[neuron_id]

def get_synapse_coords(self, neuron_id, pre_type=None):
Expand Down
2 changes: 1 addition & 1 deletion snudda/utils/swap_to_degenerated_morphologies.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def filter_synapses(self, filter_axon=False):

print(f"Keeping {self.new_hdf5['network/num_synapses'][()]} "
f"out of {self.old_hdf5['network/num_synapses'][()]} synapses "
f"({self.new_hdf5['network/num_synapses'][()] / self.old_hdf5['network/num_synapses'][()]*100:.3f} %)")
f"({self.new_hdf5['network/num_synapses'][()] / np.max(1,self.old_hdf5['network/num_synapses'][()])*100:.3f} %)")

def filter_gap_junctions(self):
# First version, will keep all synapses in memory to write a more efficient file
Expand Down

0 comments on commit be6bf01

Please sign in to comment.