Blue Brain BioExplorer
Neurons.h
Go to the documentation of this file.
1 /*
2  *
3  * The Blue Brain BioExplorer is a tool for scientists to extract and analyse
4  * scientific data from visualization
5  *
6  * This file is part of Blue Brain BioExplorer <https://github.com/BlueBrain/BioExplorer>
7  *
8  * Copyright 2020-2024 Blue BrainProject / EPFL
9  *
10  * This program is free software: you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License as published by the Free Software
12  * Foundation, either version 3 of the License, or (at your option) any later
13  * version.
14  *
15  * This program is distributed in the hope that it will be useful, but WITHOUT
16  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
18  * details.
19  *
20  * You should have received a copy of the GNU General Public License along with
21  * this program. If not, see <https://www.gnu.org/licenses/>.
22  */
23 
24 #pragma once
25 
26 #include "Morphologies.h"
27 
28 #include <science/api/Params.h>
29 #include <science/common/Types.h>
30 
31 namespace bioexplorer
32 {
33 namespace morphology
34 {
35 using Varicosities = std::map<uint64_t, Vector3ds>;
36 
41 class Neurons : public Morphologies
42 {
43 public:
50  Neurons(core::Scene& scene, const details::NeuronsDetails& details, const core::Vector3d& assemblyPosition,
51  const core::Quaterniond& assemblyRotation, const core::LoaderProgress& callback = core::LoaderProgress());
52 
60  Vector4ds getNeuronSectionPoints(const uint64_t neuronId, const uint64_t sectionId);
61 
68  Vector3ds getNeuronVaricosities(const uint64_t neuronId);
69 
70 private:
71  double _getDisplacementValue(const DisplacementElement& element) final;
72 
73  void _logRealismParams();
74 
75  void _buildModel(const core::LoaderProgress& callback);
76 
77  void _buildContours(common::ThreadSafeContainer& container, const NeuronSomaMap& somas);
78 
79  void _buildSurface(const NeuronSomaMap& somas);
80 
81  void _buildSomasOnly(core::Model& model, common::ThreadSafeContainer& container, const NeuronSomaMap& somas);
82 
83  void _buildOrientations(common::ThreadSafeContainer& container, const NeuronSomaMap& somas);
84 
85  void _buildMorphology(common::ThreadSafeContainer& container, const uint64_t neuronId, const NeuronSoma& soma,
86  const uint64_t neuronIndex, const float* voltages = nullptr);
87 
88  SectionSynapseMap _buildDebugSynapses(const uint64_t neuronId, const SectionMap& sections);
89 
90  void _addArrow(common::ThreadSafeContainer& container, const uint64_t neuronId, const core::Vector3d& somaPosition,
91  const core::Quaterniond& somaRotation, const core::Vector4d& srcNode, const core::Vector4d& dstNode,
92  const details::NeuronSectionType sectionType, const size_t baseMaterialId,
93  const double distanceToSoma);
94 
95  void _addSection(common::ThreadSafeContainer& container, const uint64_t neuronId, const uint64_t morphologyId,
96  const uint64_t sectionId, const Section& section, const core::Vector3d& somaPosition,
97  const core::Quaterniond& somaRotation, const double somaRadius, const size_t baseMaterialId,
98  const double mitochondriaDensity, const uint64_t somaUserData, const SectionSynapseMap& synapses,
99  const double distanceToSoma, const common::Neighbours& somaNeighbours,
100  const float voltageScaling = 1.f);
101 
102  void _addSpine(common::ThreadSafeContainer& container, const uint64_t neuronId, const uint64_t morphologyId,
103  const uint64_t sectionId, const Synapse& synapse, const size_t baseMaterialId,
104  const core::Vector3d& surfacePosition, const double radiusAtSurfacePosition);
105 
106  void _addSectionInternals(common::ThreadSafeContainer& container, const uint64_t neuronId,
107  const core::Vector3d& somaPosition, const core::Quaterniond& somaRotation,
108  const double sectionLength, const double sectionVolume, const core::Vector4fs& points,
109  const double mitochondriaDensity, const size_t baseMaterialId);
110 
111  void _addAxonMyelinSheath(common::ThreadSafeContainer& container, const uint64_t neuronId,
112  const core::Vector3d& somaPosition, const core::Quaterniond& somaRotation,
113  const double sectionLength, const core::Vector4fs& points,
114  const double mitochondriaDensity, const size_t materialId);
115 
116  void _addVaricosity(core::Vector4fs& points);
117 
118  void _attachSimulationReport(core::Model& model);
119 
120  const details::NeuronsDetails _details;
121  core::Scene& _scene;
122  Varicosities _varicosities;
123  uint64_t _nbSpines{0};
124  double _maxDistanceToSoma{0.0};
125  core::Vector2d _minMaxSomaRadius{1e6, -1e6};
126  common::SimulationReport _simulationReport;
127  details::NeuronsReportParameters _neuronsReportParameters;
128 };
129 } // namespace morphology
130 } // namespace bioexplorer
The ThreadSafeContainer class is used to load large datasets in parallel. Every individual element is...
Vector3ds getNeuronVaricosities(const uint64_t neuronId)
Get the neuron varicosities location in space.
Definition: Neurons.cpp:1236
Neurons(core::Scene &scene, const details::NeuronsDetails &details, const core::Vector3d &assemblyPosition, const core::Quaterniond &assemblyRotation, const core::LoaderProgress &callback=core::LoaderProgress())
Construct a new Neurons object.
Definition: Neurons.cpp:78
Vector4ds getNeuronSectionPoints(const uint64_t neuronId, const uint64_t sectionId)
Get the neuron section 3D points for a given section Id.
Definition: Neurons.cpp:1213
The abstract Model class holds the geometry attached to an asset of the scene (mesh,...
Definition: Model.h:469
Scene object This object contains collections of geometries, materials and light sources that are use...
Definition: Scene.h:43
std::set< size_t > Neighbours
Definition: Types.h:81
std::map< uint64_t, Vector3ds > Varicosities
Definition: Neurons.h:35
std::map< uint64_t, NeuronSoma > NeuronSomaMap
Definition: Types.h:377
std::map< uint64_t, SegmentSynapseMap > SectionSynapseMap
Definition: Types.h:358
std::map< uint64_t, Section > SectionMap
Definition: Types.h:386
glm::vec< 3, double > Vector3d
Definition: MathTypes.h:143
glm::vec< 2, double > Vector2d
Definition: MathTypes.h:142
std::vector< Vector4f > Vector4fs
Definition: MathTypes.h:140
glm::tquat< double, glm::highp > Quaterniond
Double quaternion.
Definition: MathTypes.h:153
glm::vec< 4, double > Vector4d
Definition: MathTypes.h:144
std::vector< core::Vector3d > Vector3ds
Definition: Types.h:64
std::vector< core::Vector4d > Vector4ds
Definition: Types.h:66