[docs]classAlignmentMethod(str,Enum):""" Allowed values for the stack alignment method. See :py:func:`etspy.align.align_stack` for more details. Group ----- align """STACK_REG="StackReg""Stack Registration method"PC="PC""Phase correlation method"COM="COM""Center of Mass method"COM_CL="COM-CL""Center of Mass with Common Line method"
[docs]@classmethoddefis_valid_value(cls,value)->bool:"""Test if value is contained in the AlignmentMethod enum."""try:cls(value)exceptValueError:returnFalseelse:returnTrue
[docs]@classmethoddefvalues(cls)->list[str]:"""Calculate a list of allowed values in the AlignmentMethod enum."""return[v.valuefor_,vincls.__members__.items()]
AlignmentMethodType=AlignmentMethod|Literal["PC","COM","COM-CL","StackReg"]FbpMethodType=Literal["ram-lak","shepp-logan","cosine","hamming","hann","none","tukey","lanczos","triangular","gaussian","barlett-hann","blackman","nuttall","blackman-harris","blackman-nuttall","flat-top","kaiser","parzen","projection","sinogram","rprojection","rsinogram",]ReconMethodType=Literal["FBP","SIRT","SART","DART"]def_get_literal_hint_values(function:Callable,param_name:str)->tuple:"""Get values specified by a Literal type for a given function and parameter."""returnget_args(get_type_hints(function)[param_name])def_format_choices(choices:list|tuple)->str:""" Format a list of values as a string showing options. For example, the tuple ("one", "two", "three") would be formatted as '["one", "two", or "three"]'. This method is helpful for printing context in error messages. """first_part=", ".join([f'"{i}"'ifisinstance(i,str)elsestr(i)foriinchoices[:-1]],)middle_part=", "iflen(choices[:-1])>1else" "last_part="or "+(f'"{choices[-1]}"'ifisinstance(choices[-1],str)elsestr(choices[-1]))returnf"[{first_part}{middle_part}{last_part}]"