Skip to content
This repository was archived by the owner on Jan 27, 2025. It is now read-only.
Merged
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
11 changes: 8 additions & 3 deletions src/eddymotion/dmri.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,15 @@ class DWI:
"""
fieldmap = attr.ib(default=None, repr=_data_repr)
"""A 3D displacements field to unwarp susceptibility distortions."""
_filepath = attr.ib(default=Path(mkdtemp()) / "em_cache.h5", repr=False)
_filepath = attr.ib(
factory=lambda: Path(mkdtemp()) / "em_cache.h5",
repr=False,
)
"""A path to an HDF5 file to store the whole dataset."""

def __len__(self):
"""Obtain the number of high-*b* orientations."""
return self.gradients.shape[-1]
return self.dataobj.shape[-1]

def logo_split(self, index, with_b0=False):
"""
Expand Down Expand Up @@ -201,7 +204,9 @@ def from_filename(cls, filename):
"""Read an HDF5 file from disk."""
with h5py.File(filename, "r") as in_file:
root = in_file["/0"]
data = {k: np.asanyarray(v) for k, v in root.items()}
data = {
k: np.asanyarray(v) for k, v in root.items() if not k.startswith("_")
}
return cls(**data)


Expand Down