Skip to content
This repository was archived by the owner on Feb 26, 2025. It is now read-only.

Commit 37f271c

Browse files
authored
Use MorphIO Collections. (#4)
1 parent 7db6de1 commit 37f271c

File tree

6 files changed

+10
-26
lines changed

6 files changed

+10
-26
lines changed

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[MESSAGES CONTROL]
2-
disable=fixme,invalid-name,len-as-condition,no-else-return,cyclic-import,import-outside-toplevel,useless-object-inheritance,self-assigning-variable,line-too-long,logging-fstring-interpolation,too-many-locals,too-many-branches,too-many-statements,no-member,unspecified-encoding,too-many-arguments,dangerous-default-value,similarities,too-many-lines,consider-using-f-string,broad-exception-caught,too-many-return-statements,eval-used
2+
disable=fixme,invalid-name,len-as-condition,no-else-return,cyclic-import,import-outside-toplevel,useless-object-inheritance,self-assigning-variable,line-too-long,logging-fstring-interpolation,too-many-locals,too-many-branches,too-many-statements,no-member,unspecified-encoding,too-many-arguments,dangerous-default-value,similarities,too-many-lines,consider-using-f-string,broad-exception-caught,too-many-return-statements,eval-used,too-many-positional-arguments
33

44
[FORMAT]
55
# Maximum number of characters on a single line.

connectome_manipulator/access_functions.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
"""Collection of function for flexible nodes/edges access, to be used by model building and manipulation operations"""
77

8-
from pathlib import Path
9-
108
import numpy as np
119
import pandas as pd
1210

@@ -57,20 +55,6 @@ def get_nodes(nodes, selection=None):
5755
return result
5856

5957

60-
def get_morphology_paths(nodes, selection, morpho_helper, extension="swc"):
61-
"""Return paths to morphology files corresponding to `selection`.
62-
63-
Args:
64-
nodes: a bluepysnap node set
65-
selection (libsonata.Selection): a selection of nodes
66-
morpho_helper: a bluepysnap MorphoHelper instance
67-
extension (str): expected filetype extension of the morph file.
68-
"""
69-
morpho_dir = morpho_helper.get_morphology_dir(extension)
70-
result = get_nodes(nodes, selection)
71-
return [Path(morpho_dir, f"{name}.{extension}") for name in result[Node.MORPHOLOGY]]
72-
73-
7458
def orientations(nodes, node_sel=None):
7559
"""Node orientation(s) as a list of numpy arrays.
7660

connectome_manipulator/connectome_manipulation/manipulation/base.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
from bluepysnap.morph import MorphHelper
1717
from bluepysnap.sonata_constants import Node
18-
from morphio.mut import Morphology
18+
from morphio import Collection
1919
import numpy as np
2020

2121
from connectome_manipulator import access_functions
@@ -94,12 +94,13 @@ def __init__(self, nodes, writer=None, split_index=0, split_total=1):
9494

9595
def _get_tgt_morphs(self, morph_ext, tgt_node_sel):
9696
"""Access function (incl. transformation!), using specified format (swc/h5/...)"""
97-
morphology_paths = access_functions.get_morphology_paths(
98-
self.nodes[1], tgt_node_sel, self.morpho_helper, morph_ext
99-
)
97+
morpho_dir = self.morpho_helper.get_morphology_dir(morph_ext)
98+
collection = Collection(morpho_dir, [f".{morph_ext}"])
99+
result = access_functions.get_nodes(self.nodes[1], tgt_node_sel)
100+
100101
morphologies = []
101-
for mp in morphology_paths:
102-
morphologies.append(Morphology(mp))
102+
for morpho_name in result[Node.MORPHOLOGY]:
103+
morphologies.append(collection.load(morpho_name, mutable=True))
103104
return self._transform(morphologies, tgt_node_sel)
104105

105106
def _transform(self, morphs, node_sel):

connectome_manipulator/connectome_manipulation/manipulation/conn_rewiring.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ def apply(
337337
tgt_morphs = [None] * num_tgt
338338

339339
log.info(
340-
f"Rewiring afferent {syn_class} connections to {num_tgt} ({amount_pct}%) of {len(tgt_sel)} target neurons in current split (total={num_tgt_total}, sel_src={sel_src}, sel_dest={sel_dest}, keep_indegree={keep_indegree}, gen_method={gen_method}, keep_conns={keep_conns}, reuse_conns={reuse_conns}, syn_pos_mode={syn_pos_mode}{', morph_ext=' + morph_ext if syn_pos_mode=='random' else ''}, rewire_mode={rewire_mode})"
340+
f"Rewiring afferent {syn_class} connections to {num_tgt} ({amount_pct}%) of {len(tgt_sel)} target neurons in current split (total={num_tgt_total}, sel_src={sel_src}, sel_dest={sel_dest}, keep_indegree={keep_indegree}, gen_method={gen_method}, keep_conns={keep_conns}, reuse_conns={reuse_conns}, syn_pos_mode={syn_pos_mode}{', morph_ext=' + morph_ext if syn_pos_mode == 'random' else ''}, rewire_mode={rewire_mode})"
341341
)
342342

343343
# Init/reset static variables (function attributes) related to generation methods which need only be initialized once [for better performance]

connectome_manipulator/model_building/conn_props.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def merge_uniq(vals, cnts):
397397
conn_prop_model["p"][sidx, tidx, pidx] = c / np.sum(c)
398398

399399
log.info(
400-
f"Interpolated {missing_list.shape[0]} missing values. Interpolation level counts: { {k: level_counts[k] for k in sorted(level_counts.keys())} }"
400+
f"Interpolated {missing_list.shape[0]} missing values. Interpolation level counts: {{k: level_counts[k] for k in sorted(level_counts.keys())}}"
401401
)
402402

403403
# Create model properties dictionary

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ include = 'connectome_manipulator\/.*\.py$|tests\/.*\.py$|doc\/source\/conf\.py$
99
pythonpath = [
1010
"."
1111
]
12-

0 commit comments

Comments
 (0)