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

Trx integration to Dipy (part 2) #59

Merged
merged 20 commits into from Oct 7, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Expand Up @@ -12,7 +12,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10"]
python-version: ["3.8", "3.9", "3.10"]
frheault marked this conversation as resolved.
Show resolved Hide resolved

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 4 additions & 3 deletions setup.cfg
Expand Up @@ -21,15 +21,16 @@ include_package_data = True


[options]
python_requires = >=3.7
python_requires = >=3.8
setup_requires =
packaging >= 19.0
cython >= 0.29
install_requires =
setuptools_scm
deepdiff
nibabel >= 3
dipy@git+https://git@github.com/arokem/dipy@11a94c0fcf9b3
nibabel >= 5
numpy >= 1.22
dipy@git+https://git@github.com/frheault/dipy@cf4338d
fury

[options.extras_require]
Expand Down
16 changes: 13 additions & 3 deletions trx/trx_file_memmap.py
Expand Up @@ -1065,8 +1065,15 @@ def _create_trx_from_pointer(
ext = ".bool"
mem_adress, size = dict_pointer_size[elem_filename]

if root is not None and folder.startswith(root.rstrip("/")):
folder = folder.replace(root, "").lstrip("/")
if root is not None:
# This is for Unix
if os.name != 'nt' and folder.startswith(root.rstrip("/")):
folder = folder.replace(root, "").lstrip("/")
# These two are for Windows
elif os.path.isdir(folder) and os.path.basename(folder) in ['dpg', 'dpv', 'dps']:
folder = os.path.basename(folder)
else:
folder = ''

# Parse/walk the directory tree
if base == "positions" and folder == "":
Expand All @@ -1089,7 +1096,10 @@ def _create_trx_from_pointer(
shape=(trx.header["NB_STREAMLINES"]+1,),
dtype=ext[1:],
)
lengths = _compute_lengths(offsets)
if offsets[-1] != 0:
lengths = _compute_lengths(offsets)
else:
lengths = [0]
elif folder == "dps":
nb_scalar = size / trx.header["NB_STREAMLINES"]
if not nb_scalar.is_integer() or nb_scalar != dim:
Expand Down