kwneuro.resource module¶
- class kwneuro.resource.BvalResource¶
Bases:
ResourceBase class for resources representing a list of b-values associated with a 4D DWI volume stack.
- abstractmethod get()¶
Get the underlying array of b-values
- load()¶
Load a Resource. Specific functionality depends on the Resource subclass, but if the resource is considered to be ‘loaded’ then this should be a no-op, returning the same Resource back.
- Return type:
- class kwneuro.resource.BvecResource¶
Bases:
ResourceBase class for resources representing a list of b-vectors associated with a 4D DWI volume stack.
- abstractmethod get()¶
Get the underlying array of b-vectors of shape (N,3)
- load()¶
Load a Resource. Specific functionality depends on the Resource subclass, but if the resource is considered to be ‘loaded’ then this should be a no-op, returning the same Resource back.
- Return type:
- class kwneuro.resource.InMemoryBvalResource(array)¶
Bases:
BvalResourceA b-value list that is loaded into memory.
- class kwneuro.resource.InMemoryBvecResource(array)¶
Bases:
BvecResourceA b-vector list that is loaded into memory.
- get()¶
Get the underlying array of b-vectors of shape (N,3)
- class kwneuro.resource.InMemoryResponseFunctionResource(sh_coeffs, avg_signal)¶
Bases:
ResponseFunctionResourceA response function that is loaded into memory.
- avg_signal: floating¶
The average non-diffusion weighted signal within the voxels used to calculate the response function
- static from_dipy_object(obj)¶
Construct from a DIPY AxSymShResponse instance.
- Parameters:
obj (
AxSymShResponse)- Return type:
- static from_prolate_tensor(response, gtab, sh_order_max=8)¶
Convert a legacy DIPY prolate-tensor response (evals, S0) into spherical harmonic coefficients using the approach from DIPY’s csdeconv module: https://github.com/dipy/dipy/blob/f7b863f1485cd3fa6329c8e8f3388d8f58863f0d/dipy/reconst/csdeconv.py#L168. :type response:
tuple[ndarray[tuple[Any,...],dtype[TypeVar(_ScalarT, bound=generic)]],floating] :param response: Response function output by DIPY. :type gtab:GradientTable:param gtab: Gradient table used to estimate response :type sh_order_max:int:param sh_order_max: Maximum spherical harmonic order to use for the basis model. Default is 8.Returns: InMemoryResponseFunctionResource
- Return type:
- get()¶
Returns the underlying response function components as (sh_coeffs, avg_signal) :returns: An array of m=0 coefficients for even degrees l = [0, 2, …, sh_order].
The array length is ((sh_order / 2) + 1,), where sh_order is the maximal spherical harmonics order.
avg_signal: The mean signal intensity across the sphere, equivalent to the m=0, l=0 component.
- Return type:
- get_dipy_object()¶
Return the stored response function as a DIPY AxSymShResponse.
- Return type:
AxSymShResponse
- is_loaded: ClassVar[bool] = True¶
Whether a resource corresponds to in-memory data, rather than for example on-disk data.
- sh_coeffs: ndarray[tuple[Any, ...], dtype[floating]]¶
Spherical harmonic coefficients of the response function for an axially symmetric, even-degree model. Following the Dipy convention for symmetric signals, only even degrees (l = 0, 2, 4, …, sh_order) are included. Under the assumption of axial symmetry, only the m = 0 coefficients are included. The coefficients are ordered by increasing degree l:
Index 0: l=0, m=0 (proportional to the average signal or avg_signal) Index 1: l=2, m=0 Index 2: l=4, m=0 … Index M-1: l=sh_order, m=0
The total number of coefficients M is (sh_order / 2) + 1.
- class kwneuro.resource.InMemoryVolumeResource(array, affine=<factory>, metadata=<factory>)¶
Bases:
VolumeResourceA volume resource that is loaded into memory. An n-D array where n >= 3 and where three of the dimensions are spatial and have associated header information describing a patient coordinate system.
- Parameters:
- static from_ants_image(ants_image)¶
Create an InMemoryVolumeResource from an ANTsImage.
- Parameters:
ants_image (
ANTsImage)- Return type:
- get_affine()¶
Get the 4x4 affine matrix that maps index space to patient/scanner space
- is_loaded: ClassVar[bool] = True¶
Whether a resource corresponds to in-memory data, rather than for example on-disk data.
- load()¶
Load volume into memory
- Return type:
- to_ants_image()¶
Convert to an ANTsImage. This conversion creates a deep copy of the underlying data. The coordinate system is also converted from Nibabel’s RAS+ to ANTs/ LPS+ orientation.
- Return type:
ANTsImage
- class kwneuro.resource.Resource¶
Bases:
ABCBase class for all Resources. A Resource is a piece of data that could live in memory or on disk.
- class kwneuro.resource.ResponseFunctionResource¶
Bases:
ResourceBase class for resources representing a response function associated with a DWI.
- abstractmethod get()¶
Returns the underlying response function components as (sh_coeffs, avg_signal) :returns: An array of m=0 coefficients for even degrees l = [0, 2, …, sh_order].
The array length is ((sh_order / 2) + 1,), where sh_order is the maximal spherical harmonics order.
avg_signal: The mean signal intensity across the sphere, equivalent to the m=0, l=0 component.
- Return type:
- abstractmethod get_dipy_object()¶
Get the underlying response function in a format compatible with Dipy
- Return type:
AxSymShResponse
- load()¶
Load a Resource. Specific functionality depends on the Resource subclass, but if the resource is considered to be ‘loaded’ then this should be a no-op, returning the same Resource back.
- Return type:
- class kwneuro.resource.VolumeResource¶
Bases:
ResourceBase class for resources representing a volume or volume stack. An n-D array where n >= 3 and where three of the dimensions are spatial and have associated header information describing a patient coordinate system.
- abstractmethod get_affine()¶
Get the 4x4 affine matrix that maps index space to patient/scanner space
- abstractmethod get_array()¶
Get the underlying volume data array
- abstractmethod load()¶
Load volume into memory
- Return type: