| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- from types import SimpleNamespace
- from typing import Union
- from seqgen.pypulseq.supported_labels_rf_use import get_supported_labels
- def make_label(
- label: str, type: str, value: Union[bool, float, int]
- ) -> SimpleNamespace:
- """
- Create an ADC Label.
- Parameters
- ----------
- type : str
- Label type. Must be one of 'SET' or 'INC'.
- label : str
- Must be one of 'SLC', 'SEG', 'REP', 'AVG', 'SET', 'ECO', 'PHS', 'LIN', 'PAR', 'NAV', 'REV', or 'SMS'.
- value : bool, float or int
- Label value.
- Returns
- -------
- out : SimpleNamespace
- Label object.
- Raises
- ------
- ValueError
- If a valid `label` was not passed. Must be one of 'SLC', 'SEG', 'REP', 'AVG', 'SET', 'ECO', 'PHS', 'LIN', 'PAR',
- NAV', 'REV', or 'SMS'.
- If a valid `type` was not passed. Must be one of 'SET' or 'INC'.
- If `value` was not a valid numerical or logical value.
- """
- arr_supported_labels = get_supported_labels()
- if label not in arr_supported_labels:
- raise ValueError(
- "Invalid label. Must be one of 'SLC', 'SEG', 'REP', 'AVG', 'SET', 'ECO', 'PHS', 'LIN', 'PAR', "
- "NAV', 'REV', or 'SMS'."
- )
- if type not in ["SET", "INC"]:
- raise ValueError("Invalid type. Must be one of 'SET' or 'INC'.")
- if not isinstance(value, (bool, float, int)):
- raise ValueError("Must supply a valid numerical or logical value.")
- out = SimpleNamespace()
- if type == "SET":
- out.type = "labelset"
- elif type == "INC":
- out.type = "labelinc"
- out.label = label
- out.value = value
- return out
|