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

Add distance summary plots #48

Merged
merged 9 commits into from
Dec 6, 2023
Merged

Conversation

kaitj
Copy link
Contributor

@kaitj kaitj commented Oct 30, 2023

Proposed changes
Based off of #45 (which should be merged in before this), this PR adds in functionality to create some distance-based summary plots. These include:

  • Connectome - AFIDs coloured by distances on a nilearn glassbrain
  • Histogram - A histogram of the afid distances (similar to what has previously been done for the afids-validator)
  • Scatter - A scatter plot of the afid distances (x - afid label, y - distance)

These all return views to allow the user to choose what they wish to do with it (e.g. save to disk, return html, etc.)

Also added typing stubs for matplotlib and plotly (hence the 400k+ of new lines - these are all the files under the typings directory), which can be ignored.

Types of changes
What types of changes does your code introduce? Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Other (if none of the other choices apply)

Checklist
Put an x in the boxes that apply. You can also fill these out after creating the PR. If you are unsure about any of the choices, don't hesitate to ask!

  • Changes have been tested to ensure that fix is effective or that a feature works.
  • Changes pass the unit tests
  • Code has been run through the poe quality task
  • I have included necessary documentation or comments (as necessary)
  • Any dependent changes have been merged and published

Notes
All PRs will undergo the unit testing before being reviewed. You may be requested to explain or make additional changes before the PR is accepted.

@kaitj kaitj added the enhancement New feature or request label Oct 30, 2023
@kaitj kaitj requested a review from ataha24 October 30, 2023 20:25
@codecov
Copy link

codecov bot commented Oct 30, 2023

Codecov Report

Merging #48 (7c8cc94) into main (e3e19d2) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##              main       #48    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files           14        14            
  Lines          838       965   +127     
==========================================
+ Hits           838       965   +127     
Components Coverage Δ
afids_utils/afids.py 100.00% <ø> (ø)
afids_utils/ext 100.00% <ø> (ø)
afids_utils/metrics.py 100.00% <ø> (ø)
afids_utils/plotting.py 100.00% <100.00%> (ø)
afids_utils/transforms.py 100.00% <ø> (ø)

This commit adds the functionality to generate a summary plot of AFID
distances on a connectome using nilearn.plotting to do so. In doing so,
a complete set of AfidSet distances are provided as an argument, and
coloured based on their distance from "expected" (ground-truth).

Approporiate unit tests are also added in to make sure plots are generated
and of the correct type. During development, generated plots were visually
assessed to ensure generated plots are as expected.

Note: a `pyright: ignore` has been temporarily added to line 230 in
plotting.py until other plot_types are implemented in order to bypass
the pyright error being thrown.
This commit adds the functionality to generate a summary histogram plot
of AFID distances using `plotly`. In doing so, an optional argument has
been added - `afid_labels` for labelling the histogram. If not provided,
`afid_labels`, indices are used to label the histogram.

Appropriate unit tests are also added. During development, generated
plots were visually assessed.

Note: `pyright: ignore` have been added where `afid_labels` is not
expected to be None.

Also added type stubs for plotly.
Knowing if the "distance" is negative can provide some insight - this is
mostly for plotting distances along specific spatial components (e.g. x,
y, z).

These distances will be automatically set in the histogram and upcoming
scatter plots. For the connectome plot, the minimum node value is set by
either taking the smallest value (if negative) or 0 (if positive).
This commit adds functionality to generate a summary scatter plot of
AFID distances using `plotly`. Similar to generating a histogram plot,
this also makes use of the new `afid_labels` argument to label the
markers. If not porvided, indices are used to label the scatter plot.

Appropriate unit tests are alos added, with generated plots visually
assessed during development.
Some tests may fail a HealthCheck due to slow data generation - namely
any tests that try to generate an entire AfidSet. This commit adds a
function to the helpers that disables this check.
This commit adds the slow_generation decorator where appropriate to
disable the health checks for tests where data generation is slow.
Additionally, delete the view that is created from plot_ortho for memory
considerations (`close()` is not a valid command for these views).
@kaitj
Copy link
Contributor Author

kaitj commented Dec 6, 2023

Also merging this one to push development.

@kaitj kaitj merged commit 62fe609 into afids:main Dec 6, 2023
24 checks passed
@kaitj kaitj deleted the enh/plot-distance-summary branch December 6, 2023 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant