From 0e7dc416d39ba522af62ff05b6e10e5bbc4f9cab Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:07:54 -0500 Subject: [PATCH 01/10] implementing auto version --- MANIFEST.in | 2 ++ conwhat/__init__.py | 9 ++++----- setup.cfg | 2 +- setup.py | 13 +++++++------ 4 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..77fb6ea --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include versioneer.py +include conwhat/_version.py diff --git a/conwhat/__init__.py b/conwhat/__init__.py index 236fa7a..30f8d95 100644 --- a/conwhat/__init__.py +++ b/conwhat/__init__.py @@ -1,10 +1,9 @@ - - -__version__ = '0.1.dev0' - +__all__ = [ 'VolTractAtlas', 'VolConnAtlas', 'StreamTractAtlas', 'StreamConnAtlas' ] from atlas import (VolTractAtlas,VolConnAtlas, StreamTractAtlas,StreamConnAtlas) - +from ._version import get_versions +__version__ = get_versions()['version'] +del get_versions diff --git a/setup.cfg b/setup.cfg index 5485a90..1a08a6f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -2,6 +2,6 @@ VCS = git style = pep440 versionfile_source = conwhat/_version.py -versionfile_build = _version.py +versionfile_build = conwhat/_version.py tag_prefix = parentdir_prefix = conwhat- diff --git a/setup.py b/setup.py index dd4d70e..38f667a 100644 --- a/setup.py +++ b/setup.py @@ -1,17 +1,19 @@ #!/usr/bin/env python from setuptools import setup, find_packages -import versioneer +import versioneer -setup(name='conwhat', #version=versioneer.get_version(), +setup(name='conwhat', + version=versioneer.get_versions(), + cmdclass=versioneer.get_cmdclass(), description='python library for connectome-based white matter atlas analyses in neuroimaging', long_description='python library for connectome-based white matter atlas analyses in neuroimaging', keywords='white matter, tractography, MRI, DTI, diffusion, python', author='John David Griffiths', author_email='j.davidgriffiths@gmail.com', url='https://github.com/JohnGriffiths/conwhat', - packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - install_requires=['numpy', 'setuptools'], + packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), + install_requires=['numpy', 'setuptools', 'pandas', 'nibabel', 'nilearn', 'dipy', 'joblib', 'matplotlib'], classifiers=[ 'Intended Audience :: Science/Research', 'Programming Language :: Python', @@ -28,6 +30,5 @@ "console_scripts": [ "conwhat=conwhat.__main__:main", ] - }, - #cmdclass=versioneer.get_cmdclass() + } ) From 452f8ed9d84ac83d9d812acfd611a5e324967cbb Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:09:12 -0500 Subject: [PATCH 02/10] implementing the mechanism for CLI, not throwing an error if used --- conwhat/__main__.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 conwhat/__main__.py diff --git a/conwhat/__main__.py b/conwhat/__main__.py new file mode 100644 index 0000000..86cee1f --- /dev/null +++ b/conwhat/__main__.py @@ -0,0 +1,15 @@ + + + +def main(): + "Entry point." + + raise NotImplementedError('The command line interface for ConWhAt is not currently supported. ' + 'Please use it via API in a script or jupyter notebook. \n' + 'Example usages : \n' + 'from conwhat import StreamConnAtlas \n' + 'from conwhat import VolConnAtlas \n' + '') + +if __name__ == '__main__': + main() \ No newline at end of file From 20b1ee78b2df87da301647b8f69275f3869d1f1a Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:09:58 -0500 Subject: [PATCH 03/10] cleaning up repo --- .gitignore | 89 ------------------------------------------------------ 1 file changed, 89 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 72364f9..0000000 --- a/.gitignore +++ /dev/null @@ -1,89 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -env/ -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -*.egg-info/ -.installed.cfg -*.egg - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*,cover -.hypothesis/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# IPython Notebook -.ipynb_checkpoints - -# pyenv -.python-version - -# celery beat schedule file -celerybeat-schedule - -# dotenv -.env - -# virtualenv -venv/ -ENV/ - -# Spyder project settings -.spyderproject - -# Rope project settings -.ropeproject From 885fbbc3a5b33c1008e99a27a82fca06f73d5b72 Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:13:48 -0500 Subject: [PATCH 04/10] updating import reference --- conwhat/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conwhat/__init__.py b/conwhat/__init__.py index 30f8d95..838ca5d 100644 --- a/conwhat/__init__.py +++ b/conwhat/__init__.py @@ -1,7 +1,7 @@ __all__ = [ 'VolTractAtlas', 'VolConnAtlas', 'StreamTractAtlas', 'StreamConnAtlas' ] -from atlas import (VolTractAtlas,VolConnAtlas, +from .atlas import (VolTractAtlas,VolConnAtlas, StreamTractAtlas,StreamConnAtlas) from ._version import get_versions From c08de415c9f6c6ebba350ae62d6f2ae8b0093282 Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:50:31 -0500 Subject: [PATCH 05/10] code cleanup, defining unresolved references. better print() syntax --- conwhat/atlas.py | 33 ++++++++++++++++++++++----------- conwhat/utils/stats.py | 15 +++++++++------ conwhat/viz/network.py | 7 +++++-- conwhat/viz/streams.py | 8 +++++--- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/conwhat/atlas.py b/conwhat/atlas.py index 76c5ea8..e53b4c5 100644 --- a/conwhat/atlas.py +++ b/conwhat/atlas.py @@ -14,17 +14,17 @@ from nilearn.plotting import plot_glass_brain -from utils.readers import (load_connectivity,load_vol_file_mappings,load_vol_bboxes, +from .utils.readers import (load_connectivity,load_vol_file_mappings,load_vol_bboxes, load_stream_file_mappings,load_stream_bboxes, make_nx_graph,dpy_to_trk) -from utils.stats import (compute_vol_hit_stats,compute_vol_scalar_stats, +from .utils.stats import (compute_vol_hit_stats,compute_vol_scalar_stats, compute_streams_in_roi,#compute_stream_hit_stats,compute_stream_scalar_stats, hit_stats_to_nx) -#from viz.network import plot_network,plot_matrix -#from viz.volume import plot_vol_cnxn,plot_vol_tract -#from viz.streams import plot_stream_cnxn,plot_stream_tract +from .viz.network import plot_network, plot_matrix +from .viz.volume import plot_vol_cnxn, plot_vol_tract +from .viz.streams import plot_stream_cnxn, plot_stream_tract @@ -38,7 +38,7 @@ class _Atlas(): # object): def __init__(self): - print 'blah' + print('blah') class _VolAtlas(_Atlas): @@ -61,6 +61,7 @@ def __init__(self,atlas_name=None,atlas_dir=None): self.vfms,self.atlas_dir = load_vol_file_mappings(atlas_name=atlas_name,atlas_dir=atlas_dir) self.bbox = load_vol_bboxes(atlas_name=atlas_name,atlas_dir=atlas_dir) + self.scalar_stats = dict() def get_vol_from_vfm(self,idx): """ @@ -174,7 +175,8 @@ def compute_hit_stats(self,roi,idxs,n_jobs=1,run_type='simple',joblib_cache_dir= def plot_tract(self,atlas_name): # (uses plotting param defaults tuned to JHU atlas) - plot_tract() + # plot_tract() + raise NotImplementedError @@ -207,6 +209,8 @@ def __init__(self,atlas_dir=None,atlas_name=None): # Compile node and connectivity info into a networkx graph self.Gnx = make_nx_graph(self.vfms,self.bbox,ws,rls,hs,ctx) + self.modcons = dict() + @property def weights(self): @@ -282,13 +286,17 @@ def get_vol_from_rois(self,roi1,roi2): return img + def modify_vol_connectome(self): + + raise NotImplementedError + def modify_connectome(self, name='mc1',function=''): """ Modify canonical connectome using hit or scalar stats, and store in this obj """ - res = modify_vol_connectome() + res = self.modify_vol_connectome() self.modcons[name] = res @@ -444,6 +452,8 @@ def __init__(self,atlas_name=None,atlas_dir=None): # Compile node and connectivity info into a networkx graph self.Gnx = make_nx_graph(self.sfms,self.bbox,ws,rls,hs,ctx) + self.modcons = dict() + def get_rois_from_idx(self,idx): @@ -484,7 +494,8 @@ def compute_hit_stats(self,roi,idxs,n_jobs=1,run_type='simple',joblib_cache_dir= - + def modify_stream_connectome(self): + raise NotImplementedError def modify_connectome(self, name='mc1',function=''): """ @@ -492,7 +503,7 @@ def modify_connectome(self, name='mc1',function=''): stats, and store in this obj """ - res = modify_stream_connectome() + res = self.modify_stream_connectome() self.modcons[name] = res @@ -521,7 +532,7 @@ def plot_matrix(self): def plot_cnxns(self): - plot_stream_cnxns() + plot_stream_cnxn() diff --git a/conwhat/utils/stats.py b/conwhat/utils/stats.py index 64faa73..eae5ed8 100644 --- a/conwhat/utils/stats.py +++ b/conwhat/utils/stats.py @@ -388,20 +388,23 @@ def calc_streams_in_roi(dpy_file,roi_dat,stream_idxs): -def compute_vol_scalar_stats(): +def compute_vol_scalar_stats(params): - print 'computing vol scalar stats' + print('computing vol scalar stats') + raise NotImplementedError -def compute_stream_hit_stats(): +def compute_stream_hit_stats(params): - print 'computing stream hit stats' + print('computing stream hit stats') + raise NotImplementedError -def compute_stream_scalar_stats(): +def compute_stream_scalar_stats(params): + print('computing stream scalar stats') + raise NotImplementedError - print 'computing stream scalar stats' diff --git a/conwhat/viz/network.py b/conwhat/viz/network.py index 2cb1b1f..96bb3f0 100644 --- a/conwhat/viz/network.py +++ b/conwhat/viz/network.py @@ -9,13 +9,16 @@ def plot_network(): - print 'plotting network' + print('plotting network') + return def plot_matrix(): - print 'plotting matrix' + print('plotting matrix') + + return diff --git a/conwhat/viz/streams.py b/conwhat/viz/streams.py index ffe3ce8..b5e7bd3 100644 --- a/conwhat/viz/streams.py +++ b/conwhat/viz/streams.py @@ -54,7 +54,7 @@ def get_track_vis_pic(trk_file, length=None,bg_image=None,bz=None, sc='/tmp/movi if tr: cmd += ' -s -r %s' %tr - if tc: + if tc: cmd += ' -c %s ' %tc if aa: cmd+= ' -aa ' @@ -74,11 +74,13 @@ def get_track_vis_pic(trk_file, length=None,bg_image=None,bz=None, sc='/tmp/movi def plot_stream_cnxn(): - print 'plotting streamlinetric connection' + print('plotting streamlinetric connection') + raise NotImplementedError def plot_stream_tract(): - print 'plotting streamlinetric tract' + print('plotting streamlinetric tract') + raise NotImplementedError From 4c6a9cae6173d01fa9e7d2917abf493b624c8d0c Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 14:57:58 -0500 Subject: [PATCH 06/10] fixing typo --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 38f667a..5acb439 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ import versioneer setup(name='conwhat', - version=versioneer.get_versions(), + version=versioneer.get_version(), cmdclass=versioneer.get_cmdclass(), description='python library for connectome-based white matter atlas analyses in neuroimaging', long_description='python library for connectome-based white matter atlas analyses in neuroimaging', From 3ca29a5ec14b1ad748088564df5b5181a52682a8 Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 15:10:55 -0500 Subject: [PATCH 07/10] adding sklearn to requirements --- requirements.txt | 1 + setup.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b366461..d40455b 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,3 +5,4 @@ nilearn dipy joblib matplotlib +sklearn \ No newline at end of file diff --git a/setup.py b/setup.py index 5acb439..0dfa97b 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ author_email='j.davidgriffiths@gmail.com', url='https://github.com/JohnGriffiths/conwhat', packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - install_requires=['numpy', 'setuptools', 'pandas', 'nibabel', 'nilearn', 'dipy', 'joblib', 'matplotlib'], + install_requires=['numpy', 'setuptools', 'pandas', 'nibabel', 'sklearn', 'nilearn', 'dipy', 'joblib', 'matplotlib'], classifiers=[ 'Intended Audience :: Science/Research', 'Programming Language :: Python', From b3f017255862ac407fd88d13418e158aed072a65 Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 15:11:12 -0500 Subject: [PATCH 08/10] fixing syntax errors for print --- conwhat/atlas.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/conwhat/atlas.py b/conwhat/atlas.py index e53b4c5..0ba359e 100644 --- a/conwhat/atlas.py +++ b/conwhat/atlas.py @@ -4,6 +4,7 @@ # Author: John Griffiths # License: simplified BSD +from __future__ import print_function import os @@ -80,10 +81,10 @@ def get_vol_from_vfm(self,idx): if os.path.isfile(nii_file): if (np.isnan(volnum) or volnum == 'nan'): - print 'getting atlas entry %s: image file %s' %(idx,nii_file) + print('getting atlas entry {}: image file {} ' % (idx,nii_file)) img = nib.load(nii_file) else: - print 'getting atlas entry %s: volume %s from image file %s' %(idx,volnum,nii_file) + print('getting atlas entry {}: volume %s from image file {}' % (idx,volnum,nii_file)) img = index_img(nii_file,volnum) return img @@ -406,7 +407,7 @@ def __init__(self,atlas_name=None,atlas_dir=None): def write_subset_to_trk(self,ref_file,outfile,stream_inds='all'): - print 'writing streams to trk file: %s' %outfile + print('writing streams to trk file: {}' % outfile) dpy_to_trk(self.dpy_file,ref_file,outfile,inds=stream_inds) From af01d0009d79752b4cd3c19d308669de4dc9e02f Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 15:16:58 -0500 Subject: [PATCH 09/10] fixing not implemented functions --- conwhat/viz/volume.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/conwhat/viz/volume.py b/conwhat/viz/volume.py index 02f10e0..445fb23 100644 --- a/conwhat/viz/volume.py +++ b/conwhat/viz/volume.py @@ -157,3 +157,11 @@ def plot_vol_and_rois_nilearn(vol,labels,roi1_img=None,roi2_img=None, return display +def plot_vol_cnxn(): + "" + + raise NotImplementedError + +def plot_vol_tract(): + + raise NotImplementedError \ No newline at end of file From 098ae8088f6d320ed414355be3d31a65b8bf43de Mon Sep 17 00:00:00 2001 From: Pradeep Reddy Raamana Date: Mon, 27 Nov 2017 15:17:13 -0500 Subject: [PATCH 10/10] updating the requirements to be complete --- requirements.txt | 5 ++++- setup.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index d40455b..e43e825 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,7 @@ nilearn dipy joblib matplotlib -sklearn \ No newline at end of file +sklearn +pyyaml +networkx +indexed_gzip \ No newline at end of file diff --git a/setup.py b/setup.py index 0dfa97b..a3fc205 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,8 @@ author_email='j.davidgriffiths@gmail.com', url='https://github.com/JohnGriffiths/conwhat', packages=find_packages(exclude=["*.tests", "*.tests.*", "tests.*", "tests"]), - install_requires=['numpy', 'setuptools', 'pandas', 'nibabel', 'sklearn', 'nilearn', 'dipy', 'joblib', 'matplotlib'], + install_requires=['numpy', 'setuptools', 'pandas', 'nibabel', 'sklearn', 'nilearn', + 'dipy', 'joblib', 'matplotlib', 'pyyaml', 'networkx', 'indexed_gzip'], classifiers=[ 'Intended Audience :: Science/Research', 'Programming Language :: Python',