-
Notifications
You must be signed in to change notification settings - Fork 52
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
WIP: Upgrade plot_morphology #499
base: master
Are you sure you want to change the base?
Conversation
Looks good so far! Let's see how it shapes when you have it working |
hnn_core/viz.py
Outdated
|
||
parameters | ||
---------- | ||
cell_type : instance of net.cell_type[] |
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 doesn't really specify the object being passed to the function since net.cell_types
is a dictionary:
Line 291 in 9850f20
cell_types : dict |
Is the goal to just pass the cell name, or the cell object to the function? If it's the latter, this would be an instance of the Cell
class:
Line 220 in 9850f20
class Cell: |
Agreed! Also @mjpelah I added the tag "WIP" before the title to indicate the PR is still a work in progress. |
One idea I pitched to @mjpelah was to allow |
I like that! Would you have another argument that specifies the soma locations? |
hnn_core/viz.py
Outdated
|
||
for cell in net.cell_types.values(): | ||
ax = _plot_cell(cell, ax=ax, plt=plt, color=colors[i], show=True) | ||
i+=1 |
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.
indexing is for Matlab and C++ folks ;-) enumerate
is more pythonic
Current iteration has three functions in
Output for As you can see, the cells are not offset (next step) as only the L2_pyramidal and L2_basket show, with the others (presumably) behind. I thought I would try this implementation however, after thinking it through with Ryan, I believe it would be best to have one just one function that takes either a single cell or a list (or dictionary), creates a list (if only a single cell was passed in) and iterates through the list, plotting each cell. Thoughts? |
hnn_core/network.py
Outdated
@@ -1271,6 +1271,25 @@ def plot_cells(self, ax=None, show=True): | |||
""" | |||
return plot_cells(net=self, ax=ax, show=show) | |||
|
|||
def plot_cell_morphologies(self, ax=None, show=True): |
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.
can you share a plot or add it to an example once it's ready? so we can see how it looks
I think it's worth thinking through how the user would use the function. If you have a single function for one cell and multiple cells, how would the offsets be plotted? Would you still plot the cell with the same z offset if it was the only cell being plotted? |
hnn_core/viz.py
Outdated
plt.figure() | ||
ax = plt.axes(projection='3d') | ||
|
||
colors = ['b', 'c', 'r', 'm'] |
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 set the colormap (e.g., 'cividis'
) as a default arg when calling the function.
I think the best way to handle this would be to get the morphological radius for each cell and then plot each successive cell at a distance equal to the sum of the radii for each pair of adjacent cells. Then, the user could input a |
We also need the z-axis to be visible ! |
The solution @rythorpe proposed might allow for more readable code. If you used separate functions for a cell vs cells, you would then need a private function (as in the most recent commit) because they're would be a lot shared (redundant) code between the two. This would be fine, calling the private function once for a cell and more than once (for loop) for cells, but how would you set the offset for multiple cells? You could:
I feel like with any of these implementations, it would be difficult to read or there would be redundant code. Alternatively, to have one function that treats any cell (or cells) that are passed in, as a list of cells, and iterate through the list setting a new offset for each subsequent iteration, might be less redundant. |
@jasmainak z-axis as well as x and y? I thought we were first going to get something like this, without z axis: |
actually is it possible to share axis between a 3D plot and a 2D plot? can you try plotting this alongside the LFP to see how it looks? |
but that plot shows the z axis ... |
I was thinking of two separate functions that call a common private function. In each function you pass the position ... when it's only one cell, the position is z=0, when it is called from the method of network to plot all the cell types, use the positions of the cells in the network. |
Oh yes, my mistake. I'm used to x being left right, y being up down, and z being forward back. |
Try to first plot it alongside LFP with 2 subplots and see if it makes sense. Then we can make the code organization nice :) |
Small nitpick, the Perhaps the next PR could merge this functionality and rename |
I like |
any updates here? |
Nothing significant. I've got a poster presentation to create for Monday on the LFP/CSD project so that is taking up most of my time |
This can be saved for another PR, but two things that would be really nice to have in To see an example of how this could be implemented you can check out the changes made here. |
Something went wrong with your git ... And you need to make this a 2D plot or have an option for 2D plot, otherwise I don't know if you can combine it with the LFP plot. |
Yeah, something is off. It almost looks like you rebased @jasmainak I had advised Matt to get the logic down first, as there are a few options we discussed yester of how to place the figure into a subplot so that it looks pretty and is visually aligned with the y-axis of an LFP plot. |
okay sounds good. I just want to make sure you are thinking of that goal. Because the logic and code structure might be slightly different if you have only 2 dimensions to plot the morphology |
@mjpelah looks like you need to rebase :) :) :) |
@jasmainak Yep, just got home, have been busy with all the symposiums and presentations; will rebase and continue tomorrow! |
sounds good, thank @mjpelah |
@jasmainak could we meet very briefly (5-10m) to discuss some things with this PR and some issues I had with git? It would be a big help! |
Sorry I just saw this email. Can you shoot me an email with a zoom id? I can join anytime now |
e3eb74f
to
96ef8c2
Compare
How's it going @mjpelah? Anything we can assist with here? |
Hey Ryan, thanks for checking in. Haven't had time to make progress, will update as soon as I’ve got something. |
Co-authored-by: mjpelah <mjpelah@gmail.com>
96ef8c2
to
c64ced3
Compare
Closes #496
Goals:
viz.py
and correspondingnet.py
method to plot morphologies of the cells within a network:plot_cell_morphologies
plot_cell_morphology
and (new)plot_cell_morphologies
to private method inviz.py
:_plot_cell
So far, the three new methods are setup to discuss code architecture, but not complete.