|
1 | 1 | # emacs: -*- mode: python-mode; py-indent-offset: 4; indent-tabs-mode: nil -*-
|
2 | 2 | # vi: set ft=python sts=4 ts=4 sw=4 et:
|
3 | 3 | """Read and write transforms."""
|
| 4 | + |
4 | 5 | from nitransforms.io import afni, fsl, itk, lta, x5
|
5 | 6 | from nitransforms.io.base import TransformIOError, TransformFileError
|
6 | 7 |
|
|
27 | 28 |
|
28 | 29 |
|
29 | 30 | def get_linear_factory(fmt, is_array=True):
|
30 |
| - """Return the type required by a given format.""" |
| 31 | + """ |
| 32 | + Return the type required by a given format. |
| 33 | +
|
| 34 | + Parameters |
| 35 | + ---------- |
| 36 | + fmt : :obj:`str` |
| 37 | + A format identifying string. |
| 38 | + is_array : :obj:`bool` |
| 39 | + Whether the array version of the class should be returned. |
| 40 | +
|
| 41 | + Returns |
| 42 | + ------- |
| 43 | + type |
| 44 | + The class object (not an instance) of the linear transfrom to be created |
| 45 | + (for example, :obj:`~nitransforms.io.itk.ITKLinearTransform`). |
| 46 | +
|
| 47 | + Examples |
| 48 | + -------- |
| 49 | + >>> get_linear_factory("itk") |
| 50 | + <class 'nitransforms.io.itk.ITKLinearTransformArray'> |
| 51 | + >>> get_linear_factory("itk", is_array=False) |
| 52 | + <class 'nitransforms.io.itk.ITKLinearTransform'> |
| 53 | + >>> get_linear_factory("fsl") |
| 54 | + <class 'nitransforms.io.fsl.FSLLinearTransformArray'> |
| 55 | + >>> get_linear_factory("fsl", is_array=False) |
| 56 | + <class 'nitransforms.io.fsl.FSLLinearTransform'> |
| 57 | + >>> get_linear_factory("fakepackage") # doctest: +IGNORE_EXCEPTION_DETAIL |
| 58 | + Traceback (most recent call last): |
| 59 | + TypeError: Unsupported transform format <fakepackage>. |
| 60 | +
|
| 61 | + """ |
31 | 62 | if fmt.lower() not in _IO_TYPES:
|
32 | 63 | raise TypeError(f"Unsupported transform format <{fmt}>.")
|
33 | 64 |
|
|
0 commit comments