Skip to content

Commit

Permalink
More tests, removed nonexistant output types
Browse files Browse the repository at this point in the history
  • Loading branch information
bbfrederick committed Nov 1, 2023
1 parent 7467493 commit 3b4df0b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
22 changes: 22 additions & 0 deletions rapidtide/data/examples/src/test_io
Original file line number Diff line number Diff line change
Expand Up @@ -294,3 +294,25 @@ tide_io.niftimerge(mergelist, os.path.join(DESTDIR, "merged"))
tide_io.niftiroi(
os.path.join(SOURCEDIR, "sub-HAPPYTEST.nii.gz"), os.path.join(DESTDIR, "roi"), 2, 9
)

dummy, dataarray, theheader, thedims, thesizes = tide_io.readfromnifti(
os.path.join(DESTDIR, "roi")
)
thetypes = [
np.uint8,
np.int16,
np.int32,
np.float32,
np.complex64,
np.float64,
np.int8,
np.uint16,
np.uint32,
np.int64,
np.uint64,
np.complex128,
]
for thedtype in thetypes:
tide_io.savetonifti(
dataarray.astype(thedtype), theheader, os.path.join(DESTDIR, "dtypetest"), debug=debug
)
12 changes: 6 additions & 6 deletions rapidtide/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ def savetonifti(thearray, theheader, thename, debug=False):
elif thedtype == np.uint64:
thedatatypecode = 1280
thebitpix = 64
elif thedtype == np.float128:
thedatatypecode = 1536
thebitpix = 128
# elif thedtype == np.float128:
# thedatatypecode = 1536
# thebitpix = 128
elif thedtype == np.complex128:
thedatatypecode = 1792
thebitpix = 128
elif thedtype == np.complex256:
thedatatypecode = 2048
thebitpix = 256
# elif thedtype == np.complex256:
# thedatatypecode = 2048
# thebitpix = 256
else:
raise TypeError("type", thedtype, "is not legal")
theheader["datatype"] = thedatatypecode
Expand Down

0 comments on commit 3b4df0b

Please sign in to comment.