diff --git a/.pylintrc b/.pylintrc index 120ff98..551446a 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,5 +1,5 @@ [MESSAGES CONTROL] -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 +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 [FORMAT] # Maximum number of characters on a single line. diff --git a/connectome_manipulator/access_functions.py b/connectome_manipulator/access_functions.py index 43d6ee0..86e8551 100644 --- a/connectome_manipulator/access_functions.py +++ b/connectome_manipulator/access_functions.py @@ -5,8 +5,6 @@ """Collection of function for flexible nodes/edges access, to be used by model building and manipulation operations""" -from pathlib import Path - import numpy as np import pandas as pd @@ -57,20 +55,6 @@ def get_nodes(nodes, selection=None): return result -def get_morphology_paths(nodes, selection, morpho_helper, extension="swc"): - """Return paths to morphology files corresponding to `selection`. - - Args: - nodes: a bluepysnap node set - selection (libsonata.Selection): a selection of nodes - morpho_helper: a bluepysnap MorphoHelper instance - extension (str): expected filetype extension of the morph file. - """ - morpho_dir = morpho_helper.get_morphology_dir(extension) - result = get_nodes(nodes, selection) - return [Path(morpho_dir, f"{name}.{extension}") for name in result[Node.MORPHOLOGY]] - - def orientations(nodes, node_sel=None): """Node orientation(s) as a list of numpy arrays. diff --git a/connectome_manipulator/connectome_manipulation/manipulation/base.py b/connectome_manipulator/connectome_manipulation/manipulation/base.py index f8dff01..3256828 100644 --- a/connectome_manipulator/connectome_manipulation/manipulation/base.py +++ b/connectome_manipulator/connectome_manipulation/manipulation/base.py @@ -15,7 +15,7 @@ from bluepysnap.morph import MorphHelper from bluepysnap.sonata_constants import Node -from morphio.mut import Morphology +from morphio import Collection import numpy as np from connectome_manipulator import access_functions @@ -94,12 +94,13 @@ def __init__(self, nodes, writer=None, split_index=0, split_total=1): def _get_tgt_morphs(self, morph_ext, tgt_node_sel): """Access function (incl. transformation!), using specified format (swc/h5/...)""" - morphology_paths = access_functions.get_morphology_paths( - self.nodes[1], tgt_node_sel, self.morpho_helper, morph_ext - ) + morpho_dir = self.morpho_helper.get_morphology_dir(morph_ext) + collection = Collection(morpho_dir, [f".{morph_ext}"]) + result = access_functions.get_nodes(self.nodes[1], tgt_node_sel) + morphologies = [] - for mp in morphology_paths: - morphologies.append(Morphology(mp)) + for morpho_name in result[Node.MORPHOLOGY]: + morphologies.append(collection.load(morpho_name, mutable=True)) return self._transform(morphologies, tgt_node_sel) def _transform(self, morphs, node_sel): diff --git a/connectome_manipulator/connectome_manipulation/manipulation/conn_rewiring.py b/connectome_manipulator/connectome_manipulation/manipulation/conn_rewiring.py index d26a47c..5dc2277 100644 --- a/connectome_manipulator/connectome_manipulation/manipulation/conn_rewiring.py +++ b/connectome_manipulator/connectome_manipulation/manipulation/conn_rewiring.py @@ -337,7 +337,7 @@ def apply( tgt_morphs = [None] * num_tgt log.info( - 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})" + 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})" ) # Init/reset static variables (function attributes) related to generation methods which need only be initialized once [for better performance] diff --git a/connectome_manipulator/model_building/conn_props.py b/connectome_manipulator/model_building/conn_props.py index cd65ace..69ac3a8 100644 --- a/connectome_manipulator/model_building/conn_props.py +++ b/connectome_manipulator/model_building/conn_props.py @@ -397,7 +397,7 @@ def merge_uniq(vals, cnts): conn_prop_model["p"][sidx, tidx, pidx] = c / np.sum(c) log.info( - f"Interpolated {missing_list.shape[0]} missing values. Interpolation level counts: { {k: level_counts[k] for k in sorted(level_counts.keys())} }" + f"Interpolated {missing_list.shape[0]} missing values. Interpolation level counts: {{k: level_counts[k] for k in sorted(level_counts.keys())}}" ) # Create model properties dictionary diff --git a/pyproject.toml b/pyproject.toml index 94c25e7..52eb2af 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -9,4 +9,3 @@ include = 'connectome_manipulator\/.*\.py$|tests\/.*\.py$|doc\/source\/conf\.py$ pythonpath = [ "." ] -