Skip to content

Commit

Permalink
Merge pull request #67 from wiheto/develop
Browse files Browse the repository at this point in the history
0.5.2_prerelease
  • Loading branch information
wiheto committed May 12, 2020
2 parents 71b872e + 90fab6a commit 6b6a2fe
Show file tree
Hide file tree
Showing 18 changed files with 468 additions and 348 deletions.
6 changes: 4 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ language: python
dist: xenial
python:
- "3.6"
- "3.6-dev" # 3.6 development branch
- "3.8-dev" # 3.6 development branch
- "3.7"
- "3.8"
# command to install dependencies
install:
- pip install -r requirements.txt
- python setup.py install
- pip install python-coveralls
- pip install coveralls
- pip install pytest
- pip install pytest-cov
- sudo apt-get -y install python3-pyqt5
Expand Down
22 changes: 21 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# Changelog

## V0.5.1
## Version 0.5.2 (In development)

### 0.5.2 Improvements

Improved sidecar checking.

Added is_jsonable to utils.

### 0.5.2 Fixes

Fixes the issues when shortest paths were trying to be derived on non existent time points (raised in #60)

Fixing problem with df_to_array when time indices do not start at 0.

Fixing problem with dataframe netshape when starttime !=0 (#61)

coveralls resynced with travis (pip install python-coveralls replaced with pip install coveralls)

### 0.5.2 Changes

Removing wrong cased variables (e.g. netIN and TN from utils)

## Version 0.5.1

Expand Down
14 changes: 6 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

from setuptools import setup, find_packages

version = "teneto/_version.py"
verstrline = open(version, "rt").read()
version = verstrline.split('"')[1]
VERSION = "teneto/_version.py"
VERSION = open(VERSION, "rt").read()
VERSION = VERSION.split('"')[1]

setup(name='teneto',
version=version,
version=VERSION,
python_requires='>3.5',
setup_requires=['pytest-runner'],
tests_require=['pytest'],
Expand All @@ -30,10 +30,8 @@
package_data={'': ['./teneto/data']},
include_package_data=True,
entry_points={
'console_scripts': ['teneto = teneto.__main__:main'
]
'console_scripts': ['teneto = teneto.__main__:main']
},
long_description='Temporal network tools. \
A package for deriving, analysing and plotting temporal network representations. \
Additional tools for temporal network analysis with neuroimaging contexts.'
)
Additional tools for temporal network analysis with neuroimaging contexts.')
4 changes: 2 additions & 2 deletions teneto/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
__author__ = "WHT (wiheto @ github)"
#
from ._version import __version__
from .classes import TenetoBIDS, TemporalNetwork, TenetoWorkflow
from . import networkmeasures
from . import utils
from . import plot
from . import generatenetwork
from . import timeseries
Expand All @@ -17,7 +17,7 @@
from . import communitymeasures
from . import communitydetection
from . import neuroimagingtools
from .classes import TenetoBIDS, TemporalNetwork, TenetoWorkflow
from . import utils
#del misc.teneto
#del communitydetection.static.modularity_based_clustering
__all__ = ['__version__', 'utils', 'networkmeasures', 'plot', 'generatenetwork',
Expand Down
2 changes: 1 addition & 1 deletion teneto/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.5.1"
__version__ = "0.5.2-dev-c"
37 changes: 22 additions & 15 deletions teneto/classes/bids.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""TenetoBIDS is a class which can be used to use Teneto functions with data organized with BIDS (neuroimaging data)."""
"""TenetoBIDS is a class to use Teneto functions with data organized with BIDS (neuroimaging data)."""
import os
import bids
import numpy as np
import inspect
import json
from ..neuroimagingtools import load_tabular_file, get_sidecar
import bids
import importlib
import numpy as np
import pandas as pd
from .. import __path__ as tenetopath
from .. import __version__ as tenetoversion
from ..neuroimagingtools import load_tabular_file, get_sidecar
from .network import TemporalNetwork
from teneto import __path__ as tenetopath
from teneto import __version__ as tenetoversion
import teneto


# @check_neuro_packages(bids)
class TenetoBIDS:
"""
Class for analysing data in BIDS.
Expand Down Expand Up @@ -141,7 +141,9 @@ def run(self, run_func, input_params, output_desc=None, output_pipeline_name=Non
"""
if exist_ok is not None:
self.exist_ok = exist_ok

# Import teneto if it has not been already
if 'teneto' not in globals():
teneto = importlib.import_module('teneto')
func = teneto
for f in self.tenetobids_structure[run_func]['module'].split('.'):
func = getattr(func, f)
Expand Down Expand Up @@ -244,16 +246,21 @@ def run(self, run_func, input_params, output_desc=None, output_pipeline_name=Non
input_params['confounds'] = 'Passed as argument'
if 'sidecar' in input_params:
input_params['sidecar'] = 'Loaded automatically via TenetoBIDS'
sidecar['TenetoFunction']['Parameters'] = input_params
# Loop through input params content and make any nparray input to list for sidecar
sidecar['TenetoFunction']['Parameters'] = {}
for key, value in input_params.items():
if not teneto.utils.is_jsonable(value):
if isinstance(input_params[key], np.ndarray):
sidecar['TenetoFunction']['Parameters'][key] = input_params[key].tolist()
else:
print('Warning: Dropping input (' + key + ') from sidecar (not JSONable).')
else:
sidecar['TenetoFunction']['Parameters'][key] = input_params[key]
elif functype == 'on_sidecar':
sidecar = func(**input_params)
update_pipeline = False
save_path = f.dirname + '/'
save_name = f.filename
# Loop through sidecar content and make any nparray input to list
for n in sidecar.keys():
if isinstance(sidecar[n], np.ndarray):
sidecar[n] = sidecar[n].tolist()
# Save sidecar
with open(save_path + save_name.replace('.tsv', '.json'), 'w') as f:
json.dump(sidecar, f)
Expand Down Expand Up @@ -318,7 +325,7 @@ def get_run_options(self, for_selected=True):
for su in suffix:
if su in s:
funcs_filter.append(t)
funcs = list(set(funcs_filter))
funcs = sorted(list(set(funcs_filter)))
return ', '.join(funcs)

def update_bids_filter(self, filter_addons):
Expand Down
Loading

0 comments on commit 6b6a2fe

Please sign in to comment.