Skip to content

NF: Functionality for reading AFNI BRIK/HEAD #561

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

Merged
merged 16 commits into from
Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
627 changes: 627 additions & 0 deletions nibabel/brikhead.py

Large diffs are not rendered by default.

13 changes: 10 additions & 3 deletions nibabel/imageclasses.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
''' Define supported image classes and names '''

from .analyze import AnalyzeImage
from .brikhead import AFNIImage
from .cifti2 import Cifti2Image
from .freesurfer import MGHImage
from .gifti import GiftiImage
Expand All @@ -31,7 +32,7 @@
Cifti2Image, Nifti2Image, # Cifti2 before Nifti2
Spm2AnalyzeImage, Spm99AnalyzeImage, AnalyzeImage,
Minc1Image, Minc2Image, MGHImage,
PARRECImage, GiftiImage]
PARRECImage, GiftiImage, AFNIImage]


# DEPRECATED: mapping of names to classes and class functionality
Expand Down Expand Up @@ -88,7 +89,12 @@ def __getitem__(self, *args, **kwargs):
'ext': '.par',
'has_affine': True,
'makeable': False,
'rw': False})
'rw': False},
afni={'class': AFNIImage,
'ext': '.brik',
'has_affine': True,
'makeable': False,
'rw': False})


class ExtMapRecoder(Recoder):
Expand All @@ -107,14 +113,15 @@ def __getitem__(self, *args, **kwargs):
('mgh', '.mgh'),
('mgz', '.mgz'),
('par', '.par'),
('brik', '.brik')
))

# Image classes known to require spatial axes to be first in index ordering.
# When adding an image class, consider whether the new class should be listed
# here.
KNOWN_SPATIAL_FIRST = (Nifti1Pair, Nifti1Image, Nifti2Pair, Nifti2Image,
Spm2AnalyzeImage, Spm99AnalyzeImage, AnalyzeImage,
MGHImage, PARRECImage)
MGHImage, PARRECImage, AFNIImage)


def spatial_axes_first(img):
Expand Down
133 changes: 133 additions & 0 deletions nibabel/tests/data/bad_attribute+orig.HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

type = string-attribute
name = DATASET_NAME
count = 5
'none~

type = string-attribute
name = TYPESTRING
count = 15
'3DIM_HEAD_ANAT~

type = string-attribute
name = IDCODE_STRING
count = 27
'AFN_-zxZ0OyZs8eEtm9syGBNdA~

type = string-attribute
name = IDCODE_DATE
count = 25
'Sun Oct 1 21:13:09 2017~

type = integer-attribute
name = SCENE_DATA
count = 8
0 2 0 -999 -999
-999 -999 -999

type = string-attribute
name = LABEL_1
count = 5
'none~

type = string-attribute
name = LABEL_2
count = 5
'none~

type = integer-attribute
name = ORIENT_SPECIFIC
count = 3
0 3 4

type = float-attribute
name = ORIGIN
count = 3
-49.5 -82.312 -52.3511

type = float-attribute
name = DELTA
count = 3
3 3 3

type = float-attribute
name = IJK_TO_DICOM
count = 12
3 0 0 -49.5 0
3 0 -82.312 0 0
3 -52.3511

type = float-attribute
name = IJK_TO_DICOM_REAL
count = 12
3 0 0 -49.5 0
3 0 -82.312 0 0
3 -52.3511

type = float-attribute
name = BRICK_STATS
count = 6
0 13722 0 10051 0
9968

type = integer-attribute
name = TAXIS_NUMS
count = 8
3 25 77002 -999 -999
-999 -999 -999

type = float-attribute
name = TAXIS_FLOATS
count = 8
0 3 0 -52.3511 3
-999999 -999999 -999999

