Skip to content

Commit

Permalink
Merge pull request #372 from favreau/master
Browse files Browse the repository at this point in the history
Added connectome population name to add_astrocytes API
  • Loading branch information
favreau committed May 23, 2024
2 parents 552d32a + e9c3666 commit 84cc1d8
Show file tree
Hide file tree
Showing 14 changed files with 77 additions and 46 deletions.
1 change: 1 addition & 0 deletions bioexplorer/backend/science/api/Params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -944,6 +944,7 @@ bool from_json(AstrocytesDetails &param, const std::string &payload)
FROM_JSON(param, js, assemblyName);
FROM_JSON(param, js, populationName);
FROM_JSON(param, js, vasculaturePopulationName);
FROM_JSON(param, js, connectomePopulationName);
FROM_JSON(param, js, loadSomas);
FROM_JSON(param, js, loadDendrites);
FROM_JSON(param, js, generateInternals);
Expand Down
5 changes: 3 additions & 2 deletions bioexplorer/backend/science/common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -1469,9 +1469,10 @@ typedef struct
std::string assemblyName;
/** Name of the population of astrocytes */
std::string populationName;
/** Name of the vasculature population. If not empty, endfeet are
* automatically loaded */
/** Name of the vasculature population. If not empty, endfeet are automatically loaded */
std::string vasculaturePopulationName;
/** Name of the connectome population. If not empty, endfeet are automatically loaded */
std::string connectomePopulationName;
/** Load somas if set to true */
bool loadSomas{true};
/** Load dendrites if set to true */
Expand Down
5 changes: 2 additions & 3 deletions bioexplorer/backend/science/io/db/DBConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ namespace db
{
const std::string DB_SCHEMA_OUT_OF_CORE = "outofcore";
const std::string DB_SCHEMA_METABOLISM = "metabolism";
const std::string DB_SCHEMA_CONNECTOME = "connectome";

DBConnector* DBConnector::_instance = nullptr;
std::mutex DBConnector::_mutex;
Expand Down Expand Up @@ -568,7 +567,7 @@ SectionMap DBConnector::getAstrocyteSections(const std::string& populationName,
return sections;
}

EndFootMap DBConnector::getAstrocyteEndFeet(const std::string& vasculaturePopulationName,
EndFootMap DBConnector::getAstrocyteEndFeet(const std::string& vasculaturePopulationName, const std::string& connectomePopulationName,
const uint64_t astrocyteId) const
{
CHECK_DB_INITIALIZATION
Expand All @@ -584,7 +583,7 @@ EndFootMap DBConnector::getAstrocyteEndFeet(const std::string& vasculaturePopula
"c.endfoot_compartment_length, c.endfoot_compartment_diameter "
"* "
"0.5 FROM " +
DB_SCHEMA_CONNECTOME + ".glio_vascular as c, " + vasculaturePopulationName +
connectomePopulationName + ".glio_vascular as c, " + vasculaturePopulationName +
".node as n WHERE c.vasculature_node_guid=n.guid AND "
"c.astrocyte_guid=" +
std::to_string(astrocyteId);
Expand Down
3 changes: 2 additions & 1 deletion bioexplorer/backend/science/io/db/DBConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,11 @@ class DBConnector
* @brief Get the end-feet as nodes for a given astrocyte
*
* @param vasculaturePopulationName Name of the vasculature population
* @param connectomePopulationName Name of the connectome population
* @param astrocyteId Identifier of the astrocyte
* @return EndFootNodesMap A map of end-feet
*/
morphology::EndFootMap getAstrocyteEndFeet(const std::string& vasculaturePopulationName,
morphology::EndFootMap getAstrocyteEndFeet(const std::string& vasculaturePopulationName, const std::string& connectomePopulationName,
const uint64_t astrocyteId) const;

/**
Expand Down
4 changes: 3 additions & 1 deletion bioexplorer/backend/science/morphologies/Astrocytes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ void Astrocytes::_buildModel(const LoaderProgress& callback, const doubles& radi
// End feet
EndFootMap endFeet;
if (loadEndFeet)
endFeet = connector.getAstrocyteEndFeet(_details.vasculaturePopulationName, somaId);
endFeet = connector.getAstrocyteEndFeet(_details.vasculaturePopulationName, _details.connectomePopulationName, somaId);

// Soma radius
uint64_t count = 1;
Expand Down Expand Up @@ -421,6 +421,8 @@ void Astrocytes::_addEndFoot(ThreadSafeContainer& container, const Vector3d& som
connector.getVasculatureNodes(_details.vasculaturePopulationName,
"section_guid=" + std::to_string(endFoot.second.vasculatureSectionId));

if (vasculatureNodes.empty())
continue;
uint64_t startIndex = 0;
uint64_t endIndex = 1;
const auto halfLength = endFoot.second.length / 2.0;
Expand Down
9 changes: 9 additions & 0 deletions bioexplorer/pythonsdk/bioexplorer/bio_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class BioExplorer:
morphology_representation = MorphologyRepresentation
morphology_color_scheme = MorphologyColorScheme
morphology_realism_level = MorphologyRealismLevel

population_color_scheme = PopulationColorScheme

synapse_representation = SynapseRepresentation

Expand Down Expand Up @@ -2814,6 +2816,7 @@ def add_astrocytes(
assembly_name,
population_name,
vasculature_population_name="",
connectome_population_name="",
realism_level=MorphologyRealismLevel.NONE,
load_somas=True,
load_dendrites=True,
Expand All @@ -2838,6 +2841,8 @@ def add_astrocytes(
:population_name: Name of the population of astrocytes
:vasculature_population_name: Name of the vasculature population. Automatically load
end-feet if not empty
:connectome_population_name: Name of the connectome population. Automatically load
end-feet if not empty
:load_somas: Load somas if set to true
:load_dendrites: Load dendrites if set to true
:generate_internals: Generate internals (Nucleus and mitochondria)
Expand All @@ -2859,11 +2864,15 @@ def add_astrocytes(
assert isinstance(scale, Vector3)
assert isinstance(animation_params, CellAnimationParams)
assert isinstance(displacement_params, AstrocyteDisplacementParams)
if vasculature_population_name != '':
if connectome_population_name == '':
raise RuntimeError("A connectome population must be specified together with the vasculature population")

params = dict()
params["assemblyName"] = assembly_name
params["populationName"] = population_name
params["vasculaturePopulationName"] = vasculature_population_name
params["connectomePopulationName"] = connectome_population_name
params["loadSomas"] = load_somas
params["loadDendrites"] = load_dendrites
params["generateInternals"] = generate_internals
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
" assembly_name=assembly_name,\n",
" population_name='Astrocytes',\n",
" vasculature_population_name='vasculature',\n",
" connectome_population_name='connectome',\n",
" load_micro_domains=False,\n",
" load_dendrites=True,\n",
" morphology_color_scheme=be.morphology_color_scheme.SECTION_TYPE,\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@
" assembly_name=assembly_name,\n",
" population_name='astrocytes',\n",
" vasculature_population_name='vasculature',\n",
" population_color_scheme=be.POPULATION_COLOR_SCHEME_ID,\n",
" connectome_population_name='connectome',\n",
" population_color_scheme=be.population_color_scheme.ID,\n",
" radius_multiplier=1.0,\n",
" morphology_color_scheme=be.morphology_color_scheme.SECTION_TYPE,\n",
" realism_level=be.morphology_realism_level.ALL,\n",
Expand All @@ -144,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 13,
"id": "7cd24ef9",
"metadata": {},
"outputs": [],
Expand Down Expand Up @@ -205,9 +206,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
"neuron_population_name = 'o1'\n",
"vasculature_population_name = 'vasculature'\n",
"astrocytes_population_name = 'astrocytes'\n",
"connectome_population_name='connectome'\n",
"\n",
"if load_neuron:\n",
" neuron_sql_filter = 'guid=%d' % neuron_guid\n",
Expand All @@ -79,7 +80,7 @@
" assembly_name=neuron_assembly_name,\n",
" morphology_color_scheme=be.morphology_color_scheme.SECTION_TYPE,\n",
" population_name=neuron_population_name,\n",
" realism_level=realism_level, generate_buttons=True,\n",
" realism_level=realism_level,\n",
" synapses_type=be.neuron_synapse_type.AFFERENT, show_membrane=not load_mesh_neuron,\n",
" generate_internals=True, generate_externals=False,\n",
" sql_node_filter=neuron_sql_filter, scale=scale,\n",
Expand All @@ -106,6 +107,7 @@
" assembly_name=astrocytes_assembly_name,\n",
" population_name=astrocytes_population_name,\n",
" vasculature_population_name=vasculature_population_name,\n",
" connectome_population_name=connectome_population_name,\n",
" radius_multiplier=0.5,\n",
" realism_level=realism_level, generate_internals=True,\n",
" load_somas=True, load_dendrites=True,\n",
Expand Down Expand Up @@ -752,9 +754,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
"vasculature_model = be.add_vasculature(\n",
" assembly_name=vasculature_assembly_name,\n",
" population_name=vasculature_population_name,\n",
" representation=be.VASCULATURE_REPRESENTATION_SECTION,\n",
" representation=be.vascular_representation.SECTION,\n",
" realism_level=be.morphology_realism_level.ALL,\n",
" sql_filter='sqrt(pow(x - %f, 2) + pow(y - %f, 2) + pow(z - %f, 2)) < 200' % (target[0], target[1], target[2])\n",
")"
Expand All @@ -165,11 +165,14 @@
"outputs": [],
"source": [
"astrocytes_assembly_name = 'Astrocytes'\n",
"astrocytes_population_name = 'astrocytes'\n",
"connectome_population_name = 'connectome'\n",
"be.remove_assembly(astrocytes_assembly_name)\n",
"astrocytes_assembly = be.add_assembly(astrocytes_assembly_name)\n",
"astrocytes_model = be.add_astrocytes(\n",
" assembly_name=astrocytes_assembly_name,\n",
" population_name=vasculature_population_name,\n",
" population_name=astrocytes_population_name,\n",
" connectome_population_name=connectome_population_name,\n",
" realism_level=be.morphology_realism_level.ALL,\n",
" generate_internals=True,\n",
" load_somas=True, load_dendrites=True,\n",
Expand Down Expand Up @@ -213,12 +216,12 @@
" for material_id in material_ids:\n",
" mid = material_id % palette_size\n",
" colors.append(palette[mid])\n",
" if mid == be.NEURON_MATERIAL_SYNAPSE:\n",
" if mid in [be.neuron_material.AFFERENT_SYNAPSE, be.neuron_material.EFFERENT_SYNAPSE]:\n",
" opacities.append(opacity)\n",
" shading_modes.append(shading_mode)\n",
" glossinesses.append(glossiness)\n",
" specular_exponents.append(5.0)\n",
" elif mid in [be.NEURON_MATERIAL_VARICOSITY]:\n",
" elif mid in [be.neuron_material.VARICOSITY]:\n",
" opacities.append(opacity)\n",
" shading_modes.append(shading_mode)\n",
" glossinesses.append(glossiness)\n",
Expand Down Expand Up @@ -343,9 +346,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"from tqdm.notebook import tqdm\n",
"\n",
"db_host = os.getenv('DB_HOST')\n",
"db_host = '10.80.7.21'\n",
"db_name = os.getenv('DB_NAME')\n",
"db_user = os.getenv('DB_USER')\n",
"db_password = os.getenv('DB_PASSWORD')\n",
Expand Down Expand Up @@ -165,12 +164,15 @@
"outputs": [],
"source": [
"astrocytes_assembly_name = 'Astrocytes'\n",
"astrocytes_population_name = 'astrocytes'\n",
"connectome_population_name = 'connectome'\n",
"be.remove_assembly(astrocytes_assembly_name)\n",
"astrocytes_assembly = be.add_assembly(astrocytes_assembly_name)\n",
"astrocytes_model = be.add_astrocytes(\n",
" assembly_name=astrocytes_assembly_name,\n",
" population_name=vasculature_population_name,\n",
" population_name=astrocytes_population_name,\n",
" vasculature_population_name=vasculature_population_name,\n",
" connectome_population_name=connectome_population_name,\n",
" radius_multiplier=0.5,\n",
" realism_level=be.morphology_realism_level.ALL,\n",
" generate_internals=True, load_somas=True, load_dendrites=True,\n",
Expand All @@ -191,7 +193,7 @@
"acetylcholin_path = os.path.join(pdb_folder, 'neuromodulation', 'acetylcholin.pdb')\n",
"\n",
"def add_acetylcholin(radius, nb_molecules, radius_multiplier, frame=0):\n",
" protein_representation = be.REPRESENTATION_ATOMS\n",
" protein_representation = be.protein_representation.ATOMS\n",
"\n",
" acetylcholin_assembly_name = 'Acetylcholin'\n",
" acetylcholin_name = 'Acetylcholin'\n",
Expand All @@ -210,7 +212,7 @@
" )\n",
" volume = Volume(\n",
" name=acetylcholin_assembly_name,\n",
" shape=be.ASSEMBLY_SHAPE_FILLED_SPHERE,\n",
" shape=be.assembly_shape.FILLED_SPHERE,\n",
" shape_params=Vector3(radius, 0.0, 0.0),\n",
" protein=acetylcholin)\n",
" be.add_volume(\n",
Expand Down Expand Up @@ -258,7 +260,7 @@
"\n",
" for material_id in material_ids:\n",
" mid = material_id % palette_size\n",
" if mid == be.NEURON_MATERIAL_SYNAPSE:\n",
" if mid == [be.neuron_material.AFFERENT_SYNAPSE, be.neuron_material.EFFERENT_SYNAPSE]:\n",
" colors.append(palette[0])\n",
" opacities.append(1.0)\n",
" shading_modes.append(shading_mode)\n",
Expand Down Expand Up @@ -560,9 +562,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -235,12 +235,15 @@
"outputs": [],
"source": [
"astrocytes_assembly_name = 'Astrocytes'\n",
"astrocytes_population_name = 'astrocytes'\n",
"connectome_population_name = 'connectome'\n",
"be.remove_assembly(astrocytes_assembly_name)\n",
"astrocytes_assembly = be.add_assembly(astrocytes_assembly_name)\n",
"astrocytes_model = be.add_astrocytes(\n",
" assembly_name=astrocytes_assembly_name,\n",
" population_name=vasculature_population_name,\n",
" population_name=astrocytes_population_name,\n",
" vasculature_population_name=vasculature_population_name,\n",
" connectome_population_name=connectome_population_name,\n",
" radius_multiplier=0.5,\n",
" realism_level=be.morphology_realism_level.ALL,\n",
" generate_internals=True, load_somas=True, load_dendrites=True,\n",
Expand Down Expand Up @@ -323,13 +326,13 @@
"\n",
" for material_id in material_ids:\n",
" mid = material_id % palette_size\n",
" if mid == be.NEURON_MATERIAL_SYNAPSE:\n",
" if mid in [be.neuron_material.AFFERENT_SYNAPSE, be.neuron_material.EFFERENT_SYNAPSE]:\n",
" colors.append(palette[1])\n",
" opacities.append(1.0)\n",
" shading_modes.append(shading_mode)\n",
" glossinesses.append(glossiness)\n",
" specular_exponents.append(5.0)\n",
" elif mid in [be.NEURON_MATERIAL_VARICOSITY]:\n",
" elif mid in [be.neuron_material.VARICOSITY]:\n",
" colors.append(palette[min(2, palette_size-1)])\n",
" opacities.append(1.0)\n",
" shading_modes.append(shading_mode)\n",
Expand Down Expand Up @@ -630,9 +633,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.10"
"version": "3.10.12"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
}

0 comments on commit 84cc1d8

Please sign in to comment.