-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add incomplete Sonata Circuit #222
Conversation
@@ -89,7 +93,7 @@ class ModelType: | |||
"etype": ["fast", "slow", "fast"]} | |||
|
|||
writer = csv.writer(out, delimiter=' ', | |||
quotechar='|', quoting=csv.QUOTE_MINIMAL) | |||
quotechar='|', quoting=csv.QUOTE_MINIMAL, lineterminator='\n') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you have to add lineterminator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It defaults to '\r\n' causing issues when parsing the csv file.
brain/detail/circuit.h
Outdated
{ | ||
LBUNIMPLEMENTED; | ||
return 0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can implement this function also
brain/detail/circuit.h
Outdated
return Strings(); | ||
} | ||
|
||
virtual URI getMorphologyURI(const std::string& /*name*/) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this function I've just realized that you can almost share the same implementation for all subclasses. You need to add a new virtual function getMorphologySource to replace the _morphologySource member variable in the original implementation.
brain/detail/circuit.h
Outdated
output.push_back(rotations[gid]); | ||
return output; | ||
} | ||
virtual Strings getMorphologyNames(const GIDSet& /*gids*/) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be implemented
|
||
BOOST_AUTO_TEST_CASE(sonata_SonataConfig_constructors) | ||
{ | ||
brain::Circuit circuit(TEST_SONATA_SIMPLE_NETWORK_URI); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check an exception is thrown if opening a json file which doesn't exist.
brain/detail/circuit.h
Outdated
{ | ||
const auto& subnetworks = config.getNodes(); | ||
const auto& node = subnetworks.front(); | ||
brion::Nodes nodes(URI(basePath.string() + "/" + node.elements)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, you're assuming that paths are relative, which may not be the case.
The CircuitConfig should deal with all path substitutions and return absolute paths so client code doesn't need to deal with this stuff. As a matter of fact, I missed that you haven't dealt with relative paths at all in the CircuitConfig implementation.
brain/detail/circuit.h
Outdated
|
||
if (subnetworks.size() > 1) | ||
{ | ||
LBWARN << "More than one subnetwork found, ignored." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More than one subnetwork found, ignoring extra ones.
brain/detail/circuit.h
Outdated
const auto populations = nodes.getPopulationNames(); | ||
if (populations.size() > 1) | ||
{ | ||
LBWARN << "More than one population found, ignored." << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
brain/detail/circuit.h
Outdated
if (nodeGroupIDs.size() > 1) | ||
{ | ||
LBWARN << "More than one group ID found, ignored." << std::endl; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dataset has as many elements as cells. You're always going to give a warning unless your circuit has 1 neuron.
What you must check is that all IDs are 0 and throw if there's any other value.
brain/detail/circuit.h
Outdated
} | ||
|
||
virtual URI getMorphologySource() const final { return morphologySource; } | ||
virtual const brion::URI& getCircuitSource() const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code for morphology caching needs to be reviewed. In principle I think this function should be renamed and return the circuit config .json path, but I have to think about it more carefully.
brain/detail/circuit.h
Outdated
|
||
const auto names = | ||
nodeGroup.getAttribute<std::string>("morphology_file", startIdx, | ||
endIdx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this attribute doesn't exist, you have to look up in the CSV file based on the node type. This is exactly the case of ABI's circuits.
brain/detail/circuit.h
Outdated
} | ||
virtual Strings getMorphologyNames() const | ||
{ | ||
return nodeGroup.getAttribute<std::string>("morphology_file"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
UNIMPLEMENTED, the name is a bit misleading, it's not the morphology file names, it's the morphology type names. Which we don't have in ABI's circuits as far as I know.
} | ||
|
||
expectedIdx++; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would just compare nodeGroupIndices to a vector created with std::iota, it's shorter and it doesn't really matter which index is out of order because later we have to implement the indirect code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand how to do that so I will leave like this since we are removing it anyway
brain/detail/circuit.h
Outdated
@@ -222,12 +189,335 @@ class Circuit::Impl | |||
|
|||
URI getMorphologyURI(const std::string& name) const | |||
{ | |||
URI uri(_morphologySource); | |||
URI uri(getMorphologySource()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect, but leave it like that I'll fix it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's mostly OK, I'll take care of the remaining changes.
@@ -214,20 +183,384 @@ class Circuit::Impl | |||
|
|||
virtual Vector3fs getPositions(const GIDSet& gids) const = 0; | |||
virtual size_ts getMTypes(const GIDSet& gids) const = 0; | |||
virtual Strings getMorphologyNames() const = 0; | |||
virtual Strings getMorphologyTypeNames() const = 0; | |||
virtual size_ts getETypes(const GIDSet& gids) const = 0; | |||
virtual Strings getElectrophysiologyNames() const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename this one also for consistency
if (boost::filesystem::path(name).is_absolute()) | ||
return URI(name); | ||
|
||
URI uri(getMorphologySource()); | ||
uri.setPath(uri.getPath() + "/" + name + ".h5"); | ||
return uri; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll review this and change it myself. I will commit on top of your branch head.
brain/detail/circuit.h
Outdated
virtual const brion::Synapse* getSynapseExtra() const = 0; | ||
virtual const brion::Synapse& getSynapsePositions( | ||
const bool afferent) const = 0; | ||
virtual const URI& getSynapseSource() const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm going to do another some other refactorings here also. This design is looking terrible to me. This will also remove the need for the compilation hacks you made below.
const auto attributeNames = nodeGroup.getAttributeNames(); | ||
const bool hasMorpholgyFile = | ||
std::find(attributeNames.begin(), attributeNames.end(), | ||
propertyName) != attributeNames.end(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about adding a function to search for an attribute name in NodeGroup?
retest this please |
Retest this please |
Renamed namespace of hlohmann::json to brion_nlohmann to prevent conflicts with tools linking to Brion and using a different version.
It only has support for getPositions and getRotations so far.