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

Integrate BrainGlobe Atlas API to download atlases from within the GUI #75

Merged
merged 47 commits into from
Aug 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
5f226de
Convert import thread docstring types to type hints
yoda-vid Aug 2, 2021
9a014ea
Initial BrainGlobe panel
yoda-vid Aug 2, 2021
ede25c1
Provide defaults arguments when generating lookup reference dictionaries
yoda-vid Aug 3, 2021
1ace774
Support setting up images set by a BrainGlobe atlas
yoda-vid Aug 3, 2021
0c60b4c
Display BrainGlobe atlases
yoda-vid Aug 3, 2021
25119d5
Refactor BrainGlobe related modules into new sub-package
yoda-vid Aug 3, 2021
b4c26e5
Add `bg-atlasapi` as a required dependency
yoda-vid Aug 3, 2021
8df11f3
Release notes for BrainGlobe integration
yoda-vid Aug 3, 2021
1b28920
Change function name to update atlas table
yoda-vid Aug 4, 2021
8480160
Merge branch 'master' into brain_globe
yoda-vid Jun 10, 2022
454fa60
Reverse resolutions for BrainGlobe atlases
yoda-vid Jun 13, 2022
59b48f5
Merge branch 'master' into brain_globe
yoda-vid Jun 14, 2022
774325b
Fix missing `TYPE_CHECKING` import
yoda-vid Jun 14, 2022
973f472
Fix initial image load through GUI
yoda-vid Jun 15, 2022
63e780c
Fix to load BrainGlobe atlas labels reference
yoda-vid Jun 15, 2022
3a51cd4
Fix unnecessary warning when no labels reference paths are given
yoda-vid Jun 15, 2022
65b9a55
Fix stale labels reference when loading a new image without a origina…
yoda-vid Jun 15, 2022
197e6a9
Manually revert resolution reversal for BrainGlobe atlases
yoda-vid Jun 22, 2022
be74bf6
Merge branch 'master' into brain_globe
yoda-vid Jul 7, 2022
8871b5d
Library function to format bytes in human-readable units
yoda-vid Jul 12, 2022
dd29316
Remove IDE-specific config file
yoda-vid Jul 12, 2022
adac847
Change panel name to "Atlases"
yoda-vid Jul 12, 2022
9f7e98d
Use the progress bar for BrainGlobe-related threads
yoda-vid Jul 12, 2022
d9c7a65
Update progress bar during BrainGlobe atlas download
yoda-vid Jul 12, 2022
3f16dc5
Merge branch 'master' into brain_globe
yoda-vid Jul 27, 2022
ea5bbe2
Fix BrainGlobe download progress updates when total reported size is 0
yoda-vid Jul 28, 2022
ebce267
Use BrainGlobe atlas Git repo for required update
yoda-vid Jul 28, 2022
23e1080
Remove trailing spaces from `setup.py`
yoda-vid Jul 28, 2022
f1440ba
Move atlas controls from ROI to atlases panel
yoda-vid Jul 28, 2022
1b919d0
Update pinned requirements for BrainGlobe and Python >= 3.6
yoda-vid Jul 28, 2022
3952d8e
Add back GitHub Actions testing for Python 3.6
yoda-vid Jul 28, 2022
cac9b0d
Run more unit tests in GitHub Actions workflow
yoda-vid Jul 28, 2022
9461768
Fix installing Scikit-image from pinned requirements by Python 3.9
yoda-vid Jul 28, 2022
122afb1
Turn off GitHub Actions testing for image equality
yoda-vid Jul 28, 2022
a57e034
Turn of GitHub Actions unit testing requiring UI
yoda-vid Jul 28, 2022
2326065
Limit VTK dependencies installs to Linux in GitHub Actions
yoda-vid Jul 29, 2022
4ba6bb6
Add macOS as an OS for CI
yoda-vid Jul 29, 2022
00c6ef2
Fix syntax for installing VTK dependencies only on Linux in CI
yoda-vid Jul 29, 2022
9111299
Fix to use single quotes for string in CI expression
yoda-vid Jul 29, 2022
3a229e5
Add Windows runner for CI
yoda-vid Jul 29, 2022
8147a10
Remove if-statement around requirements file in CI
yoda-vid Jul 29, 2022
b10e073
Move Qt off-screen setting to CI environment variable
yoda-vid Jul 29, 2022
e2f92ee
Change BrainGlobe dependency link to ZIP archive
yoda-vid Jul 29, 2022
885745d
Remove printing BrainGlobe atlas string to progress bar
yoda-vid Jul 29, 2022
3564f05
Fix logging error from Rich console by using UTF-8 encoding
yoda-vid Jul 31, 2022
0c256cf
Fix potential error converting NumPy array to SimpleITK `Image`
yoda-vid Aug 4, 2022
68bab96
Fix line width for NumPy to SimpleITK wrapper
yoda-vid Aug 4, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.7, 3.8, 3.9]
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- name: Check out repo
uses: actions/checkout@v2
- name: Install VTK dependencies
if: ${{ runner.os == 'Linux' }}
run: |
sudo apt-get update
sudo apt-get install libsm6 libgl1-mesa-glx
Expand All @@ -43,11 +45,12 @@ jobs:
# check for cache from the corresponding requirements file
key: ${{ env.pythonLocation }}-pip-${{ hashFiles('envs/requirements.txt') }}
- name: Install dependencies
env:
QT_QPA_PLATFORM: offscreen
run: |
python -m pip install --upgrade pip setuptools wheel
pip install flake8
export QT_QPA_PLATFORM=offscreen
if [ -f envs/requirements.txt ]; then pip install -r envs/requirements.txt; fi
pip install -r envs/requirements.txt
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
Expand All @@ -56,6 +59,10 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude stitch
- name: Test with pytest
run: |
# TODO: add image artifact
#python -u -m magmap.tests.unit_testing
python -u -m magmap.tests.test_chunking
python -u -m magmap.tests.test_libmag
# TODO: add UI testing
#python -u -m magmap.tests.test_visualizer
# TODO: add image artifacts
#python -u -m magmap.tests.test_img_equality
#python -u -m magmap.tests.unit_testing
9 changes: 9 additions & 0 deletions .idea/markdown.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion docs/release/release_v1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,7 @@ See the [table of CLI changes](../cli.md#changes-in-magellanmapper-v15) for a su
- Python-Bioformats has been upgraded to 4.0.5 and uses a custom package that uses the existing Javabridge rather than Python-Javabridge to avoid a higher NumPy version requirement
- Workaround for failure to install Mayavi because of a newer VTK, now pinned to 9.0.1
- Matplotlib >= 3.2 is now required
-

#### R Dependency Changes

#### Server dependency Changes
2 changes: 2 additions & 0 deletions docs/release/release_v1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- "Help" buttons added to open the online documentation (#109)
- Default confirmation labels can be set before detection (#115)
- Resets the labels reference file path when reloading an image in the GUI (#139)
- BrainGlobe panel: access atlases hosted by BrainGlobe directly from the GUI (#75)
- Registered image suffixes with variable endings (eg `annotationEdgeLevel<n>`) now show up in the dropdown boxes (#142)
- Registered image and region names are truncated in the middle to prevent expanding the sidebar for long names (#147)
- "Show all" in the Regions section of the ROI panel shows names for all labels (#145)
Expand Down Expand Up @@ -117,6 +118,7 @@
#### Python Dependency Changes

- Python 3.8 is the default version now that Python 3.6 has reached End-of-Life
- The BrainGlobe Atlas API package (`bg-atlasapi`) dependency has been added to access a suite of cloud-based atlases (#75)
- The `dataclasses` backport is installed for Python < 3.7
- `Tifffile` is now a direct dependency, previously already installed as a sub-dependency of other required packages
- Updated to use the `axis_channel` parameter in Scikit-image's `transform.rescale` function (#115)
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ dependencies:
- simpleitk==2.0.2rc2.dev785+g8ac4f
- javabridge==1.0.19.post4+gbebed64
- python-bioformats==4.0.5.post2+g51eb88a
- "https://github.com/brainglobe/bg-atlasapi/archive/refs/heads/master.zip"
92 changes: 43 additions & 49 deletions envs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,71 +6,65 @@ apptools==5.1.0
async-timeout==4.0.2
asynctest==0.13.0
attrs==21.4.0
awscli==1.22.37
boto3==1.20.37
botocore==1.23.37
charset-normalizer==2.0.10
colorama==0.4.3
bg-atlasapi @ git+https://github.com/brainglobe/bg-atlasapi.git@cc980143c88e71202d09cbbd0f1bcfa491ea759d
bg-space==0.6.0
boto3==1.23.10
botocore==1.26.10
certifi==2022.6.15
charset-normalizer==2.0.12
click==8.0.4
commonmark==0.9.1
configobj==5.0.6
cycler==0.11.0
docutils==0.15.2
dataclasses==0.8;python_version<"3.7"
decorator==4.4.2
envisage==6.0.1
et-xmlfile==1.1.0
fonttools==4.28.5
frozenlist==1.2.0
future==0.18.2
idna==3.3
imageio==2.13.5
importlib-metadata==4.10.1
idna-ssl==1.1.0
imageio==2.15.0
importlib-metadata==4.8.3
importlib-resources==5.4.0
iniconfig==1.1.1
javabridge==1.0.19.post4+gbebed64
Jinja2==3.0.3
jmespath==0.10.0
joblib==1.1.0
kiwisolver==1.3.2
MarkupSafe==2.0.1
matplotlib==3.5.1
matplotlib-scalebar==0.8.0
mayavi==4.7.4
kiwisolver==1.3.1
matplotlib==3.3.4
matplotlib-scalebar==0.7.2
mayavi==4.8.0
meshio==4.4.6
multidict==5.2.0
networkx==2.6.3
numpy==1.21.5
openpyxl==3.0.9
packaging==21.3
pandas==1.3.5
Pillow==9.0.1
pluggy==1.0.0
py==1.11.0
pyamg==4.2.1
pyasn1==0.4.8
pyface==7.3.0
Pygments==2.11.2
pyparsing==3.0.6
networkx==2.5.1
numpy==1.19.5
pandas==1.1.5
Pillow==8.4.0
pyamg==4.2.3
pyface==7.4.2
Pygments==2.12.0
pyparsing==3.0.9
PyQt5==5.15.6
PyQt5-Qt5==5.15.2
PyQt5-sip==12.9.0
pytest==6.2.5
PyQt5-sip==12.9.1
python-bioformats==4.0.5.post2+g51eb88a
python-dateutil==2.8.2
pytz==2021.3
PyWavelets==1.2.0
PyYAML==5.4.1
rsa==4.7.2
s3transfer==0.5.0
scikit-image==0.19.1
scikit-learn==1.0.2
scipy==1.7.3
pytz==2022.1
PyWavelets==1.1.1
PyYAML==6.0
requests==2.27.1
rich==12.5.1
s3transfer==0.5.2
scikit-image==0.17.2;python_version<"3.9"
scikit-image==0.19.3;python_version>="3.9"
scipy==1.5.4
SimpleITK==2.0.2rc2.dev785+g8ac4f
six==1.16.0
threadpoolctl==3.0.0
tifffile==2021.11.2
toml==0.10.2
tifffile==2020.9.3
traits==6.3.2
traitsui==7.2.1
typing_extensions==4.0.1
urllib3==1.26.8
traitsui==7.4.0
treelib==1.6.1
typing_extensions==4.1.1
urllib3==1.26.11
vtk==9.1.0
wslink==1.3.1
wslink==1.6.6
yarl==1.7.2
zipp==3.7.0
zipp==3.6.0
11 changes: 7 additions & 4 deletions magmap/atlas/ontology.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,17 @@ def create_reverse_lookup(
print(e)
return id_dict

def create_lookup_pd(self, df: pd.DataFrame) -> Dict[int, Any]:
def create_lookup_pd(
self, df: Optional[pd.DataFrame] = None) -> Dict[int, Any]:
"""Create a lookup dictionary from a Pandas data frame.

Args:
df: Pandas data frame, assumed to have at
least columns corresponding to :const:``config.ABAKeys.ABA_ID``
or :const:``config.AtlasMetrics.REGION`` and
:const:``config.ABAKeys.ABA_NAME`` or
:const:``config.AtlasMetrics.REGION_NAME``.
:const:``config.AtlasMetrics.REGION_NAME``. Defaults to None,
in which case :attr:`loaded_ref` is used.

Returns:
Dictionary similar to that generated from
Expand Down Expand Up @@ -297,7 +299,7 @@ def get_ref_lookup_as_df(self) -> Optional[pd.DataFrame]:
return df_regions

def create_ref_lookup(
self, labels_ref: Union[pd.DataFrame, Dict] = None
self, labels_ref: Optional[Union[pd.DataFrame, Dict]] = None
) -> Dict[int, Any]:
"""Wrapper to create a reference lookup from different sources.

Expand All @@ -306,7 +308,8 @@ def create_ref_lookup(

Args:
labels_ref: Reference dictionary or data frame, typically loaded
from :meth:`load_labels`.
from :meth:`load_labels`. Defaults to None, in which case
:attr:`loads_ref` is used.

Returns:
Ordered dictionary for looking up by ID.
Expand Down
Empty file added magmap/brain_globe/__init__.py
Empty file.
Loading