The class for command-line handling around :class:`ScanSequence`. The command line interface for :class:`ScanSequence` data is highly structured, particularly in data saving and loading to support easy and accurate command-line compatibility. This class overloads so
(
self,
scan_type: type,
dicom_path,
load_path,
ignore_ext: bool = False,
group_by=None,
num_workers=0,
**kwargs,
)
| 76 | |
| 77 | class CommandLineScanContainer: |
| 78 | def __init__( |
| 79 | self, |
| 80 | scan_type: type, |
| 81 | dicom_path, |
| 82 | load_path, |
| 83 | ignore_ext: bool = False, |
| 84 | group_by=None, |
| 85 | num_workers=0, |
| 86 | **kwargs, |
| 87 | ): |
| 88 | """The class for command-line handling around :class:`ScanSequence`. |
| 89 | |
| 90 | The command line interface for :class:`ScanSequence` data is highly structured, |
| 91 | particularly in data saving and loading to support easy and accurate command-line |
| 92 | compatibility. |
| 93 | |
| 94 | This class overloads some standard functionality in :class:`ScanSequence` |
| 95 | (:func:`save`, :func:`load`). When methods are not implemented, this class provides |
| 96 | access directly to attributes/methods of the underlying scan instantiation. |
| 97 | For example, if ``scan_type=QDess``, the following will call |
| 98 | :func:`QDess.generate_t2_map`: |
| 99 | |
| 100 | >>> cli_scan = CommandLineScanContainer(QDess, dicom_path="/path/to/qdess/scan") |
| 101 | >>> cli_scan.generate_t2_map(...) # this calls cli_scan.scan.generate_t2_map |
| 102 | |
| 103 | Data is loaded either from the ``dicom_path`` or the ``load_path``. If both are specified, |
| 104 | the data is loaded from the ``dicom_path``. |
| 105 | |
| 106 | Args: |
| 107 | scan_type (type): A scan type. Should be subclass of `ScanSequence`. |
| 108 | dicom_path (str): The dicom path. This value can be ``None``, but must |
| 109 | be explicitly set. |
| 110 | load_path (str): The load path. This value can be ``None``, but must be |
| 111 | explicitly set. |
| 112 | ignore_ext (bool, optional): If ``True``, ignore extensions when loading |
| 113 | dicom data. See :func:`DicomReader.load` for details. |
| 114 | group_by (optional): The value(s) to group dicoms by. See :func:`DicomReader.load` |
| 115 | for details. |
| 116 | num_workers (int, optional): Number of works for loading scan. |
| 117 | |
| 118 | Attributes: |
| 119 | scan_type (type): The scan type to instantiate. |
| 120 | scan (ScanSequence): The instantiated scan. |
| 121 | generic_args (Dict[str, Any]): Generic duck typed parameter names and values. |
| 122 | If parameters with this name are part of the method signature, they will |
| 123 | automatically be set to the values in this dictionary. Keys include: |
| 124 | * "num_workers": Number of cpu workers to use. |
| 125 | * "max_workers": Alias for "num_workers" in some functions |
| 126 | * "verbose": Verbosity |
| 127 | * "show_pbar": Show progress bar. |
| 128 | |
| 129 | Raises: |
| 130 | NotADirectoryError: If ``dicom_path`` is not a path to a directory. |
| 131 | """ |
| 132 | self.scan_type = scan_type |
| 133 | |
| 134 | if (dicom_path is not None) and (not os.path.isdir(dicom_path)): |
| 135 | if load_path is not None: |
nothing calls this directly
no test coverage detected