Skip to content
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

[MRG] Add tonic inputs #635

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

chenghuzi
Copy link
Collaborator

As titled.

@chenghuzi chenghuzi changed the title [WIP] Add tonic inputs [MRG] Add tonic inputs Apr 10, 2023
@codecov-commenter
Copy link

codecov-commenter commented Apr 10, 2023

Codecov Report

Merging #635 (a665a57) into master (cdd4050) will decrease coverage by 0.97%.
The diff coverage is 67.61%.

❗ Current head a665a57 differs from pull request most recent head effbdc1. Consider uploading reports for the commit effbdc1 to get more accurate results

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##           master     #635      +/-   ##
==========================================
- Coverage   92.19%   91.23%   -0.97%     
==========================================
  Files          22       22              
  Lines        4282     4426     +144     
==========================================
+ Hits         3948     4038      +90     
- Misses        334      388      +54     
Impacted Files Coverage Δ
hnn_core/gui/gui.py 87.97% <33.84%> (-6.91%) ⬇️
hnn_core/gui/_viz_manager.py 86.93% <64.86%> (-2.91%) ⬇️
hnn_core/cell_response.py 86.87% <97.61%> (+2.34%) ⬆️
hnn_core/cell.py 96.95% <100.00%> (ø)
hnn_core/params.py 91.92% <100.00%> (+0.03%) ⬆️
hnn_core/viz.py 89.60% <100.00%> (+0.36%) ⬆️

... and 1 file with indirect coverage changes

@ntolley
Copy link
Contributor

ntolley commented Apr 17, 2023

@chenghuzi I think a tonic drive is getting added that should be skipped:
image

Do you think you could follow the logic in #619 to filter out invalid tonic drives? I think the culprit function is _extract_drive_specs_from_hnn_params()

@chenghuzi
Copy link
Collaborator Author

_extract_drive_specs_from_hnn_params

sure, but I guess it's _extract_bias_specs_from_hnn_params? Either way I'll check and let you know asap

@chenghuzi
Copy link
Collaborator Author

@chenghuzi I think a tonic drive is getting added that should be skipped: image

Do you think you could follow the logic in #619 to filter out invalid tonic drives? I think the culprit function is _extract_drive_specs_from_hnn_params()

It should be fixed now. I didn’t open a new PR as it’s a minor modification, and adding just a filter condition in _extract_bias_specs_from_hnn_params seems to work.

if drive_type in [
'Evoked', 'Poisson', 'Rhythmic', 'Bursty', 'Gaussian'
'Evoked', 'Poisson', 'Rhythmic', 'Bursty', 'Gaussian', 'Tonic'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not related to this PR, but do we still need references to the 'Gaussian' drive type anywhere in the GUI?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

humm ... but I don't get how you can have a Gaussian drive type. It's not an option in the GUI

hnn_core/gui/gui.py Outdated Show resolved Hide resolved
Comment on lines +970 to +975
start_times[cell_type] = BoundedFloatText(
value=copy.deepcopy(default_data['t0']), description=cell_type,
min=0, max=1e6, step=0.01, **kwargs)
stop_times[cell_type] = BoundedFloatText(
value=copy.deepcopy(default_data['tstop']), description=cell_type,
min=-1, max=1e6, step=0.01, **kwargs)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we set independent start/stop times for each cell type?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean the range? or the data values?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like, I can currently add a single tonic bias that starts and stops at different times depending on the cell type. If someone wants to set different dynamics for different cell types, they should just create separate baises that correspond one-to-one with the different cell types.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree about that ... the GUI should reflect what the hnn-core API says, which is one cell-type per bias

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, a bias is only supposed to target a single cell type?

cell_types = list(drive['amplitude'].keys())
assert set(cell_types) == set(drive['t0'].keys()) == set(
drive['tstop'].keys())
for cell_type in cell_types:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as we discussed above, I think we don't need this external loop ... it will greatly simplify your code and the interface. Just a dropdown for selecting the cell_type is needed

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kind of forgot the details. could you correct me if I am wrong? are you saying that the bias has the same value for all cell types? And thus we don't need to let the user to set different values for different cell types

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we decided that the start and stop times should be the same for all cell types targetted by the tonic drive, but that this needs to be changed at the API-level within Network.add_tonic_bias().

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I think we can simply link those components so that they look all the same. This is the most straightforward solution and visually reinforces to the user they are meant to be the same, rather than implying an error on our end.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check the latest commit, we just linked them alltogether

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be it's own PR but shouldn't take too long. If I get a chance this week, I'm happy to open a PR.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with Ryan that we should add an option to specify the tonic biases using a dictionary so that the logic of network instantiating is not in the GUI. The GUI should be a thin layer on top of the computational core

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should probably be it's own PR but shouldn't take too long. If I get a chance this week, I'm happy to open a PR.

@rythorpe Was this API fix ever worked on? What is the proposed change for the method? Is it to be able to apply the bias to several different cell types in one call?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I never got around to this.

Yes, the idea was to be able to set which cell types are targeted in Network.add_tonic_bias() (similar to the way we set which cells are targeted by setting weights in Network.add_evoked_drive()). The best way to do with would probably be to remove the cell_type arg and modify the amplitude arg to be dict that maps amplitude to a given cell type key.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should certainly fix the API before adding to the GUI

@jasmainak jasmainak mentioned this pull request Apr 2, 2024
3 tasks
@gtdang gtdang linked an issue Apr 2, 2024 that may be closed by this pull request
3 tasks
@kmilo9999 kmilo9999 removed a link to an issue May 21, 2024
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants