shamo.core.problems.single.components.grid_sampler.CompGridSampler¶
-
class
shamo.core.problems.single.components.grid_sampler.CompGridSampler(**kwargs)[source]¶ Bases:
shamo.core.problems.single.components.abc.CompABCStore information about a space grid sampler.
A grid sampler is used to convert outputs from GetDP into a NII file more suitable for neuroimaging studies.
- Other Parameters
- affine
numpy.ndarray The affine matrix of the grid.
- shape
tuple[int] The shape of the grid.
- mask
numpy.ndarray The mask of the grid.
- affine
Methods
Check is the grid is properly set.
Create a new dictionary with keys from iterable and values set to value.
Return the value for key if key is in the dictionary, else default.
Convert a POS file into a NII file.
If key is not found, d is returned if given, otherwise KeyError is raised
Remove and return a (key, value) pair as a 2-tuple.
Set the grid component.
Insert key with a value of default if key is not in the dictionary.
Return if the grid can be used.
Return the parameters required to render python template.
If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
Attributes
Return the affine matrix of the grid.
Return the mask of the grid.
Return the shape of the grid.
Return wether or not the grid can be used.
-
property
affine¶ Return the affine matrix of the grid.
- Returns
numpy.ndarrayThe affine matrix of the grid.
-
check(name, **kwargs)[source]¶ Check is the grid is properly set.
- Parameters
- name
str The name of the grid.
- name
- Raises
TypeErrorIf argument affine is not a numpy.ndarray.
ValueErrorIf argument affine is not (3, 4) or (4, 4) numpy.ndarray. If argument shape is not a 3D shape.
-
clear() → None. Remove all items from D.¶
-
copy() → a shallow copy of D¶
-
fromkeys(iterable, value=None, /)¶ Create a new dictionary with keys from iterable and values set to value.
-
get(key, default=None, /)¶ Return the value for key if key is in the dictionary, else default.
-
items() → a set-like object providing a view on D’s items¶
-
keys() → a set-like object providing a view on D’s keys¶
-
property
mask¶ Return the mask of the grid.
- Returns
numpy.ndarrayThe mask of the grid.
-
nii_from_pos(src, dst)[source]¶ Convert a POS file into a NII file.
- Parameters
- src
str,byteoros.PathLike The path to the POS file to convert.
- dst
str,byteoros.PathLike The path where the generated NII image must be saved.
- Returns
- ——-
- nibabel.Nifti1Image
The generated NII image.
- src
-
pop(k[, d]) → v, remove specified key and return the corresponding value.¶ If key is not found, d is returned if given, otherwise KeyError is raised
-
popitem(/)¶ Remove and return a (key, value) pair as a 2-tuple.
Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.
-
set(affine, shape, mask=None, resize=False)[source]¶ Set the grid component.
- Parameters
- affine
numpy.ndarray The affine matrix of the grid.
- shame
tuple[int] The shape of the grid.
- mask
numpy.ndarray,optional The mask of the grid. If set to
None, no mask is applied to the resulting data. (The default isNone)- resizebool,
optional If set to
True, the affine matrix is rescaled from meters to millimeters. (the default isFalse)
- affine
-
setdefault(key, default=None, /)¶ Insert key with a value of default if key is not in the dictionary.
Return the value for key if key is in the dictionary, else default.
-
to_pro_param(**kwargs)[source]¶ Return if the grid can be used.
- Returns
- bool
Return
Trueif the grid is set.
-
update([E, ]**F) → None. Update D from dict/iterable E and F.¶ If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]
-
property
use_grid¶ Return wether or not the grid can be used.
- Returns
- bool
Return
Trueif the grid can be used,Falseotherwise.
-
values() → an object providing a view on D’s values¶