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][REF] Cortex #553

Merged
merged 45 commits into from
Jan 27, 2024
Merged

[ENH][REF] Cortex #553

merged 45 commits into from
Jan 27, 2024

Conversation

jgranley
Copy link
Member

@jgranley jgranley commented Jun 12, 2023

This is finally it! Adds support for simulation of cortical prostheses. Visual field maps, models, implants, 3D models, MRI/neuropythy, its all here.

Overview of changes

This includes all PR's for the cortex branch. It may be easier to review the individual PR's.

Implants

Topography

Models

Misc

Open questions / sharp bits

  • How to handle models that cannot separate temporal and spatial components (Dynaphos does this and thus extends BaseModel).
  • Consistent model naming (Dynaphos has 3 first authors, Dynaphos was chosen to match their code base)
  • Another ScoreboardModel in models.cortex. Does 2 separate ones (one for cortex and one for retina) make sense?
  • vfmap instead of retinotopy? Neuropythy for example uses retinotopy everywhere.

Open TODO's

I will likely make issues for these but I think we should go ahead and merge now.

  • Doc example for Neuropythy and Neuralink, add to cortex intro.
  • Add from_neuropythy for ensemble implant to support placing one or more e.g. cortivis or icvp across the 3D cortex perpendicular to surface, like it does for neuralink

Type of Change

Please delete options that are not relevant.

  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

jgranley and others added 30 commits January 17, 2023 11:06
…l areas (#509)

* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* update requirements

* update base.py for new grid class

* Grid class now supports multiple layers

* refactor layer to be region

* Add region_mappings, RetinalMap

* Fixed overwriting static attributes

* Base class for cortical models

* [MNT] Update requirements.txt (#507)

* Add tests, made inv transforms optional to overwrite

* update with named tuple coordinate grids, and ret_to_dva etc
"

* refactor everything to ret_to_dva

* Update static ret2dva references

* removed backwards compatibility for ret2dva

* update doc
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)
…518)

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* add topography module

* fix imports

* refactor tests for topography module

* doc

* add epmty submodules for implants.cortex and models.cortex
* add cortivis implant and tests

* update cortivis docstring

* Remove eye

* remove eye parameter from cortivis constructor

* remove eye from orion implant

* Removed override on plot function

* Remove override on plot function in orion

* Add pretty print to cortivis

* Add pretty print to orion

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* add constructor to cortex.py

* add v1 and v2 test cases, hemisphere inversion

* add inverse mapping for v3 and related tests

* add extra checks to test_cortex.py

* add vertical inversion for mapping

* add tests for y-ordering in v1, v2, v3

* add border continuity tests & y inversion tests

* [MNT][FIX] Remove outdated ubuntu workflows, add Jax version requirement (#529)

* Remove 18.04, add 20.04

* Add python version to display name

* remove python version

* add jax version

* Fix jax version

* test for wheels: remove jax version

* Add jax version back

* test for wheels: remove jax version

* Add jax version back

* test for wheels

* also skip win32 for python3.7

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
Co-authored-by: Luke Yoffe <lukeyoffe@umail.ucsb.edu>
* add scoreboard cortex

* Replace outdated references to utils.*Map

* fix unrelated jax error: require older jax

* add doc and skeleton tests

* docstrings

* req

* add cortex model, changes to polimeni map

* bug fixes

* add some initial tests

* add equality check

* visual field maps inherit from basemodel

* add offset to polimeni, allow polimeni to cross x axis

* fix inverse transforms

* finished tests

* update topography tests for float32

* make test simpler

* test w print for mx

* test w print for mx

* more tests for mac

* more tests for mac

* improve numerical stability

* improve numerical stability test

* remove debug, add comments
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* [MNT][FIX] Remove outdated ubuntu workflows, add Jax version requirement (#529)

* Remove 18.04, add 20.04

* Add python version to display name

* remove python version

* add jax version

* Fix jax version

* test for wheels: remove jax version

* Add jax version back

* test for wheels: remove jax version

* Add jax version back

* test for wheels

* also skip win32 for python3.7

* update test

* add axis labeling

---------

Co-authored-by: isaac hoffman <trsileneh@gmail.com>
* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* [ENH][REF] Modify Grid2D and VisualFieldMap to support multiple visual areas (#509)

* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* update requirements

* update base.py for new grid class

* Grid class now supports multiple layers

* refactor layer to be region

* Add region_mappings, RetinalMap

* Fixed overwriting static attributes

* Base class for cortical models

* [MNT] Update requirements.txt (#507)

* Add tests, made inv transforms optional to overwrite

* update with named tuple coordinate grids, and ret_to_dva etc
"

* refactor everything to ret_to_dva

* Update static ret2dva references

* removed backwards compatibility for ret2dva

* update doc

* [REF] Add topography, implants.cortex, and models.cortex submodules (#518)

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* add topography module

* fix imports

* refactor tests for topography module

* doc

* add epmty submodules for implants.cortex and models.cortex

* add orion implant and test

* update cortex __init__.py

* add orion implant and test

* add scoreboard cortex

* Replace outdated references to utils.*Map

* fix unrelated jax error: require older jax

* add doc and skeleton tests

* docstrings

* req

* add cortex model, changes to polimeni map

* bug fixes

* add some initial tests

* add equality check

* visual field maps inherit from basemodel

* add offset to polimeni, allow polimeni to cross x axis

* fix inverse transforms

* finished tests

* update topography tests for float32

* make test simpler

* test w print for mx

* test w print for mx

* more tests for mac

* more tests for mac

* improve numerical stability

* improve numerical stability test

* remove debug, add comments

* loop through transforms in grid2d plot

* change grid plot to use retinotopy

* add documentation for use_dva param in grid2d plot

* fix style=hull plot bug, changed default colors

* change default grid plot color to gray, fix hull style when using use_dva=True, make discontinuity check cleaner

* update default plotting, tests

---------

Co-authored-by: jgranley <jgranley@ucsb.edu>
Co-authored-by: isaac hoffman <trsileneh@gmail.com>
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* [MNT][FIX] Remove outdated ubuntu workflows, add Jax version requirement (#529)

* Remove 18.04, add 20.04

* Add python version to display name

* remove python version

* add jax version

* Fix jax version

* test for wheels: remove jax version

* Add jax version back

* test for wheels: remove jax version

* Add jax version back

* test for wheels

* also skip win32 for python3.7

* add separate cortex spatial model

---------

Co-authored-by: isaac hoffman <trsileneh@gmail.com>
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* [MNT][FIX] Remove outdated ubuntu workflows, add Jax version requirement (#529)

* Remove 18.04, add 20.04

* Add python version to display name

* remove python version

* add jax version

* Fix jax version

* test for wheels: remove jax version

* Add jax version back

* test for wheels: remove jax version

* Add jax version back

* test for wheels

* also skip win32 for python3.7

* [FIX] Use pandas concat instead of append (#540)

---------

Co-authored-by: isaac hoffman <trsileneh@gmail.com>
* add EnsembleImplant

* add predict_percept smoke test for ensemble

* add invalid instantiation tests

* Update ensemble.py

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* [FIX] Add check for empty stimulus (#522)

* add check for empty stimulus in stim setter for implants

* add check for empty np.ndarray

* [FIX] Fix electrode numbering annotation in implant.plot() (#523)

* fix implant annotation

* used zorder

* [ENH][REF] Modify Grid2D and VisualFieldMap to support multiple visual areas (#509)

* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* update requirements

* update base.py for new grid class

* Grid class now supports multiple layers

* refactor layer to be region

* Add region_mappings, RetinalMap

* Fixed overwriting static attributes

* Base class for cortical models

* [MNT] Update requirements.txt (#507)

* Add tests, made inv transforms optional to overwrite

* update with named tuple coordinate grids, and ret_to_dva etc
"

* refactor everything to ret_to_dva

* Update static ret2dva references

* removed backwards compatibility for ret2dva

* update doc

* [REF] Add topography, implants.cortex, and models.cortex submodules (#518)

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* add topography module

* fix imports

* refactor tests for topography module

* doc

* add epmty submodules for implants.cortex and models.cortex

* add orion implant and test

* update cortex __init__.py

* add orion implant and test

* add icvp model and tests, fix implant plotting

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
Co-authored-by: isaac hoffman <trsileneh@gmail.com>
* [ENH][REF] Modify Grid2D and VisualFieldMap to support multiple visual areas (#509)

* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* update requirements

* update base.py for new grid class

* Grid class now supports multiple layers

* refactor layer to be region

* Add region_mappings, RetinalMap

* Fixed overwriting static attributes

* Base class for cortical models

* [MNT] Update requirements.txt (#507)

* Add tests, made inv transforms optional to overwrite

* update with named tuple coordinate grids, and ret_to_dva etc
"

* refactor everything to ret_to_dva

* Update static ret2dva references

* removed backwards compatibility for ret2dva

* update doc

* [REF] Add topography, implants.cortex, and models.cortex submodules (#518)

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* add topography module

* fix imports

* refactor tests for topography module

* doc

* add epmty submodules for implants.cortex and models.cortex

* add orion implant and test

* update cortex __init__.py

* add orion implant and test

* Show stim cmap correctly, fix bug with deactivated electrodes

* Show stim cmap correctly, fix bug with deactivated electrodes

* unmark dva_to_v2 and dva_to_v3 as abstract

* remove separate changes

* [FIX] scikit-image/imageio bugfixes (kwargs, saving float32 to png, unexpected saved percepts) (#556)

* fix fps keyword error in percept.save

* update imagestimulus save

* fix percepts saving like bacteria

* remove extension keyword & update image stim save

* update percept video save/load precision test

* throw error when trying to save multi-frame as static image

* wheels build error test

* test ubuntu wheel build fix

* Set default vmin to 0

* catch specifically TypeError for percept save

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>

* [FIX] Update GitHub wheels actions to use available MacOS runner (#557)

* update macos version to use next available runner

* Update wheels.yml (test)

---------

Co-authored-by: jgranley <jgranley@ucsb.edu>

* [FIX] Github wheels for mac (#558)

* Revert "[FIX] Update GitHub wheels actions to use available MacOS runner (#557)"

This reverts commit 405d54e.

* test update wheel

* macos 12

* drop test for wheels on mac for py3.7

* test wheels

* manual exclude

* manual exclude wheels

* manual exclude wheels

* reinclude wheels

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
Co-authored-by: isaac hoffman <ihoffman@ucsb.edu>
* [ENH][REF] Modify Grid2D and VisualFieldMap to support multiple visual areas (#509)

* grid interface changes

* changed valueerror to runtime error in percept save test

* Fix unique time point bug

* temp commit to store grid stuff

* update requirements

* update base.py for new grid class

* Grid class now supports multiple layers

* refactor layer to be region

* Add region_mappings, RetinalMap

* Fixed overwriting static attributes

* Base class for cortical models

* [MNT] Update requirements.txt (#507)

* Add tests, made inv transforms optional to overwrite

* update with named tuple coordinate grids, and ret_to_dva etc
"

* refactor everything to ret_to_dva

* Update static ret2dva references

* removed backwards compatibility for ret2dva

* update doc

* [REF] Add topography, implants.cortex, and models.cortex submodules (#518)

* [MNT] Update requirements.txt (#507)

* [DOC] Fix gallery thumbnail images (#510)

* add topography module

* fix imports

* refactor tests for topography module

* doc

* add epmty submodules for implants.cortex and models.cortex

* add orion implant and test

* update cortex __init__.py

* add orion implant and test

* Show stim cmap correctly, fix bug with deactivated electrodes

* Show stim cmap correctly, fix bug with deactivated electrodes

* change cmap for implant, fix grid plotting

* revert unneeded change

* Also check that the split line will be to the left of xlim[1]

* [FIX] scikit-image/imageio bugfixes (kwargs, saving float32 to png, unexpected saved percepts) (#556)

* fix fps keyword error in percept.save

* update imagestimulus save

* fix percepts saving like bacteria

* remove extension keyword & update image stim save

* update percept video save/load precision test

* throw error when trying to save multi-frame as static image

* wheels build error test

* test ubuntu wheel build fix

* Set default vmin to 0

* catch specifically TypeError for percept save

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>

* [FIX] Update GitHub wheels actions to use available MacOS runner (#557)

* update macos version to use next available runner

* Update wheels.yml (test)

---------

Co-authored-by: jgranley <jgranley@ucsb.edu>

* [FIX] Github wheels for mac (#558)

* Revert "[FIX] Update GitHub wheels actions to use available MacOS runner (#557)"

This reverts commit 405d54e.

* test update wheel

* macos 12

* drop test for wheels on mac for py3.7

* test wheels

* manual exclude

* manual exclude wheels

* manual exclude wheels

* reinclude wheels

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
Co-authored-by: isaac hoffman <ihoffman@ucsb.edu>
* add dynaphos spatial component

* changes to spatial model hemisphere separation

* fix indentation issues

* refactor dynaphos model completely

* dynaphos model fix gaussians

* major changes to dynaphos implementation

* fix t_percept default values

* add check for stim time and test for temporal component of prediction

* update docstring, update default params, update tests

* Rearange docstrings, remove outdated _build

* remove vestigial debug lines, rearrange docstring slightly, & fix freq/pdur check in init

* Add citation

* update dynaphos citation

* fix model build + amp update method

* add plot() function to dynaphos

* [FIX] scikit-image/imageio bugfixes (kwargs, saving float32 to png, unexpected saved percepts) (#556)

* fix fps keyword error in percept.save

* update imagestimulus save

* fix percepts saving like bacteria

* remove extension keyword & update image stim save

* update percept video save/load precision test

* throw error when trying to save multi-frame as static image

* wheels build error test

* test ubuntu wheel build fix

* Set default vmin to 0

* catch specifically TypeError for percept save

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>

* [FIX] Update GitHub wheels actions to use available MacOS runner (#557)

* update macos version to use next available runner

* Update wheels.yml (test)

---------

Co-authored-by: jgranley <jgranley@ucsb.edu>

* [FIX] Github wheels for mac (#558)

* Revert "[FIX] Update GitHub wheels actions to use available MacOS runner (#557)"

This reverts commit 405d54e.

* test update wheel

* macos 12

* drop test for wheels on mac for py3.7

* test wheels

* manual exclude

* manual exclude wheels

* manual exclude wheels

* reinclude wheels

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
* Update cortivis electrode numbering

* update tests for new numbering
* update number to match 2023 cortivis numbering

* update tests for new numbering"
* update default values for mapping and cortivis implant

* update tests for new defaults

* add topography test update

* update defaults again
…xonMapModel OD location (#578)

* flip retinotopy y

* fix tests and various reliances on grid being backwards

* add update for test granley

* more updates

* fix find closest axon

* flip only ydva not yflat

* plotting changes

* flip axon bundle generation

* fix dva_to_ret test in nanduri model

* fix docstring to reflect new iteration order of grid2d (starts at max y instead of min, upper left corner

* add size attribute to grid2d
* test removing cortex imports

* update topography/model circular import

* remove topography import from p2p init

* update setup.py for p2p and p2p/models

* remove cortex import from implants & models init

* move topography imports back out
* update models init

* update implants init
* add build to plot and tes

* pulse2percept/topography/base.py

* add grid to base model constructor, separate COordinateGrid class

* temp

* revert

* finally

* jk but actually works now

* update doc example

* doc update
* include old changes by Luke

* fix submenu layout

* Fix cortex implant API reference docs and add examples

* fix and update models and topography API docs

* add cortex implants in concepts section

* update implants concept; rm minigallery as it doesn't render correctly

* fix docsting example of icvp

* fix cortivis doctest

* Update __init__.py

* Update conf.py

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
apurvvarshney and others added 7 commits December 15, 2023 10:50
* include old changes by Luke

* fix submenu layout

* Fix cortex implant API reference docs and add examples

* fix and update models and topography API docs

* add cortex implants in concepts section

* update implants concept; rm minigallery as it doesn't render correctly

* fix docsting example of icvp

* fix cortivis doctest

* Update __init__.py

* Update conf.py

* add cortical gallery

* create cortical implant basic concept

* fix basic concepts not showing plots and remove minigalleries from other concepts

* rm & convert cortex overview example to a basic concept

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
* add plot_dynaphos, update dynaphos for docs, update models list in docs

* Update models.rst

---------

Co-authored-by: Jacob Granley <jgranley@ucsb.edu>
* add tissue activation threshold to dynaphos

* update dynaphos / cortical docs

* update dynaphos tests

* update dynaphos docstring

* update dynaphos docs
* bump to py 3.11

* remove py 3.7

* update readme

* fix readme
* add optional z coordinate to Grid2D

* add base neuralink classes

* added neuralink (still needs ensemble and tests

* add neuropythy, no tests yet

* add util file

* add neuropythy file

* add random rotation for insertion

* add neuralink plotting

* add neuralink plotting

* remove cython 3d scoreboard temporarily

* update

* add tests qand bug fixes

* add plot3d for grid2d

* fix singular matrix error;

* remove circular imports

* plotting fixes

* set up pytest with slow tests

* add neuropythy tests

* add lots of tests

* add new build file for slow jobs

* update neuropythy tests

* another test update
@jgranley jgranley marked this pull request as ready for review January 13, 2024 21:56
@jgranley
Copy link
Member Author

@mbeyeler We can go over things in a meeting next week too if that is helpful!

@jgranley
Copy link
Member Author

Reminder to self / whoever merges: remember to rebase and merge instead of squash and merge, so that the individual PR's / commits are not lost.

tallyhawley and others added 8 commits January 18, 2024 15:24
* add neuropythy example

* add neuropythy example

* update doc

* restructure cortical.rst
…rdinates (#601)

* add from_coords method to initialize ensemble

* add typecheck for prosthesissystem

* update ensemble from_coords, add from_cortical_map to match from_neuropythy
@jgranley jgranley added this to the v0.9 milestone Jan 27, 2024
@jgranley jgranley merged commit c23baa2 into master Jan 27, 2024
40 checks passed
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.

None yet

4 participants