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

Develop #6

Merged
merged 10 commits into from
Nov 25, 2022
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
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
14 changes: 8 additions & 6 deletions .github/workflows/python-deploy_to_pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,17 @@ on:
jobs:
deploy:
name: Build and publish to PyPI
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7.6
uses: actions/setup-python@v2
- uses: actions/checkout@v3
with:
python-version: 3.7.6
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.9
- name: Install pypa/build
run: pip install build
run: pip install build pbr wheel
- name: Build a binary wheel and a source tarball
run: python -m build --sdist --wheel --outdir dist/ .
- name: Publish distribution to PyPI
Expand Down
32 changes: 15 additions & 17 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,39 +12,37 @@ on:
jobs:
pytest:
name: Run PHOTONAI_neuro tests
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7.6
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.7.6
python-version: 3.9
- name: Install dependencies
run: |
pip install wheel flake8
python setup.py egg_info
pip install pytest pytest-cov coveralls -r photonai_neuro.egg-info/requires.txt
pip install pytest pytest-cov coveralls -r requirements.txt
- name: Test with pytest
run: |
PYTHONPATH=./ pytest ./test --cov=./photonai_neuro --tb=long
PYTHONPATH=./ pytest ./test --cov-report lcov:./coverage/lcov.info --cov=./photonai_neuro --tb=long
- name: Coveralls
run: coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

