Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

WIP: adding Philips XML/REC support#683

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
grlee77 wants to merge16 commits intonipy:master
base:master
Choose a base branch
Loading
fromgrlee77:xmlrec_v2
Open
Changes from1 commit
Commits
Show all changes
16 commits
Select commitHold shift + click to select a range
64ed188
add Philips XML/REC reader.
grlee77Oct 18, 2018
1ff1826
add XMLRECImage support to imageclasses.py
grlee77Oct 18, 2018
df2751e
Assign an enumerated value of -1 in the PAR image_defs header for unr…
grlee77Oct 19, 2018
8c405c1
expand enums_dict using empirically determined values
grlee77Oct 19, 2018
a4636b2
Fix reading strings into image_defs when dtype_format='xml'
grlee77Oct 19, 2018
570a7ed
XMLRECImage: file extensions should be specified in lower case
grlee77Oct 19, 2018
bbeb710
loading from .REC: special case to find .xml when .PAR not present
grlee77Oct 19, 2018
a7a9edc
remove explicit mention of PAR from warning/errors that could also oc…
grlee77Oct 19, 2018
ed43e97
Add XML/REC support to parrec2nii.py
grlee77Oct 19, 2018
5fa6810
refactor/simplify. Do not convert to PAR/REC style names
grlee77Oct 19, 2018
10bf7cc
remove permit_truncated restriction
grlee77Oct 19, 2018
8d62119
minor cleanup
grlee77Oct 19, 2018
d7bf693
XMLRECImage: fix for .REC expected case mismatch
grlee77Oct 22, 2018
fd88ccd
fix misnamed key within strict_sort
grlee77Oct 22, 2018
7048640
fix for conversion of DWI scans where only the trace was retained
grlee77Oct 22, 2018
4068548
fix bug in conversion of Boolean entries from string such as 'N' and 'Y'
grlee77Oct 22, 2018
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
PrevPrevious commit
fix bug in conversion of Boolean entries from string such as 'N' and 'Y'
prior to this commit, both would get stored as true because bool('N') == True
  • Loading branch information
@grlee77
grlee77 committedOct 22, 2018
commit4068548b786c88528033e658edf63db6ba1d9fa2
25 changes: 20 additions & 5 deletionsnibabel/xmlrec.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,15 @@ class XMLRECError(Exception):

# Dict for converting XML/REC types to appropriate python types
# could convert the Enumeration strings to int, but enums_dict is incomplete

def _xml_str_to_bool(s):
if isinstance(s, bytes):
s = s.decode()
if s == 'Y':
return True
else:
return False

# and the strings are more easily interpretable
xml_type_dict = {'Float': np.float32,
'Double': np.float64,
Expand DownExpand Up@@ -62,12 +71,15 @@ def _process_gen_dict_xml(xml_root):
a = e.attrib
if 'Name' in a:
entry_type = xml_type_dict[a['Type']]
if entry_type in ['S16', 'S32', 'S128']:
entry_type = str
if entry_type == bool:
# convert string such as 'N' or 'Y' to boolean
cast = _xml_str_to_bool
else:
cast = entry_type
if 'ArraySize' in a:
val = [entry_type(i) for i in e.text.strip().split()]
val = [cast(i) for i in e.text.strip().split()]
else:
val =entry_type(e.text)
val =cast(e.text)
general_info[a['Name']] = val
return general_info

Expand DownExpand Up@@ -166,6 +178,9 @@ def _get_val(entry_dtype, text):
val = text[:32]
elif entry_dtype == '|S128':
val = text[:128]
elif entry_dtype == bool:
# convert string 'Y' or 'N' to boolean
val = _xml_str_to_bool(text)
else:
val = entry_dtype(text)
return val
Expand DownExpand Up@@ -371,7 +386,7 @@ def get_bvals_bvecs(self):
Array of b vectors, shape (n_directions, 3), or None if not a
diffusion acquisition.
"""
if self.general_info['Diffusion'] == 0:
ifnotself.general_info['Diffusion']:
return None, None
reorder = self.get_sorted_slice_indices()
if len(self.get_data_shape()) == 3:
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp