Skip to content

Commit

Permalink
Merge pull request #27 from tee-ar-ex/architecture_modif_python
Browse files Browse the repository at this point in the history
Architectures change for Python only library
  • Loading branch information
arokem committed May 11, 2022
2 parents f3ebd3e + 40bb5bb commit 1866153
Show file tree
Hide file tree
Showing 54 changed files with 226 additions and 831 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest pytest-cov
python -m pip install flake8 pytest pytest-cov pytest-console-scripts
python -m pip install .
- name: Lint with flake8
run: |
Expand All @@ -37,4 +37,4 @@ jobs:
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest trx_file_memmap/tests
pytest trx/tests; pytest scripts/tests
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
# tractography_file_format
Official repository to present specifications, showcase examples, discuss issues and keep track of everything.
Currently host only two file format propositions, the TRX file format(as memmap vs zarr). Anyone is free to contribute.
# tee-ar-ex
Official repository to present the TRX (tee-ar-ex) python implementation, discuss issues and keep track of everything.
Anyone is free to contribute (issues, code reviews, pull requests).

The library and scripts can be installed locally by using:
Due to the fast change in implementation and possibily specifications, we recommend using a virtual environement.

The library can be installed locally by using:
```
export TRX_MINIMAL_INSTALL=1
pip install -e .
```
If you want to use the scripts and the functions related to the Stateful
Tractogram using the following commands:
```
pip install packaging>=19.0
pip install cython>=0.29.24
pip install -e .
```
If you want to switch from a minimal (w/o Dipy) to a full (with Dipy) install
you may need to add this before the above commands.
```
export TRX_MINIMAL_INSTALL=0
```
Empty file added offsets.float32
Empty file.
37 changes: 32 additions & 5 deletions scripts/tests/test_workflows.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import logging
import os
import tempfile

from dipy.io.streamline import load_tractogram
import pytest
import numpy as np
from numpy.testing import assert_equal, assert_array_equal

from trx_file_memmap.trx_file_memmap import load
from tractography_file_format.fetcher import (get_testing_files_dict,
try:
from dipy.io.streamline import load_tractogram
dipy_available = True
except ImportError:
dipy_available = False

from trx.trx_file_memmap import load
from trx.fetcher import (get_testing_files_dict,
fetch_data, get_home)
from tractography_file_format.workflows import (convert_dsi_studio,
from trx.workflows import (convert_dsi_studio,
convert_tractogram)


Expand All @@ -21,16 +27,25 @@


def test_help_option_convert_dsi(script_runner):
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
ret = script_runner.run('tff_convert_dsi_studio.py', '--help')
assert ret.success


def test_help_option_convert(script_runner):
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
ret = script_runner.run('tff_convert_tractogram.py', '--help')
assert ret.success


def test_execution_convert_dsi():
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
os.chdir(os.path.expanduser(tmp_dir.name))
in_trk = os.path.join(get_home(), 'DSI',
'CC.trk.gz')
Expand All @@ -53,6 +68,9 @@ def test_execution_convert_dsi():


def test_execution_convert_to_trx():
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
os.chdir(os.path.expanduser(tmp_dir.name))
in_trk = os.path.join(get_home(), 'DSI',
'CC_fix.trk')
Expand All @@ -73,6 +91,9 @@ def test_execution_convert_to_trx():


def test_execution_convert_from_trx():
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
os.chdir(os.path.expanduser(tmp_dir.name))
in_trk = os.path.join(get_home(), 'DSI',
'CC_fix.trk')
Expand Down Expand Up @@ -101,6 +122,9 @@ def test_execution_convert_from_trx():


def test_execution_convert_dtype_p16_o64():
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
os.chdir(os.path.expanduser(tmp_dir.name))
in_trk = os.path.join(get_home(), 'DSI',
'CC_fix.trk')
Expand All @@ -113,6 +137,9 @@ def test_execution_convert_dtype_p16_o64():


def test_execution_convert_dtype_p64_o32():
if not dipy_available:
pytest.skip('Dipy library is missing, cannot test scripts involving '
'tck/trk/vtk.')
os.chdir(os.path.expanduser(tmp_dir.name))
in_trk = os.path.join(get_home(), 'DSI',
'CC_fix.trk')
Expand Down
2 changes: 1 addition & 1 deletion scripts/tff_convert_dsi_studio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import argparse
import os

from tractography_file_format.workflows import convert_dsi_studio
from trx.workflows import convert_dsi_studio


def _build_arg_parser():
Expand Down
2 changes: 1 addition & 1 deletion scripts/tff_convert_tractogram.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import argparse
import os

from tractography_file_format.workflows import convert_tractogram
from trx.workflows import convert_tractogram


def _build_arg_parser():
Expand Down
2 changes: 1 addition & 1 deletion scripts/tff_simple_compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import argparse

from tractography_file_format.workflows import tractogram_simple_compare
from trx.workflows import tractogram_simple_compare


def _build_arg_parser():
Expand Down
2 changes: 1 addition & 1 deletion scripts/tff_verify_header_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

import argparse
from tractography_file_format.workflows import verify_header_compatibility
from trx.workflows import verify_header_compatibility


def _build_arg_parser():
Expand Down
2 changes: 1 addition & 1 deletion scripts/tff_visualize_overlap.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import argparse

from tractography_file_format.workflows import tractogram_visualize_overlap
from trx.workflows import tractogram_visualize_overlap


def _build_arg_parser():
Expand Down
10 changes: 4 additions & 6 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = tractography_file_format
url = https://github.com/frheault/tractography_file_format
name = trx
url = https://github.com/tee-ar-ex/trx-python
classifiers =
Development Status :: 3 - Alpha
Environment :: Console
Expand All @@ -18,9 +18,7 @@ platforms = OS Independent

[options]
python_requires = >=3.7
install_requires =
dipy
install_requires = nibabel

[options.extras_require]
dev =
pytest
dev = pytest
20 changes: 15 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
import glob
import os

from setuptools import setup, find_packages

SCRIPTS = glob.glob("scripts/*.py")
REQUIRES = ['fury@git+https://github.com/frheault/fury.git@5059a529#egg=fury',
'dipy@git+https://github.com/frheault/dipy.git@4e192c5c6#egg=dipy',
'gdown>=4.*']
TRX_MINIMAL_INSTALL = os.environ.get('TRX_MINIMAL_INSTALL')
TRX_MINIMAL_INSTALL = False if TRX_MINIMAL_INSTALL is None else \
int(TRX_MINIMAL_INSTALL)

setup(name='tractography_file_format',
if TRX_MINIMAL_INSTALL:
SCRIPTS = None
REQUIRES = ['numpy>=1.20.*', 'nibabel>=3.*', 'gdown>=4.*',
'pytest>=7.*', 'pytest-console-scripts>=0.*']
else:
SCRIPTS = glob.glob("scripts/*.py")
REQUIRES = ['fury@git+https://github.com/frheault/fury.git@5059a529#egg=fury',
'dipy@git+https://github.com/frheault/dipy.git@4e192c5c6#egg=dipy',
'gdown>=4.*', 'pytest>=7.*', 'pytest-console-scripts>=0.*']

setup(name='trx',
packages=find_packages(),
setup_requires=['packaging>=19.0'],
install_requires=REQUIRES,
Expand Down
File renamed without changes.
2 changes: 0 additions & 2 deletions tractography_file_format/__init__.py

This file was deleted.

Loading

0 comments on commit 1866153

Please sign in to comment.