deploy:
name: Build and publish to TestPyPI
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
needs: pytest
if: github.ref == 'refs/heads/master'
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7.6
uses: actions/setup-python@v2
- uses: actions/checkout@v3
- name: Set up Python 3.9
uses: actions/setup-python@v4
with:
python-version: 3.7.6
python-version: 3.9
- name: Replace version number with commit hash
run: |
dt=$(date '+%Y.%m.%d.%H.%M.%S')
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
[![PHOTONAI_neuro tests + TestPyPI deployment @master](https://github.com/wwu-mmll/photonai_neuro/actions/workflows/python-test.yml/badge.svg)](https://github.com/wwu-mmll/photonai_neuro/actions/workflows/python-test.yml)
[![Coverage Status](https://coveralls.io/repos/github/wwu-mmll/photonai_neuro/badge.svg?branch=master)](https://coveralls.io/github/wwu-mmll/photonai_neuro?branch=master)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=wwu-mmll_photonai_neuro&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=wwu-mmll_photonai_neuro)
![GitHub](https://img.shields.io/github/license/wwu-mmll/photonai_neuro)
[![Twitter URL](https://img.shields.io/twitter/url?style=social&url=https%3A%2F%2Ftwitter.com%2Fwwu_mmll)](https://twitter.com/wwu_mmll)
# PHOTONAI Neuro
PHOTONAI Neuro is an add-on module to simplify machine learning analyses for multimodal Magnetic Resonance Imaging (MRI)
with PHOTONAI.
Expand Down
42 changes: 29 additions & 13 deletions photonai_neuro/__init__.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
import os
from datetime import datetime

from photonai.base import PhotonRegistry
from photonai.photonlogger import logger

from .util import register_photonai_neuro


# REGISTRATION
current_path = os.path.dirname(os.path.abspath(__file__))
registered_file = os.path.join(current_path, "registered")
logger.info("Checking Neuro Module Registration")
if not os.path.isfile(registered_file):
logger.info("Registering Neuro Module")
register_photonai_neuro()
with open(os.path.join(registered_file), "w") as f:
f.write(str(datetime.now()))
from .version import __version__

from .atlas_mapper import AtlasMapper
from .brain_mask import BrainMask
from .brain_atlas import BrainAtlas
from .atlas_library import AtlasLibrary
from .neuro_branch import NeuroBranch


# REGISTRATION
def do_register(current_path, registered_file): # pragma: no cover
reg = PhotonRegistry()
reg.add_module(os.path.join(current_path, "photonai_neuro.json"))
with open(os.path.join(registered_file), "w") as f:
f.write(str(__version__))


def register(): # pragma: no cover
current_path = os.path.dirname(os.path.abspath(__file__))
registered_file = os.path.join(current_path, "registered")
logger.info("Checking Neuro Module Registration")
if not os.path.isfile(registered_file): # pragma: no cover
logger.info("Registering Neuro Module")
do_register(current_path=current_path, registered_file=registered_file)
else:
with open(os.path.join(registered_file), "r") as f:
if f.read() == __version__:
logger.info("Current version already registered")
else:
logger.info("Updating Neuro Module")
do_register(current_path=current_path, registered_file=registered_file)


register()
4 changes: 4 additions & 0 deletions photonai_neuro/neuro_branch.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ def __iadd__(self, pipe_element: PipelineElement):
self

"""
if pipe_element.name not in NeuroBranch.NEURO_ELEMENTS:
ksarink marked this conversation as resolved.
Show resolved Hide resolved
# reload
PhotonRegistry.ELEMENT_DICTIONARY = PhotonRegistry().get_package_info()
NeuroBranch.NEURO_ELEMENTS = PhotonRegistry().get_package_info(['photonai_neuro'])
if pipe_element.name in NeuroBranch.NEURO_ELEMENTS:
# as the neuro branch is parallelized and processes several images subsequently on
# different cores, we need to stop the children to process on several cores as well
Expand Down
3 changes: 3 additions & 0 deletions photonai_neuro/version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from pbr.version import VersionInfo

__version__ = VersionInfo('photonai_neuro').release_string()
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ pandas
photonai
scikit-learn
scikit-image
pbr
26 changes: 26 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[metadata]
name = photonai_neuro
description-file = README.md
author = PHOTON Team
jernsting marked this conversation as resolved.
Show resolved Hide resolved
author_email = hahnt@uni-muenster.de
url = https://www.photon-ai.com/
license = GPLv3
long_description_content_type = text/markdown
project_urls:
jernsting marked this conversation as resolved.
Show resolved Hide resolved
Source Code = https://github.com/wwu-mmll/photonai_graph
Documentation = https://wwu-mmll.github.io/photonai_graph/
Bug Tracker = https://github.com/wwu-mmll/photonai_graph/issues
download_url = https://pypi.org/project/photonai_graph/#files
keywords =
machine learning
deep learning
graph convolutional neural networks
graphs
classifiers =
License :: OSI Approved :: GNU General Public License v3 (GPLv3)
Topic :: Software Development :: Libraries :: Python Modules
Topic :: Scientific/Engineering :: Artificial Intelligence
Intended Audience :: Science/Research

[files]
package = photonai_neuro
32 changes: 2 additions & 30 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,5 @@
try:
from setuptools import setup, find_packages
except ImportError:
from ez_setup import use_setuptools
use_setuptools()
from setuptools import setup, find_packages


__version__ = '0.1.0'
from setuptools import setup

setup(
name='photonai_neuro',
packages=find_packages(),
include_package_data=True,
version=__version__,
description="""
PHOTONAI NEURO
The Neuro Module enables loading and preprocessing neuroimaging data such as structural and
functional Magnetic Resonance Imaging (MRI) data.
In addition, it supports a range of advanced feature extraction and feature engineering as well as atlas-based analyses.
""",
author='PHOTONAI Team',
author_email='hahnt@wwu.de',
url='https://github.com/mmll-wwu/photonai_neuro.git',
download_url='https://github.com/wwu-mmll/photonai_neuro/archive/' + __version__ + '.tar.gz',
keywords=['machine learning', 'neuroimaging', 'MRI'],
classifiers=[],
install_requires=[
'photonai',
'nibabel',
'nilearn',
'scikit-image']
pbr=True
)
12 changes: 7 additions & 5 deletions test/test_atlas_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ def create_hyperpipe(self):
@staticmethod
def create_data():
n_subjects = 20
dataset_files = fetch_oasis_vbm(n_subjects=n_subjects)
_ = dataset_files.ext_vars['age'].astype(float)
gender = dataset_files.ext_vars['mf'].astype(str)
y = np.array(gender)
X = np.array(dataset_files.gray_matter_maps)
y = [0]
while len(np.unique(y)) == 1:
dataset_files = fetch_oasis_vbm(n_subjects=n_subjects)
_ = dataset_files.ext_vars['age'].astype(float)
gender = dataset_files.ext_vars['mf'].astype(str)
y = np.array(gender)
X = np.array(dataset_files.gray_matter_maps)
return X, y

def test_fit_reload_all(self):
Expand Down