Skip to content

Commit

Permalink
Add task to build a circuit MV3 file
Browse files Browse the repository at this point in the history
Change-Id: I239c3d97a364a7437fffa9ed3921eb1b1a45a4fe
  • Loading branch information
adrien-berchet committed Oct 23, 2020
1 parent 123c36a commit 4c19f80
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 1 deletion.
32 changes: 32 additions & 0 deletions synthesis_workflow/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from joblib import Parallel
from tqdm import tqdm

from brainbuilder.app.cells import _place as place
from morphio.mut import Morphology
from neuroc.scale import scale_section
from neuroc.scale import ScaleParameters
Expand Down Expand Up @@ -542,3 +543,34 @@ def _process_scaling_rule(
slope,
intercept,
)


def build_circuit(
cell_composition_path,
mtype_taxonomy_path,
atlas_path,
density_factor=0.01,
seed=None,
):
"""Based on YAML cell composition recipe, build a circuit as MVD3 file with:
- cell positions
- required cell properties: 'layer', 'mtype', 'etype'
- additional cell properties prescribed by the recipe and / or atlas
"""
if seed is not None:
np.random.seed(seed)
return place(
composition_path=cell_composition_path,
mtype_taxonomy_path=mtype_taxonomy_path,
atlas_url=atlas_path,
mini_frequencies_path=None,
atlas_cache=None,
region=None,
mask_dset=None,
density_factor=density_factor,
soma_placement="basic",
atlas_properties=None,
sort_by=None,
append_hemisphere=False,
input_path=None,
)
6 changes: 5 additions & 1 deletion synthesis_workflow/tasks/luigi_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ def __getattribute__(self, name):
return tmp

def __setattr__(self, name, value):
if value is None and name in self.get_param_names():
try:
global_params = self._global_params
except AttributeError:
global_params = {}
if value is None and name in global_params:
L.warning(
"The Parameter '%s' of the task '%s' is set to None, thus the global "
"value will be taken frow now on",
Expand Down
40 changes: 40 additions & 0 deletions synthesis_workflow/tasks/synthesis.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from ..synthesis import add_scaling_rules_to_parameters
from ..synthesis import apply_substitutions
from ..synthesis import build_circuit
from ..synthesis import build_distributions
from ..synthesis import create_axon_morphologies_tsv
from ..synthesis import get_axon_base_dir
Expand Down Expand Up @@ -398,3 +399,42 @@ def run(self):
def output(self):
""""""
return luigi.LocalTarget(self.rescaled_morphs_df_path)


class BuildCircuit(WorkflowTask):
"""Generate cell positions and me-types from atlas, compositions and taxonomy.
Args:
cell_composition_path (str): path to the cell composition file (YAML)
mtype_taxonomy_path (str): path to the taxonomy file (tsv)
density_factor (float): density factor
seed (int): pseudo-random generator seed
"""

cell_composition_path = luigi.Parameter(
description="path to the cell composition file (YAML)"
)
mtype_taxonomy_path = luigi.Parameter(description="path to the taxonomy file (tsv)")
density_factor = luigi.NumericalParameter(
default=0.01,
var_type=float,
min_value=0,
max_value=1,
description="The density of positions generated from the atlas",
)
seed = luigi.IntParameter(default=None, description="pseudo-random generator seed")

def run(self):
""""""
cells = build_circuit(
self.cell_composition_path,
self.mtype_taxonomy_path,
CircuitConfig().atlas_path,
self.density_factor,
self.seed,
)
cells.save(self.output().path)

def output(self):
""""""
return luigi.LocalTarget(CircuitConfig().circuit_somata_path)

0 comments on commit 4c19f80

Please sign in to comment.