Skip to content

Commit

Permalink
Merge pull request #302 from favreau/master
Browse files Browse the repository at this point in the history
Added synapse types to neurons
  • Loading branch information
favreau authored Sep 13, 2023
2 parents 26bf8ed + 14b5045 commit 16c5da6
Show file tree
Hide file tree
Showing 22 changed files with 150 additions and 248 deletions.
2 changes: 1 addition & 1 deletion bioexplorer/backend/science/api/Params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,7 @@ bool from_json(NeuronsDetails &param, const std::string &payload)
FROM_JSON(param, js, loadAxon);
FROM_JSON(param, js, loadBasalDendrites);
FROM_JSON(param, js, loadApicalDendrites);
FROM_JSON(param, js, loadSynapses);
FROM_JSON(param, js, synapsesType);
FROM_JSON(param, js, generateInternals);
FROM_JSON(param, js, generateExternals);
FROM_JSON(param, js, showMembrane);
Expand Down
6 changes: 2 additions & 4 deletions bioexplorer/backend/science/common/SDFGeometries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ Vector4fs SDFGeometries::_getProcessedSectionPoints(const MorphologyRepresentati
const Vector4fs& points)
{
Vector4fs localPoints;
if (representation == MorphologyRepresentation::bezier && points.size() > DEFAULT_BEZIER_STEP * 2)
{
for (double t = 0.0; t <= 1.0; t += 1.0 / static_cast<double>(points.size() * DEFAULT_BEZIER_STEP))
if (representation == MorphologyRepresentation::bezier)
for (double t = 0.0; t <= 1.0; t += 1.0 / static_cast<double>(points.size()))
localPoints.push_back(getBezierPoint(points, t));
}
else
localPoints = points;
return localPoints;
Expand Down
4 changes: 2 additions & 2 deletions bioexplorer/backend/science/common/ThreadSafeContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace common
{
using namespace core;

const float equalityEpsilon = 0.001f;
const float equalityEpsilon = 1e-6f;

ThreadSafeContainer::ThreadSafeContainer(Model& model, const double alignToGrid, const Vector3d& position,
const Quaterniond& rotation, const Vector3d& scale)
Expand Down Expand Up @@ -93,7 +93,7 @@ uint64_t ThreadSafeContainer::addCone(const Vector3f& sourcePosition, const floa
_bounds.merge(scaledDstPosition - scaledDstRadius);
return _addSDFGeometry(materialId, geom, neighbours);
}
if (abs(sourceRadius - targetRadius) < equalityEpsilon)
if (fabs(sourceRadius - targetRadius) < equalityEpsilon)
{
const auto scaledSrcRadius = sourceRadius * scale.x;
const auto scaledDstRadius = targetRadius * scale.x;
Expand Down
15 changes: 13 additions & 2 deletions bioexplorer/backend/science/common/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,8 +330,18 @@ using NeuronsPtr = std::shared_ptr<Neurons>;
class Synapses;
using SynapsesPtr = std::shared_ptr<Synapses>;

enum class MorphologySynapseType
{
none = 0,
afferent = 1,
efferent = 2,
debug = 4,
all = 8
};

typedef struct
{
MorphologySynapseType type;
uint64_t postSynapticNeuronId;
uint64_t postSynapticSectionId;
uint64_t postSynapticSegmentId;
Expand Down Expand Up @@ -1394,6 +1404,7 @@ typedef struct
/** Amplitude applied to the radius */
double amplitude{1.0};
} VasculatureRadiusReportDetails;

typedef struct
{
/** Name of the assembly containing the astrocytes */
Expand Down Expand Up @@ -1461,8 +1472,8 @@ typedef struct
bool loadBasalDendrites{true};
/** Load apical dendrites if set to true */
bool loadApicalDendrites{true};
/** Load synapses if set to true */
bool loadSynapses{false};
/** Type of synapses to load */
morphology::MorphologySynapseType synapsesType{morphology::MorphologySynapseType::none};
/** Generate internal components (nucleus and mitochondria) */
bool generateInternals{false};
/** Generate external components (myelin steath) */
Expand Down
5 changes: 5 additions & 0 deletions bioexplorer/backend/science/common/Utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,11 @@ size_t getMaterialIdFromOrientation(const Vector3d& orientation)
return ((rgb.x & 0x0ff) << 16) | ((rgb.y & 0x0ff) << 8) | (rgb.z & 0x0ff);
}

double rnd0()
{
return static_cast<double>(rand() % 1000) / 1000.0;
}

double rnd1()
{
return static_cast<double>(rand() % 1000 - 500) / 1000.0;
Expand Down
7 changes: 7 additions & 0 deletions bioexplorer/backend/science/common/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,13 @@ double worleyNoise(const core::Vector3d& p, const double cellCount);

size_t getMaterialIdFromOrientation(const core::Vector3d& orientation);

/**
* @brief Return a random double between 0 and 1
*
* @return double A random double between 0 and 1
*/
double rnd0();

/**
* @brief Return a random double between -0.5 and 0.5
*
Expand Down
5 changes: 3 additions & 2 deletions bioexplorer/backend/science/io/db/DBConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,8 @@ SectionMap DBConnector::getNeuronSections(const std::string& populationName, con
return sections;
}

SectionSynapseMap DBConnector::getNeuronSynapses(const std::string& populationName, const uint64_t neuronId,
const std::string& sqlCondition) const
SectionSynapseMap DBConnector::getNeuronAfferentSynapses(const std::string& populationName, const uint64_t neuronId,
const std::string& sqlCondition) const
{
CHECK_DB_INITIALIZATION
SectionSynapseMap sectionSynapseMap;
Expand Down Expand Up @@ -776,6 +776,7 @@ SectionSynapseMap DBConnector::getNeuronSynapses(const std::string& populationNa
const auto preSynapticSectionId = c[0].as<uint64_t>();
const auto preSynapticSegmentId = c[1].as<uint64_t>();
Synapse synapse;
synapse.type = MorphologySynapseType::afferent;
synapse.preSynapticSegmentDistance = c[2].as<double>();
synapse.postSynapticNeuronId = c[3].as<uint64_t>();
synapse.postSynapticSectionId = c[4].as<uint64_t>();
Expand Down
6 changes: 3 additions & 3 deletions bioexplorer/backend/science/io/db/DBConnector.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,16 +258,16 @@ class DBConnector
const std::string& sqlCondition = "") const;

/**
* @brief Get the synapses attached to a given neuron
* @brief Get the afferent synapses attached to a given neuron
*
* @param populationName Name of the population
* @param neuronId Identifier of the neuron
* @param sqlCondition String containing an WHERE condition for the SQL
* statement
* @return SectionSynapseMap A map of synapses
*/
morphology::SectionSynapseMap getNeuronSynapses(const std::string& populationName, const uint64_t neuronId,
const std::string& sqlCondition = "") const;
morphology::SectionSynapseMap getNeuronAfferentSynapses(const std::string& populationName, const uint64_t neuronId,
const std::string& sqlCondition = "") const;

/**
* @brief Get a selection of spikes from a neuron spike report
Expand Down
3 changes: 2 additions & 1 deletion bioexplorer/backend/science/morphologies/Morphologies.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const size_t MATERIAL_OFFSET_SOMA = 1;
const size_t MATERIAL_OFFSET_AXON = 2;
const size_t MATERIAL_OFFSET_DENDRITE = 3;
const size_t MATERIAL_OFFSET_APICAL_DENDRITE = 4;
const size_t MATERIAL_OFFSET_SYNAPSE = 5;
const size_t MATERIAL_OFFSET_AFFERENT_SYNAPSE = 5;
const size_t MATERIAL_OFFSET_EFFERENT_SYNAPSE = 6;
const size_t MATERIAL_OFFSET_MITOCHONDRION = 7;
const size_t MATERIAL_OFFSET_NUCLEUS = 8;
const size_t MATERIAL_OFFSET_MYELIN_SHEATH = 9;
Expand Down
Loading

0 comments on commit 16c5da6

Please sign in to comment.