type = float-attribute
name = TAXIS_OFFSETS
count = 25
0.3260869 1.826087 0.3913043 1.891304 0.4565217
1.956521 0.5217391 2.021739 0.5869564 2.086956
0.6521738 2.152174 0.7173912 2.217391 0.7826086
2.282609 0.8478259 2.347826 0.9130433 2.413044
0.9782607 2.478261 1.043478 2.543479 1.108696

type = integer-attribute
name = DATASET_RANK
count = 8
3 3 0 0 0
0 0 0

type = integer-attribute
name = DATASET_DIMENSIONS
count = 5
33 41 25 0 0

type = integer-attribute
name = BRICK_TYPES
count = 3
1 1 1

type = float-attribute
name = BRICK_FLOAT_FACS
count = 3
0 0 0

type = string-attribute
name = TEMPLATE_SPACE
count = 5
'ORIG~

type = integer-attribute
name = INT_CMAP
count = 1
0

type = integer-attribute
name = BYTEORDER_STRING
count = 10
'LSB_FIRST~

type = string-attribute
name = BRICK_LABS
count = 9
'#0~#1~#2~
133 changes: 133 additions & 0 deletions nibabel/tests/data/bad_datatype+orig.HEAD
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@

type = string-attribute
name = DATASET_NAME
count = 5
'none~

type = string-attribute
name = TYPESTRING
count = 15
'3DIM_HEAD_ANAT~

type = string-attribute
name = IDCODE_STRING
count = 27
'AFN_-zxZ0OyZs8eEtm9syGBNdA~

type = string-attribute
name = IDCODE_DATE
count = 25
'Sun Oct 1 21:13:09 2017~

type = integer-attribute
name = SCENE_DATA
count = 8
0 2 0 -999 -999
-999 -999 -999

type = string-attribute
name = LABEL_1
count = 5
'none~

type = string-attribute
name = LABEL_2
count = 5
'none~

type = integer-attribute
name = ORIENT_SPECIFIC
count = 3
0 3 4

type = float-attribute
name = ORIGIN
count = 3
-49.5 -82.312 -52.3511

type = float-attribute
name = DELTA
count = 3
3 3 3

type = float-attribute
name = IJK_TO_DICOM
count = 12
3 0 0 -49.5 0
3 0 -82.312 0 0
3 -52.3511

type = float-attribute
name = IJK_TO_DICOM_REAL
count = 12
3 0 0 -49.5 0
3 0 -82.312 0 0
3 -52.3511

type = float-attribute
name = BRICK_STATS
count = 6
0 13722 0 10051 0
9968

type = integer-attribute
name = TAXIS_NUMS
count = 8
3 25 77002 -999 -999
-999 -999 -999

type = float-attribute
name = TAXIS_FLOATS
count = 8
0 3 0 -52.3511 3
-999999 -999999 -999999

type = float-attribute
name = TAXIS_OFFSETS
count = 25
0.3260869 1.826087 0.3913043 1.891304 0.4565217
1.956521 0.5217391 2.021739 0.5869564 2.086956
0.6521738 2.152174 0.7173912 2.217391 0.7826086
2.282609 0.8478259 2.347826 0.9130433 2.413044
0.9782607 2.478261 1.043478 2.543479 1.108696

type = integer-attribute
name = DATASET_RANK
count = 8
3 3 0 0 0
0 0 0

type = integer-attribute
name = DATASET_DIMENSIONS
count = 5
33 41 25 0 0

type = integer-attribute
name = BRICK_TYPES
count = 3
1 3 5

type = float-attribute
name = BRICK_FLOAT_FACS
count = 3
0 0 0

type = string-attribute
name = TEMPLATE_SPACE
count = 5
'ORIG~

type = integer-attribute
name = INT_CMAP
count = 1
0

type = string-attribute
name = BYTEORDER_STRING
count = 10
'LSB_FIRST~

type = string-attribute
name = BRICK_LABS
count = 9
'#0~#1~#2~
Binary file added nibabel/tests/data/example4d+orig.BRIK.gz
Binary file not shown.
Loading