BlueBrain / diameter-synthesis

@@ -34,9 +34,9 @@
Loading
34 34
    return _map_sections(partial(section_path_length, cache=cache), neurite, Section.ileaf)
35 35
36 36
37 -
def build_simpler_model(morphologies, config, neurite_types=None, fit_orders=None):
37 +
def build_simpler_model(morphologies, config, fit_orders=None):
38 38
    """Build diameter model."""
39 -
    neurite_types = config["neurite_types"]
39 +
    neurite_types = config.get("neurite_types")
40 40
    if neurite_types is None:
41 41
        neurite_types = ["basal_dendrite", "apical_dendrite"]
42 42
    if fit_orders is None:
@@ -114,7 +114,7 @@
Loading
114 114
115 115
116 116
# pylint: disable=unused-argument
117 -
def simpler_diametrizer(morphology, coeffs, neurite_types, config, rng=np.random):
117 +
def simpler_diametrizer(morphology, coeffs, neurite_types, config=None, rng=np.random):
118 118
    """Diametrize a morphology."""
119 119
    morphology = Morphology(morphology)
120 120

@@ -31,7 +31,9 @@
Loading
31 31
from diameter_synthesis.build_diameters import build as build_diameters
32 32
from diameter_synthesis.build_models import build as build_model
33 33
from diameter_synthesis.plotting import plot_distribution_fit
34 +
from diameter_synthesis.simpler_diametrizer import build_simpler_model
34 35
from diameter_synthesis.simpler_diametrizer import plot_model
36 +
from diameter_synthesis.simpler_diametrizer import simpler_diametrizer
35 37
36 38
L = logging.getLogger(__name__)
37 39
logging.basicConfig(level=os.environ.get("LOGLEVEL", "INFO"))
@@ -42,6 +44,7 @@
Loading
42 44
43 45
    def default(self, o):  # pylint: disable=method-hidden
44 46
        """Numpy encoder."""
47 +
        # pragma: no cover
45 48
        if isinstance(o, np.ndarray):
46 49
            return o.tolist()
47 50
        if isinstance(o, np.floating):
@@ -215,33 +218,12 @@
Loading
215 218
            list(tqdm(pool.imap(worker, all_neurons), total=len(all_neurons)))
216 219
217 220
218 -
def diametrize_single_neuron(neuron, config=None, apical_point_sec_ids=None):
219 -
    """Diametrize single neuron by learning diameter model from it.
221 +
def diametrize_single_neuron(neuron, neurite_types=None):
222 +
    """Diametrize single neuron by learning simpler diameter model from it.
220 223
221 224
    Args:
222 225
        neuron (mophio.mut.Morphology): neuron to consider.
223 -
        config (dict): dict with entry 'model' and 'diameters' with corresponding dicts, if None,
224 -
            default dict will be used.
225 -
        apical_point_sec_ids (list): list of apical points if any.
226 +
        neurite_types (list): list of neurite types to consider, if None basal/apical will be used
226 227
    """
227 -
    if config is None:
228 -
        config = {
229 -
            "model": {
230 -
                "taper": {"max": 1e-06, "min": -0.1},
231 -
                "terminal_threshold": 2.0,
232 -
                "models": ["generic"],
233 -
                "neurite_types": ["basal", "apical"],
234 -
            },
235 -
            "diameters": {
236 -
                "models": ["generic"],
237 -
                "n_samples": 1,
238 -
                "neurite_types": ["basal", "apical"],
239 -
                "seed": 0,
240 -
                "trunk_max_tries": 100,
241 -
            },
242 -
        }
243 -
244 -
    model_params = build_model([nm.load_neuron(neuron)], config["model"])
245 -
    if apical_point_sec_ids is not None:
246 -
        model_params["apical_point_sec_ids"] = apical_point_sec_ids
247 -
    build_diameters(neuron, ["basal", "apical"], model_params, config["diameters"])
228 +
    model, _ = build_simpler_model([nm.load_neuron(neuron)], {"neurite_types": neurite_types})
229 +
    return simpler_diametrizer(neuron, model, neurite_types)
Files Coverage
diameter_synthesis 83.63%
Project Totals (12 files) 83.63%
diameter-synthesis-py39
Build #2866826344 -
pytest
1
comment:
2
  layout: "diff, flags, files"
3
  behavior: default
4
  require_changes: true
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading