Skip to content

Commit

Permalink
Merge pull request #21 from kavli-ntnu/swb_development
Browse files Browse the repository at this point in the history
Switch `sep` to optional
  • Loading branch information
simon-ball authored Oct 24, 2019
2 parents cd1a768 + 91bbf86 commit 5ec9983
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 12 deletions.
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ Installing in this way requires having `git`, this can be acquired from

https://git-scm.com/download/win

Installing the required python package `sep` requires the Microsoft Visual C++ Build Tools, these can be downloaded from
Opexebo has an optional dependency, `sep`, that is not installed by default. To be able to install it, you require a C++ compiler installed on your system. On Linux, `gcc` will do the job. On Windows, the the Microsoft Visual C++ Build Tools fulfil the same role (https://www.microsoft.com/en-us/download/details.aspx?id=48159). To force installation of all optional depencies, append `[full]` to the install command, for example

pip install git+https://github.com/kavli-ntnu/opexebo.git#egg=v0.3.3[full]

https://www.microsoft.com/en-us/download/details.aspx?id=48159


Usage example
Expand Down
4 changes: 2 additions & 2 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pip==19.1.1
bumpversion==0.5.3
pip>=19.0.0
bumpversion>=0.5.3
wheel>=0.31.0,<0.32
flake8==3.5.0
tox>=3.2.0,<3.3
Expand Down
2 changes: 1 addition & 1 deletion opexebo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@

__author__ = """Simon Ball"""
__email__ = 'simon.ball@ntnu.no'
__version__ = '0.3.2'
__version__ = '0.3.3'
33 changes: 29 additions & 4 deletions opexebo/general/peakSearch.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import numpy as np
import warnings
import opexebo.defaults as default
from skimage import measure, morphology
import sep


#import sep
# NOTE!! Due to how annoying it is to install sep, I have moved this dependency
# into the method that uses it. This will allow users that struggle to install it
# to proceed with other methods that do not rely on it

# TODO! Decide what, if any, parameters need to move over to Defaults


Expand Down Expand Up @@ -58,7 +63,7 @@ def peak_search(image, **kwargs):
if search_method == default.search_method:
peak_coords = _peak_search_skimage(image, **kwargs)
elif search_method == "sep":
peak_coords = _peak_search_sep(image, **kwargs)
peak_coords = _peak_search_sep_wrapper(image, **kwargs)
else:
raise NotImplementedError("The search method you have requested (%s) is"\
" not yet implemented" % search_method)
Expand Down Expand Up @@ -104,8 +109,26 @@ def _peak_search_skimage(image, **kwargs):
return peak_coords




def _peak_search_sep_wrapper(firing_map, **kwargs):
''' Wrapper around the 'sep' Peak Search method
Because the 'sep' package is a nightmare to install, and not used for most
analysis routines, this wrapper allows most users to ignore it
If the user tries to invoke the 'sep' routines, this will try to do so
If it fails due to ModuleNotFound, it will use the default algorithm instead
with a warning to the user
'''
algorithm = _peak_search_sep
try:
import sep
except ModuleNotFoundError:
warnings.warn("Package 'sep' not installed in this environment."\
" Using the default peak search algorithm instead")
algorithm = _peak_search_skimage
return algorithm(firing_map, **kwargs)



def _peak_search_sep(firing_map, **kwargs):
'''Peak search using sep, a Python wrapper for a standard astronomy library.
Expand All @@ -120,6 +143,8 @@ def _peak_search_sep(firing_map, **kwargs):
'tetrode': 6,
'cell': 23}
'''
import sep

mask = kwargs.get("mask", np.zeros(firing_map.shape, dtype=bool))
null_background = kwargs.get("null_background", False)
threshold = kwargs.get("threshold", 0.2)
Expand Down
1 change: 1 addition & 0 deletions optional-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sep>=1.0.3
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sep>=1.0.3
astropy>=3.1.2
numpy>=1.15.0
scipy>=1.3.0
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 0.3.2
current_version = 0.3.3
commit = False
tag = False

Expand Down
6 changes: 5 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
with open(path.join(here, 'requirements.txt')) as f:
requirements = f.read().split()

with open(path.join(here, 'optional-requirements.txt')) as f:
optional_requirements = f.read().split()

setup_requirements = [ ]

test_requirements = [ ]
Expand All @@ -35,12 +38,13 @@
],
description="Collection of python code in Kavli lab.",
install_requires=requirements,
extras_require={"full": optional_requirements},
long_description=readme + '\n\n' + history,
include_package_data=True,
keywords='neuroscience kavli gridscore',
name='opexebo',
packages=find_packages(include=['opexebo*']),
url='https://github.com/kavli-ntnu/opexebo',
version='0.3.2',
version='0.3.3',
zip_safe=False,
)

0 comments on commit 5ec9983

Please sign in to comment.