Skip to content

Commit

Permalink
ENH: Allow ingestion of alternatively grouped CompositeH5s
Browse files Browse the repository at this point in the history
  • Loading branch information
mgxd committed Dec 20, 2024
1 parent 4d7ae6c commit 08c3c84
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions nitransforms/io/itk.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,20 @@ def from_h5obj(cls, fileobj, check=True, only_linear=False):
xfm_list = []
h5group = fileobj["TransformGroup"]
typo_fallback = "Transform"

start_idx = 1
for i, group in enumerate(h5group):
found = h5group[group].get(f'{typo_fallback}Parameters', None)
if found is not None:
start_idx = i
break

try:
h5group["1"][f"{typo_fallback}Parameters"]
h5group[f'{start_idx}'][f"{typo_fallback}Parameters"]
except KeyError:
typo_fallback = "Tranform"

for xfm in list(h5group.values())[1:]:
for xfm in list(h5group.values())[start_idx:]:
if xfm["TransformType"][0].startswith(b"AffineTransform"):
_params = np.asanyarray(xfm[f"{typo_fallback}Parameters"])
xfm_list.append(
Expand Down

0 comments on commit 08c3c84

Please sign in to comment.