jonescompneurolab / hnn-core

Simulation and optimization of neural circuits for MEG/EEG source estimates
https://jonescompneurolab.github.io/hnn-core/
BSD 3-Clause "New" or "Revised" License
53 stars 52 forks source link

GUI: Connection Probability #841

Open gtdang opened 1 month ago

gtdang commented 1 month ago

Working on the Network configuration export I noticed that the GUI is not using the connection probability in any way.


The connectivity only have a weight widget parameter.

Screenshot 2024-07-31 at 10 20 16 AM

The connectivity widget constructor is shown below. Notice the docstring mentions probability, but it is not in the box construct. It's a bit hard to read but the connectivity box is a vertical box (Vbox) composed of 3 elements:

  1. HTML - Receptor label
  2. w_text_input - Weight widget
  3. HTML - Black horizontal bar https://github.com/jonescompneurolab/hnn-core/blob/a1c94ee2f83e3b7a432fb03daa659f25a05da98a/hnn_core/gui/gui.py#L935-L951

The Problem A problem arises when initializing the new network from widget values. It tries to assign a probability from a widget that does not exist (see below). The vbox_key.children[2].value, is not a probability widget but the html widget that styles the black horizontal bar. So the network actually gets assigned a probability value of "<hr style='margin-bottom:5px'/>"! https://github.com/jonescompneurolab/hnn-core/blob/a1c94ee2f83e3b7a432fb03daa659f25a05da98a/hnn_core/gui/gui.py#L1650-L1653


Solution I suppose the easiest solution is to just add the probability as a widget for all the connections. Does this make sense for all types of connections?

ntolley commented 1 month ago

Is it an easy addition? The probability should default to 1.0 for all connections.

If it's straight forward to implement then I would say yes, it's a line of investigation that people haven't gone down because it wasn't possible in the old GUI

gtdang commented 1 month ago

Do all connections and all weights have an associated probability? Or is it conditional?

ntolley commented 1 month ago

Whenever you call net.add_connection to add a drive or connect cell types, there's a probability argument that let's you randomly select some subset of all possible cell-cell connections. In that sense any entry in the net.connectivity list could have probability < 1.0, but by default it's always set to 1.0.

Where we need to be careful is that net.connectivity[conn_idx]['gid_pairs'] will change depending on the value of probability and conn_seed. Since the GUI builds each connection separately from the widget I don't think this will be a problem, since net.add_connection is still being used when you hit the run button and compile the Network object

gtdang commented 1 month ago

https://github.com/jonescompneurolab/hnn-core/pull/843#issuecomment-2263262202