Skip to content

Commit

Permalink
handling atlases on pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomaubier committed Jan 27, 2025
1 parent 6bde405 commit fa7417d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 28 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
- name: Display Python version
run: python -c "import sys; print(sys.version)"

- name: Download test BrainGlobe atlas
brainglobe install -a example_mouse_100um

- name: Installing CoperniFUS
run: python -m pip install -e .

Expand Down
56 changes: 28 additions & 28 deletions coperniFUS/modules/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class BrainAtlas(Module):
def __init__(self, parent_viewer, skip_online_atlas_retreival=False, **kwargs) -> None:
super().__init__(parent_viewer, 'atlas', **kwargs)

self.test_atlas = False
# self.test_atlas = False
if 'running_test' in self.module_kwargs and self.module_kwargs['running_test']:
print('running test')
self.test_atlas = True
# self.test_atlas = True
self._DEFAULT_PARAMS['default_atlas_name'] = 'example_mouse_100um'

self.skip_online_atlas_retreival = skip_online_atlas_retreival
Expand Down Expand Up @@ -182,33 +182,33 @@ def _add_atlas(self):
# bg_atlas = BrainGlobeAtlas(online_atlas_name, check_latest=True)
# self._add_atlas()

if self.test_atlas: # Only when testing application
pass # TEMPORARY TODO implement proper test
else:
if selected_atlas_description is None:
pass # TODO msg in status bar
elif selected_atlas_description.endswith('(DOWNLOADED)'):
offline_atlas_name = selected_atlas_description.split(' | ')[0]
self.parent_viewer.statusBar().showMessage(f'Loading offline {offline_atlas_name}', self.parent_viewer._STATUS_BAR_MSG_TIMEOUT)
self.bg_atlas = BrainGlobeAtlas(offline_atlas_name, check_latest=False)
elif selected_atlas_description.endswith('(online)'):
online_atlas_name = selected_atlas_description.split(' | ')[0]
# if self.test_atlas: # Only when testing application
# pass # TEMPORARY TODO implement proper test
# else:
if selected_atlas_description is None:
pass # TODO msg in status bar
elif selected_atlas_description.endswith('(DOWNLOADED)'):
offline_atlas_name = selected_atlas_description.split(' | ')[0]
self.parent_viewer.statusBar().showMessage(f'Loading offline {offline_atlas_name}', self.parent_viewer._STATUS_BAR_MSG_TIMEOUT)
self.bg_atlas = BrainGlobeAtlas(offline_atlas_name, check_latest=False)
elif selected_atlas_description.endswith('(online)'):
online_atlas_name = selected_atlas_description.split(' | ')[0]

dialog = AcceptRejectDialog(parent=self.parent_viewer, title='Proceed with Brain Atlas download?', msg=f'Do you want to download {online_atlas_name} ?\nThis might take a few minutes')
dialog_result = dialog.exec()
if dialog_result == 1:
self.parent_viewer.statusBar().showMessage(f'Downloading {online_atlas_name}')

# TODO reimplement threaded download
# self.threaded_atlas_download = threading.Thread(
# target=download_atlas_wrapper,
# args=(online_atlas_name,))
# self.threaded_atlas_download.start()
# TODO allow thread interruption
self.bg_atlas = BrainGlobeAtlas(online_atlas_name, check_latest=True)

dialog = AcceptRejectDialog(parent=self.parent_viewer, title='Proceed with Brain Atlas download?', msg=f'Do you want to download {online_atlas_name} ?\nThis might take a few minutes')
dialog_result = dialog.exec()
if dialog_result == 1:
self.parent_viewer.statusBar().showMessage(f'Downloading {online_atlas_name}')

# TODO reimplement threaded download
# self.threaded_atlas_download = threading.Thread(
# target=download_atlas_wrapper,
# args=(online_atlas_name,))
# self.threaded_atlas_download.start()
# TODO allow thread interruption
self.bg_atlas = BrainGlobeAtlas(online_atlas_name, check_latest=True)

else:
self.parent_viewer.statusBar().showMessage('Atlas Download Canceled!', self.parent_viewer._STATUS_BAR_MSG_TIMEOUT)
else:
self.parent_viewer.statusBar().showMessage('Atlas Download Canceled!', self.parent_viewer._STATUS_BAR_MSG_TIMEOUT)

if self.bg_atlas is not None:

Expand Down

0 comments on commit fa7417d

Please sign in to comment.