Skip to content

Commit

Permalink
updated to use validated_property and BinaryFile
Browse files Browse the repository at this point in the history
  • Loading branch information
tclose committed Sep 17, 2024
1 parent 447e7a1 commit af43bb6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -115,19 +115,19 @@ jobs:
--log-errors
--latest
- name: Upload MRtrix3 install
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: MRtrix3
path: ${{ env.MRTRIX_INSTALL}}
- name: Upload auto-gen pydra
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: AutoGen
path: pydra/tasks/mrtrix3/${{ env.SUBPKG_NAME }}
- name: Write version file
run: echo $MRTRIX_VERSION > mrtrix3_version.txt
- name: Upload version file
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: VersionFile
path: mrtrix3_version.txt
Expand Down Expand Up @@ -352,7 +352,7 @@ jobs:
git tag -d ${{ steps.latest_tag.outputs.TAG }};
git tag -a ${{ steps.latest_tag.outputs.TAG }} -m"Tag used to create a pydra-mrtrix3 $MRTRIX_VERSION release";
- name: Set up Python 3.11
uses: actions/setup-python@v2
uses: actions/setup-python@v3
with:
python-version: 3.11
- name: Install build tools
Expand All @@ -362,7 +362,7 @@ jobs:
- name: Check distributions
run: twine check dist/*
- name: Upload sdist
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: SDist
path: dist/*.tar.gz
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from fileformats.core import validated_property
from fileformats.core.mixin import WithAdjacentFiles
from fileformats.medimage import DwiEncoding, Nifti1, NiftiGz, NiftiX, NiftiGzX
from .image import ImageFormat, ImageHeader, ImageFormatGz
Expand All @@ -11,7 +12,7 @@ class BFile(DwiEncoding):

# NIfTI file format gzipped with BIDS side car
class WithBFile(WithAdjacentFiles):
@property
@validated_property
def encoding(self) -> BFile:
return BFile(self.select_by_ext(BFile))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pathlib import Path
import typing as ty
from fileformats.core import FileSet, extra_implementation
from fileformats.generic import File
from fileformats.core import FileSet, extra_implementation, validated_property
from fileformats.generic import BinaryFile
from fileformats.application.archive import BaseGzip
from fileformats.core.mixin import WithMagicNumber
from fileformats.core.exceptions import FormatMismatchError
Expand All @@ -12,12 +12,12 @@ class MultiLineMetadataValue(list):
pass


class BaseMrtrixImage(WithMagicNumber, fileformats.medimage.MedicalImage, File):
class BaseMrtrixImage(WithMagicNumber, fileformats.medimage.MedicalImage, BinaryFile):

magic_number = b"mrtrix image\n"
binary = True

@property
@validated_property
def data_fspath(self):
data_fspath = self.metadata["file"].split()[0]
if data_fspath == ".":
Expand Down Expand Up @@ -48,8 +48,8 @@ class ImageFormat(BaseMrtrixImage):
ext = ".mif"
iana_mime = "application/x-mrtrix-image-format"

@property
def check_data_file(self):
@validated_property
def _check_data_file(self):
if self.data_fspath != self.fspath:
raise FormatMismatchError(
f"Data file ('{self.data_fspath}') is not set to the same file as header "
Expand All @@ -73,7 +73,7 @@ class ImageHeader(BaseMrtrixImage):
ext = ".mih"
iana_mime = "application/x-mrtrix-image-header"

@property
@validated_property
def data_file(self):
return ImageDataFile(self.data_fspath)

Expand All @@ -84,7 +84,7 @@ def __attrs_post_init__(self):
super().__attrs_post_init__()


class ImageDataFile(File):
class ImageDataFile(BinaryFile):

ext = ".dat"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from fileformats.generic import File
from fileformats.generic import BinaryFile
from fileformats.core.mixin import WithMagicNumber


class Tracks(WithMagicNumber, File):
class Tracks(WithMagicNumber, BinaryFile):

ext = ".tck"
magic_number = b"mrtrix tracks\n"
Expand Down

0 comments on commit af43bb6

Please sign in to comment.