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

ENH/VIZ: Add visualization of strength of drives to each celltype #967

Open
asoplata opened this issue Jan 14, 2025 · 9 comments
Open

ENH/VIZ: Add visualization of strength of drives to each celltype #967

asoplata opened this issue Jan 14, 2025 · 9 comments
Labels
enhancement New feature or request visualization

Comments

@asoplata
Copy link
Collaborator

Title is pretty self-explanatory, and this was requested by Stephanie. Add a new plot type that shows how relatively "strong" each drive is to the different celltypes in a given network, such as in https://jonescompneurolab.github.io/hnn-core/stable/auto_examples/workflows/plot_simulate_gamma.html#sphx-glr-auto-examples-workflows-plot-simulate-gamma-py .

@dikshant182004
Copy link

i just wanna confirm that do i have to make the new funtion in hnn_core/viz.py that will handle the visualization of drive strengths across cell types.I am planning to go for heatmap as a part of visualization to determine strength in more understandable form .
Am i going correct ?

@asoplata
Copy link
Collaborator Author

Sure, this sounds like a good approach. Try to use what you can from calling plot_connectivity_matrix or plot_cell_connectivity, and make sure to run make test before pushing any commits. Thanks!

@asoplata asoplata removed the good first issue Good for newcomers label Jan 23, 2025
@asoplata
Copy link
Collaborator Author

Hey @dikshant182004 I have moved the comments related to our installation discussion over to here: #982 . Since installation help is not related to the overall Issue, I will delete the comments in this Issue. If you need further help with installation, please comment in the Discussions thread, not in this Issue.

@dikshant182004
Copy link

dikshant182004 commented Jan 28, 2025

i am using synaptc weights which determine the strength between connection influenced by spatial distances. i have been summing the code but during the test time fail to get any color gradient in a heatmap ,not able to understand where i am going wrong
`for conn in net.connectivity:
src_type = conn['src_type']
target_type = conn['target_type']
if src_type in drive_names and target_type in cell_types:
nc_dict = conn['nc_dict']
drive_idx = drive_names.index(src_type)
cell_idx = cell_types.index(target_type)
src_type_pos = net.pos_dict[src_type]
target_type_pos = net.pos_dict[target_type]

        src_range = np.array(net.gid_ranges[src_type])
        target_range = np.array(net.gid_ranges[target_type])

        for src_gid, target_src_pair in conn['gid_pairs'].items():
            src_idx = np.where(src_range == src_gid)[0][0]
            target_indeces = np.where(np.isin(target_range, target_src_pair))[0]
            for target_idx in target_indeces:
                src_pos = src_type_pos[src_idx]
                target_pos = target_type_pos[target_idx]

                if show_weight:
                    weight, _ = _get_gaussian_connection(
                        src_pos, target_pos, nc_dict,
                        inplane_distance=net._inplane_distance)
                else:
                    weight = 1.0

                strength_matrix[drive_idx, cell_idx] += weight   `

@asoplata
Copy link
Collaborator Author

Instead of trying to solve the problem all at once, I would suggest starting smaller: build a "minimum working example" that works across only a few cells or a single connection type. Get that to work and produce a plot reliably (even if it is a heatmap with only a single square), then refactor it to begin including different types/cells etc. HTH

@dikshant182004
Copy link

dikshant182004 commented Jan 29, 2025

okay actually i have test the code by adding some external drive as implemented in your provided reference and got the results in heatmap which is quite satisfactory which can be seen in this visualization

Image

if this is okay then i can push my commit as it is working perfectly fine .

@dikshant182004
Copy link

??

@asoplata
Copy link
Collaborator Author

Hey Dikshant, please understand that we want to help as much as possible, but our response times can vary. Our developers have finite time and there is a lot of work to do on HNN with different priority levels, but we are working hard to assist everyone.

Regarding the plot, it looks good! I would make some small suggestions:

  1. Instead of using the summed weight values, I would suggest that you "normalize" the data to be between 0 and 1 (one way to do this: https://en.wikipedia.org/wiki/Feature_scaling#Rescaling_(min-max_normalization) ). This is useful when we're more interested in the relative difference between two values than in the absolute difference between two values(e.g. relative: "poisson->L5_pyramidal is about 67% the strength of evoked_drive->L5_pyramidal"). In this case, we're more interested in relative differences. This would change the plot to show only values between 0 and 1, which instantly lets us see how strong a certain connection is versus the maximum strength in the network. Better yet, add this as an optional argument to the plotting function, so that a user can still get the "absolute" version if they want.
  2. Test case: plot a version that has an "empty" drive where all the drive weights are 0 by default, then make sure it's still plotted. This could be a test that you add in test_viz.py for this new plot type.
  3. In the "absolute" case, it would be helpful to indicate the units on the plot itself.

Also, if you feel you have developed the code to a "good working state" that you're satisfied with, or simply in a state where you want feedback on it, please push it to your branch so that I can see it here in this PR. This includes even if it is not the final version that will be merged. Until the PR is accepted and rebased onto our master branch, you have the full freedom to make any code changes to your local branch, including additional commits, or even "rewriting history" if you make mistakes (see here for a guide https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History ). In other words, at least for HNN, don't feel that you only need to push your commits when the code is absolutely complete and finished -- feel free to push your commits as soon as you want! We prefer the latter, actually, since it helps us understand how the code is being developed.

@dikshant182004
Copy link

okay @asoplata i have understood all your sayings and keep that in mind in future ,i have added the funtionality that u have suggested ,if there is something that needs to be corrected do tell me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request visualization
Projects
None yet
Development

No branches or pull requests

2 participants