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
51 stars 50 forks source link

[WIP] Make all plots with time end at stop #752

Closed katduecker closed 2 months ago

katduecker commented 2 months ago

Continues the PR #683 Closes #544

katduecker commented 2 months ago

Hey, I have now taken on this pull request. I'm thinking about the options for the deprecation cycle of defining tmin and tmax for plot_dipole et al.

  1. Should it still be possible to set the xlims using tmax and tmin, and if tmax and tmin aren't defined then rasterplots and dipole are plotted from 0 to stop?
  2. OR should the data always be plotted from 0 to tstop, and the deprecation warning tells the user to set xlim after plotting? (i.e. setting tmin and tmax doesn't do anything)

I'm happy to make all of these clear in the tutorials when I'm done!

jasmainak commented 2 months ago

I think we should not change behavior while deprecating ...

tmin and tmax should be set to None by default. If it is not None, then raise deprecation warning telling the user that they should set directly with plt.xlim() and plt.ylim() to avoid this warning

if it is None, then use the times attribute: extracellular.times, cell_response.times, dipole.times etc.

do the hdf5 files now save times attribute @ntolley ? This was a concern raised by @rythorpe

Thanks for taking over the PR @katduecker !

katduecker commented 2 months ago

Hi all,

I've been trying to push the changes but it keeps failing the CircleCI. I wonder if that is because of a deprecation?

The build_docs test gets stuck when running plot_firing_pattern.py. This is the associated error message.

Screenshot 2024-05-08 at 15 35 13

When I run plot_firing_pattern.py locally, the spike raster is plotted, but I receive this deprecation warning.

Screenshot 2024-05-08 at 15 35 57

It seems that cell_response.times (loaded in from the .txt file) is empty, but net.cell_response.times contains the time points from 0 to tstop. Any ideas on what's going on and why the plot works locally, but not when doing the unit test?

Thanks!

jasmainak commented 2 months ago

@katduecker I am able to reproduce locally. Are you sure you have the editable hnn-core version that you are testing? You can check by:

import hnn_core
hnn_core.__version__
hnn_core.__path__

it should point to your github folder not to the anaconda folder.

katduecker commented 2 months ago

Thanks Mainak. I reinstalled the developer version, cherry picked the PR and added my changes. Now it can't load custom mechanisms.. this is in files that I haven't even edited, so I'm not sure what's causing this

Screenshot 2024-05-08 at 15 35 13

When I run "make test" locally, this error does not come up. I see a bunch of errors with lines being too long etc, but I think that's other people's work as I haven't worked on those scripts...

I do have two local installation of HNN dev (not sure if that's smart?) - one that I'm working on and what that I'm using. However, when I open a jupyter notebook inside the folder that I'm pushing to my repository, it gives me the right path (the version I'm currently working on).

Thanks for your help!

jasmainak commented 2 months ago

Did you look at the contributing guide ?

You need to run the command:

python setup.py build_mod

You don't need two local installations :) Just switch branches on git ... once you have a developer install, you can switch between different versions simply by switching branches.

In case you want to maintain a copy of hnn-core installation for reproducibility reasons, I would recommend creating a separate conda environment for your project and installing hnn-core there.

ntolley commented 2 months ago

@katduecker I think one reason the tests are failing is because the GUI code depends on some of these plotting functions: image

Try running pytest test_gui.py to see if you can reproduce the error locally

ntolley commented 2 months ago

@katduecker I think I figured out the issue. If you're not planning on working on this over the weekend then we can sort things our in person on Monday.

The cleanest solution would be to git reset --hard this branch to the last commit, and then copy in the changes directly. The approach we took (copying in the entire files you had backed up) failed because the master branch was updated since the time you had backed up those files.

If you don't want to mess with the git reset business the alternative is to make a new commit where you copy read_dipole and read_dipole_txt directly from the master branch and paste it into your code. This will remove these functions from the diff, since these were the ones that were updated in the master branch most recently.

katduecker commented 2 months ago

@ntolley thanks so much, that makes sense! I'll get everything ready for Monday up to the point where I'd commit the changes so that we could talk this over before I do to avoid further problems?

katduecker commented 2 months ago

Due to issues when resetting to the commits from this PR, I have opened a new PR #769