bbp_workflow.simulation.sim_writer

Simulation campaign writer.

Functions

generate_campaign(config, ...[, validate_output])

Generate simulation campaign.

generate_stim_file(*, path, noise_rate, **_)

Map noise_rate to input spike file at path location.

parse_circuit_config(path)

Assert that circuit config path exists and return the parsed CircuitConfig.

user_target_processor(path[, user_target])

Map user_target file path to file name while copying it to path location.

bbp_workflow.simulation.sim_writer.generate_campaign(config, coords_filter_func, param_processors, workers, set_progress_percentage, rnd, validate_output=True)

Generate simulation campaign.

Parameters:
  • config (xarray.DataArray) –

    Simulation campaign configuration. Config must contain at least the following:

    • name: Full path will be: attrs.path_prefix/name.

    • attrs.path_prefix: base location of the generated campaign.

    • attrs.blue_config_template: path to the blue config cheetah template file.

    • attrs.circuit_config: circuit config path. CircuitConfig file properties will be available for use in the template placeholders. For convenience Run_Default section properties will be available directly(ex. $MorphologyPath). Properties from the other sections need to be accessed by direct path(ex. $Projection_Thalamocortical_input_VPM.Path).

    • attrs.user_target: optional path to the custom user target file. It will be copied to the generated simulation folders. And user_target_file_name placeholder will be available for use in the template. See user_target_processor().

    • attrs.rnd_seed_range: optional list of two parameters to numpy randint function to generate seed placeholder value for simulation campaign.

  • coords_filter_func (str) – Full name(package.module.func) of a coords filter function. Should return True for coords values to keep. As an additional arguments will receive: idx and {coord_name}_idx. If not provided all coords will be kept.

  • param_processors (tuple) – Collection of parameter processing functions. Check some examples: default_ca_treatment and generate_stim_file().

  • workers (int) – Parallelization level of campaign generation.

  • set_progress_percentage (Callable) – Luigi progress callback.

  • rnd (numpy.random.Generator) – Random number generator.

Returns:

Copy of config with config.data pointing to the locations of the blue configs.

bbp_workflow.simulation.sim_writer.generate_stim_file(*, path, noise_rate, **_)

Map noise_rate to input spike file at path location.

file_name = "input.spikes"
(Path(path) / file_name).write_text(f"my input spikes at {noise_rate}")
return {"stim_file": file_name}
bbp_workflow.simulation.sim_writer.parse_circuit_config(path)

Assert that circuit config path exists and return the parsed CircuitConfig.

Parameters:

path (str) – Path to the circuit config file or sonata json.

Returns:

libsonata.CircuitConfig Parsed circuit config.

bbp_workflow.simulation.sim_writer.user_target_processor(path, user_target=None)

Map user_target file path to file name while copying it to path location.

This map function is always invoked when generating simulation campaigns, so you don’t have to enable it explicitly.

if user_target:
    user_target = Path(user_target)
    assert user_target.exists(), f"Not found: {user_target}"
    shutil.copy(user_target, path)
    return {"user_target_file_name": user_target.name}
else:
    return {}