+
    ?i}                         R t ^ RIHt ^ RIt^ RIt^ RIHtHtHtHtH	t	H
t
HtHtHtHt ^ RIt^ RIt^RIHtHtHt ^RIHtHt ]P2                  ! ]4      t ! R R4      t ! R R	4      t ! R
 R]4      tR R ltR# )a  Read SPE files.

This plugin supports reading files saved in the Princeton Instruments
SPE file format.

Parameters
----------
check_filesize : bool
    The number of frames in the file is stored in the file header. However,
    this number may be wrong for certain software. If this is `True`
    (default), derive the number of frames also from the file size and
    raise a warning if the two values do not match.
char_encoding : str
    Deprecated. Exists for backwards compatibility; use ``char_encoding`` of
    ``metadata`` instead.
sdt_meta : bool
    Deprecated. Exists for backwards compatibility; use ``sdt_control`` of
    ``metadata`` instead.

Methods
-------
.. note::
    Check the respective function for a list of supported kwargs and detailed
    documentation.

.. autosummary::
    :toctree:

    SpePlugin.read
    SpePlugin.iter
    SpePlugin.properties
    SpePlugin.metadata

)datetimeN)
AnyCallableDictIteratorListMappingOptionalSequenceTupleUnion)RequestIOModeInitializationError)PluginV3ImagePropertiesc                      ] tR t^@tRtRR9RR:RR;RR<RR=RR>/t/ RR?bR	R
]P                  ! . R@O4      ^
3bRRAbRRBbRRCbRRDbRREbRRFbRRGbRRHbRRIbRRJbRRKbRRLbRRMbRRNbRROb/ RRPbRRQbRRRbRRSbRRTbRRUbR RVbR!RWbR"RXbR#RYbR$RZbR%R[bR&R\bR'R]bR(R^bR)R_bR*R`bCR+RaR,RbR-RcR.RdR/ReR0RfR1RgRR<R2RhR3RiR4RjR5RkRR>/CtR6t	^ ]P                  ! ]P                  4      ^]P                  ! ]P                  4      ^]P                  ! ]P                  4      ^]P                  ! ]P                  4      ^]P                  ! ]P                  4      /t. RlOt. RmOtR,.tR7tR8# )nSpeca/  SPE file specification data

Tuples of (offset, datatype, count), where offset is the offset in the SPE
file and datatype is the datatype as used in `numpy.fromfile`()

`data_start` is the offset of actual image data.

`dtypes` translates SPE datatypes (0...4) to numpy ones, e. g. dtypes[0]
is dtype("<f") (which is np.float32).

`controllers` maps the `type` metadata to a human readable name

`readout_modes` maps the `readoutMode` metadata to something human readable
although this may not be accurate since there is next to no documentation
to be found.
datatypexdimydimxml_footer_offset	NumFramesfile_header_verNumROIROIsi  xDimDetyDimDet	VChipXdim	VChipYdimcontroller_versionlogic_outputamp_high_cap_low_noisemodeexposure_secdatedetector_tempdetector_typest_diode
delay_timeshutter_controlabsorb_liveabsorb_modecan_do_virtual_chipthreshold_min_livethreshold_min_valthreshold_max_livethreshold_max_val
time_localtime_utc
adc_offsetadc_rateadc_typeadc_resolutionadc_bit_adjustgaincomments	geometric
sw_versionspare_4
XPrePixelsXPostPixels
YPrePixelsYPostPixelsreadout_timetypeclockspeed_usreadout_modewindow_sizei   N)l   <h)*   <H)i  rK   )i  z<Q)i  z<i)i  <f)i  rI   ))startxrK   )endxrK   )groupxrK   )startyrK   )endyrK   )groupyrK   )   rK   )   rK   )   rI   )   rI   )    rI   )   rI   )   rK   )   rI   )
   rL   )   z<10S)$   rL   )(   rI   ),   rI   ).   rL   )2   rK   )4   rI   )6   rK   )8   rI   ):   rI   )<   rL   )@   rI   )B   rL   )   <7S)   rj   )   rK   )   rK   )   rK   )   rK   )   rK   )   rK   )   z<80S   )iX  rK   )i  z<16S)i  z<436S)b   rI   )d   rI   )f   rI   )h   rI   )i  rL   )i  rI   )i  rL   )i  rK   )i  rK   )znew120 (Type II)zold120 (Type I)ST130ST121ST138zDC131 (PentaMax)zST133 (MicroMax/Roper)zST135 (GPIB)VTCCDzST116 (GPIB)zOMA3 (GPIB)OMA4)z
full framezframe transferkinetics)__name__
__module____qualname____firstlineno____doc__basicnpdtypemetadata
data_startfloat32int32int16uint16uint32dtypescontrollersreadout_modes	no_decode__static_attributes__rG       Q/var/www/html/photoedit/myenv/lib/python3.14/site-packages/imageio/plugins/spe.pyr   r   @   s   $ 	K
[\<EB,B 	HH	 
B$ 	9%B& 	:'B( 	Z)B* 	Z+B. 	i/B0 		1B2 	!)3B4 		5B6 	
7B8 	9B: 	;B< 	=B> 	J?B@ 	jABF 	:GBH 	zIBJ 	zKBL 	zMBN 	jOBP 	ZQBR 	jSBT 	ZUBV 	lWBX 	LYBZ 	k[B\ 	K]B^ 	K_B` 	+aBb 	+cBd 	eBf 	$gBh 	[iBj 	m>j{k{[|<CBHH J 	
288BJJ	288BHH	288BHH	288BII	288BIIFK" AM Ir   r   c                     a a ] tR t^t oRt/ R^bR^bR^bR^bR^bR^bR^bR	^bR
^bR^bR^bR^	bR^
bR^
bR^bR^bR^btRRRRRRRR/t ! R R4      tRE/ R]! ^]! ^B^D4      ]	4      bR]! ^]! ^D^F4      ]	4      bR]! ^]! ^ ^4      ]
4      bR ]! ^]! ^@^I4      ]RF4      bR!]! ^]! ^
^4      ]
4      bR"]! ^]! ^^4      ]	4      bR#]! ^^R$ 4      bR%]! ^^ R& 4      bR']! ^]! ^^ 4      ]	4      bR(]! ^^!R) 4      bR*]! ^]! ^^4      ]R+4      bR,]! ^]! ^^
4      V 3R- l4      bR.]! ^]! ^^4      ]RF4      bR/]! ^]! ^ ^4      ]	4      bR0]! ^]! ^
^4      ]RG4      bR1]! ^]! ^^4      ]	4      bR2]! ^]! ^^4      ]RF4      bR3]! ^]! ^^
4      ]	4      R4]! ^]! ^^%4      ]RF4      R5]! ^]! ^^
4      ]	4      R6]! ^]! ^I^O4      ]RF4      R7]! ^]! ^%^.4      ]RF4      R8]! ^]! ^.^74      ]RF4      R9]! ^]! ^7^@4      ]RF4      /CRHR:]! ^]! ^"^#4      R; 4      //t]V3R< lR= l4       t]V3R> lV 3R? ll4       t]V3R@ lV 3RA ll4       t]RIV3RB lV 3RC lll4       tRDtVtV ;t# )JSDTControlSpeca  Extract metadata written by the SDT-control software

Some of it is encoded in the comment strings
(see :py:meth:`parse_comments`). Also, date and time are encoded in a
peculiar way (see :py:meth:`get_datetime`). Use :py:meth:`extract_metadata`
to update the metadata dict.
u   JänJanFebu   MärMarAprMaiMayJunJulAugSepOktOctNovDezDecSEQUstandardSETOTOCCSLKINEr}   SEAR	arbitraryc                   R   a  ] tR t^t o Rt    ]R3V 3R lR lltV 3R ltRtV t	R# )SDTControlSpec.CommentDescz>Describe how to extract a metadata entry from a comment stringNc          	      Z   < V ^8  d   QhRS[ RS[RS[S[.S[3,          RS[S[,          /# )rX   nslicecvtscale)intr   r   strr   r	   float)format__classdict__s   "r   __annotate__'SDTControlSpec.CommentDesc.__annotate__   sB     
	 
	
	 
	 3%*%	
	
 E?
	r   c                6    Wn         W n        W0n        W@n        R # N)r   r   r   r   )selfr   r   r   r   s   &&&&&r   __init__#SDTControlSpec.CommentDesc.__init__   s     FJHJr   c                v   < V ^8  d   Qh/ S[ ;R&   S[;R&   S[S[.S[3,          ;R&   S[RS[3,          ;R&   # )rX   r   r   r   Nr   )r   r   r   r   r   r   r   )r   r   s   "r   r   r      sK       
   seSj!!  T5[!! r   )r   r   r   r   )
r~   r   r   r   r   r   r   __annotate_func__r   __classdictcell__)r   s   @r   CommentDescr      s/     L 	8><1 ),%)
	 
	  r   r   sdt_major_versionsdt_minor_versionsdt_controller_nameexposure_time
color_codedetection_channelsbackground_subtractionc                    V R 8H  # )BrG   xs   &r   <lambda>SDTControlSpec.<lambda>  s    18r   	em_activec                    V R 8H  # )ErG   r   s   &r   r   r     s    a3hr   em_gainmodulation_activec                    V R 8H  # )ArG   r   s   &r   r   r   
  s    a3hr   
pixel_sizeg?sequence_typec                *   < SP                   V ,          # r   )sequence_types)r   	__class__s   &r   r   r     s    9+C+CA+Fr   gridn_macrodelay_macron_mini
delay_minin_microdelay_micro	n_subpicsdelay_shutterdelay_prebleachbleach_timerecovery_timebleach_piezo_activec                    V R 8H  # )zrG   r   s   &r   r   r     s	    1PS8r   c                L   < V ^8  d   QhRS[ S[,          RS[S[S[3,          /# )rX   r:   return)r
   r   r   r   )r   r   s   "r   r   SDTControlSpec.__annotate__"  s'      hsm c3h r   c                    V ^,          R,          R8w  d   R#  \        V ^,          R,          4      \        V ^,          R,          4      3#   \         d    Ru # i ; i)zGet the version of SDT-control metadata encoded in the comments

Parameters
----------
comments
    List of SPE file comments, typically ``metadata["comments"]``.

Returns
-------
Major and minor version. ``-1, -1`` if detection failed.
:F   L   NCOMVER:r   N   N:r   P   N)r   )r   
ValueError)r:   s   &r   get_comment_version"SDTControlSpec.get_comment_version!  sZ     A;u)M	x{5)*CE0B,CCC 	M	s   1A AAc                h   < V ^8  d   QhRS[ S[,          RS[S[S[3,          RS[S[S[3,          /# )rX   r:   versionr   )r
   r   r   r   r   r   )r   r   s   "r   r   r   6  s9     0 03-0*/S/0	c3h0r   c           	        < / p\        V^,          ^,           4       F  p SP                  V^ ,          V3,          pTP                  4        F\  w  rV TP	                  YP
                  ,          TP                  ,          4      pTP                  e   YvP                  ,          pYrT&   K^  	  K  	  VSP                  9  dV   RP                  \        R SP                  4      4      p	\        P                  ! RV^ ,           RV^,          R R	V	 R
24       V ^ ,          V ^,          ,           p
V
P                  4       VR&   V#   \         d     EK5  i ; i  \         d-   p\        P                  ! RT RT 24       RY%&    Rp?EK;  Rp?ii ; i)zExtract SDT-control metadata from comments

Parameters
----------
comments
    List of SPE file comments, typically ``metadata["comments"]``.
version
    Major and minor version of SDT-control metadata format

Returns
-------
Dict of metadata
Nz-Failed to decode SDT-control metadata field `z`: z, c                 .    V ^ ,           RV ^,          R 2# )rW   .02rG   r   s   &r   r   /SDTControlSpec.parse_comments.<locals>.<lambda>]  s    1a!Ry1r   z)Unsupported SDT-control metadata version r   r   z. Only versions z@ are supported. Some or all SDT-control metadata may be missing.comment)rangecomment_fieldsKeyErroritemsr   r   r   r   	Exceptionwarningswarnjoinmapstrip)r:   r   sdt_mdminorcmtnamespecvesupported_verr   r   s   &&         r   parse_commentsSDTControlSpec.parse_comments5  sv   " 71:>*E
..wqz5/@A "iik
	(&&!1$**!=>Azz-ZZ#$4L * +( )222 II193K3KLM MM;GAJ<qQRTV X!!. 0CC
 1++#MMOy1   ! (MMGvSQRPST $(FLL	(s*   EAEEEF! FFc                @   < V ^8  d   QhRS[ RS[ RS[S[R3,          /# )rX   r%   timer   N)r   r   r   )r   r   s   "r   r   r   i  s0     R R3 Rc ReHdN.C Rr   c                ^  <  SP                   V R,          ,          p\        \        V R,          4      V\        V R,          4      \        VR,          4      \        VR,          4      \        VR,          4      4      #   \         d%   p\        P                  RT R24        Rp?R# Rp?ii ; i)	a  Turn date and time saved by SDT-control into proper datetime object

Parameters
----------
date
    SPE file date, typically ``metadata["date"]``.
time
    SPE file date, typically ``metadata["time_local"]``.

Returns
-------
File's datetime if parsing was succsessful, else None.
:rX   rs   N:rs   	   N:rW   rX   N:rX   rY   N:rY   rS   Nz1Failed to decode date from SDT-control metadata: r   N)monthsr   r   r  loggerinfo)r%   r  monthr  r   s   &&  r   get_datetimeSDTControlSpec.get_datetimeh  s    	R$$T#Y/EDIDIDIDIDI   	RKKKA3aPQQ	Rs   A9A= =B,B''B,c                &   < V ^8  d   QhRS[ RS[/# )rX   metachar_encoding)r   r   )r   r   s   "r   r   r     s     *! *!w *!s *!r   c                  < SP                  V R,          4      p\        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      '       d   \        P                  R4       R# SP	                  V R,          V4      pV P                  R4       V P                  V4       SP                  V R,          V R,          4      pV'       d'   W@R	&   V P                  R4       V P                  R4       V R
,          p VP                  V4      V R&   V P                  R
4       V P                  R4       V P                  R4       R#   \         d    \        P                  ! R4        LGi ; i)a*  Extract SDT-control metadata from SPE metadata

SDT-control stores some metadata in comments and other fields.
Extract them and remove unused entries.

Parameters
----------
meta
    SPE file metadata. Modified in place.
char_encoding
    Character encoding used to decode strings in the metadata.
r:   c              3   *   "   T F	  q^ 8  x  K  	  R# 5i)rW   NrG   ).0cs   & r   	<genexpr>2SDTControlSpec.extract_metadata.<locals>.<genexpr>  s     %f1ufs   TFzSDT-control comments not found.Nr%   r2   r   r=   modulation_scriptzHFailed to decode SDT-control laser modulation script. Bad char_encoding?r3   r$   )r   anyr  debugr  popupdater  decodeUnicodeDecodeErrorr  r  )r  r   comversdt_metadtsp4r   s   &&    r   extract_metadataSDTControlSpec.extract_metadata  s$    ..tJ/?@3%f%333%f%%%LL:;++D,<fEH ##DL$|2DE!HHVHH\"9o	(+

=(AD$%HHY 	  " 	MM8	s   >%E !E+*E+rG   )rs   rW   gư>gMbP?)rs      )latin1)r~   r   r   r   r   r  r   r   r   r   r   r   r  staticmethodr   r  r  r2  r   r   __classcell__r   r   s   @@r   r   r      s     	q 	q	
 	 	q 	q 	q 	q 	q 	q 	q 	q 	r 	r  	r!" 	r#$ 	r%F. 	

N 2 	 
Qb"s!C
Qb"s!C
 ";q%1+s#C
 [E"bM5&I	

 +ar2<
 !+ar2"D
 %k!R9K&L
 Q,>?
 {1eBmS9
  Q4F!G
 +ar2sC
 [5B<!F
 K5R=%@
  {1eAqk37!
" ;q%B-G#
$ k!U1a[#6%
& +ar2vF'
( {1eArlC8;q%B-GQac:[E"bM5&I{1eBmUFK;q%B-G[E"bM5&I5
8 	!;q%B-AS#T
; ND  & 0 0 0d R R R6 *! *! *! *!r   r   c                      a a ] tR tRt oRV3R lV 3R llltRR/V3R lR lltV3R lR	 ltRV3R
 lR lltV3R lR ltV3R lR lt	RV3R lR llt
V3R lR ltRtVtV ;t# )	SpePlugini  c          
      V   < V ^8  d   QhRS[ RS[RS[S[,          RS[S[,          RR/# )rX   requestcheck_filesizer   r/  r   N)r   boolr	   r   )r   r   s   "r   r   SpePlugin.__annotate__  sS     NS NSNS NS  }	NS
 4.NS 
NSr   c           	     4  < \         SV `  V4       VP                  P                  \        P
                  8X  d   \        R4      hVe   \        P                  ! R\        4       W0n
        Ve   \        P                  ! R\        4       W@n        V P                  P                  4       V n         V P                  \         P"                  R4      pVR,          V n        \         P&                  VR,          ,          V n        VR,          VR	,          3V n        VR
,          V n        V'       Ed(   VR,          ^8  d   VR,          pMDV P                  P/                  ^ \0        P2                  4       V P                  P5                  4       pV\         P6                  ,
          pWpP*                  ^ ,          V P*                  ^,          ,          V P(                  P8                  ,          ,          pWpP,                  8w  dY   \        P                  ! RV P                  P:                   RV P,                   RV R24       \=        WpP,                  4      V n        V P                  P/                  \         P6                  4       R#   \>         d    \        R4      hi ; i)ai  Instantiate a new SPE file plugin object

Parameters
----------
request : Request
    A request object representing the resource to be operated on.
check_filesize : bool
    If True, compute the number of frames from the filesize, compare it
    to the frame count in the file header, and raise a warning if the
    counts don't match. (Certain software may create files with
char_encoding : str
    Deprecated. Exists for backwards compatibility; use ``char_encoding`` of
    ``metadata`` instead.
sdt_meta : bool
    Deprecated. Exists for backwards compatibility; use ``sdt_control`` of
    ``metadata`` instead.

zcannot write SPE filesNz{Passing `char_encoding` to the constructor is deprecated. Use `char_encoding` parameter of the `metadata()` method instead.ztPassing `sdt_meta` to the constructor is deprecated. Use `sdt_control` parameter of the `metadata()` method instead.r5  r   r   r   r   r   r   zThe file header of z claims there are z  frames, but there are actually z frames.z)SPE plugin cannot read the provided file.) superr   r#   io_moder   writer   r  r  DeprecationWarning_char_encoding	_sdt_metar<  get_file_file_parse_headerr   r   _file_header_verr   _dtype_shape_lenseekosSEEK_ENDtellr   itemsizefilenameminr  )	r   r<  r=  r   r/  r  data_endliner   s	   &&&&&   r   r   SpePlugin.__init__  s   4 	!<<6<</%&>??$MM #	 ,MM #	 "\\**,
	S %%djj(;D$():$;D!++d:&67DK<f6DK[)DI~
 )*a/#$78HJJOOAr{{3#zz0H$//1Q$++a.84;;;O;OOO99$MM-dll.C.C-DDV99+%EdV8U !$D)) 4DIJJOODOO, 	S%&QRR	Ss   /GJ   Jindex.c                :   < V ^8  d   QhRS[ RS[P                  /# rX   rX  r   )r   r   ndarray)r   r   s   "r   r   r?    s     #' #'S #'2:: #'r   c               J   V\         J dh   \        P                  pV P                  ^ ,          V P                  ^,          ,          V P                  ,          pV P                  .V P                  O5pMV^ 8  d   \        RV R24      hWP                  8  d   \        RV RV P                   R24      h\        P                  WP                  ^ ,          ,          V P                  ^,          ,          V P                  P                  ,          ,           pV P                  ^ ,          V P                  ^,          ,          pV P                  pV P                  P                  V4       \        P                  ! V P                  V P                  VR7      pVP                  V4      # )zRead a frame or all frames from the file

Parameters
----------
index : int
    Select the index-th frame from the file. If index is `...`,
    select all frames and stack them along a new axis.

Returns
-------
A Numpy array of pixel values.

zIndex `z` is smaller than 0.z5` exceeds the number of frames stored in this file (`z`).r   count)Ellipsisr   r   rL  rM  
IndexErrorrK  rR  rH  rN  r   fromfilereshape)r   rX  read_offsetr^  	out_shapedatas   &$    r   readSpePlugin.read  s8    H//KKKNT[[^3dii?E1T[[1IQYwug-ABCCii% UVZV_V_U``cd 
 ++a.(4;;q>9DKK<P<PPQ  KKNT[[^3EI

${{4::T[[F||I&&r   c                D   < V ^8  d   QhRS[ S[P                  ,          /# rX   r   )r   r   r[  )r   r   s   "r   r   r?  (  s     > >hrzz* >r   c                B   a  V 3R l\        S P                  4       4       # )zRIterate over the frames in the file

Yields
------
A Numpy array of pixel values.
c              3   H   <"   T F  pSP                  VR 7      x  K  	  R# 5i))rX  N)rf  )r#  ir   s   & r   r%  !SpePlugin.iter.<locals>.<genexpr>0  s!     =,<q			"",<s   ")r   rM  )r   s   fr   iterSpePlugin.iter(  s     >E$)),<==r   c                N   < V ^8  d   QhRS[ RS[RS[RS[RS[S[S[3,          /# )rX   rX  exclude_appliedr   sdt_controlr   )r   r>  r   r   r   )r   r   s   "r   r   r?  2  sL     R( R(R( R( 	R(
 R( 
c3hR(r   c                    V P                   ^8  dF   V P                  e   V P                  pV P                  e   V P                  pV P                  W44      # V P	                  4       # )uq  SPE specific metadata.

Parameters
----------
index : int
    Ignored as SPE files only store global metadata.
exclude_applied : bool
    Ignored. Exists for API compatibility.
char_encoding : str
    The encoding to use when parsing strings.
sdt_control : bool
    If `True`, decode special metadata written by the
    SDT-control software if present.

Returns
-------
metadata : dict
    Key-value pairs of metadata.

Notes
-----
SPE v3 stores metadata as XML, whereas SPE v2 uses a binary format.

.. rubric:: Supported SPE v2 Metadata fields

ROIs : list of dict
    Regions of interest used for recording images. Each dict has the
    "top_left" key containing x and y coordinates of the top left corner,
    the "bottom_right" key with x and y coordinates of the bottom right
    corner, and the "bin" key with number of binned pixels in x and y
    directions.
comments : list of str
    The SPE format allows for 5 comment strings of 80 characters each.
controller_version : int
    Hardware version
logic_output : int
    Definition of output BNC
amp_hi_cap_low_noise : int
    Amp switching mode
mode : int
    Timing mode
exp_sec : float
    Alternative exposure in seconds
date : str
    Date string
detector_temp : float
    Detector temperature
detector_type : int
    CCD / diode array type
st_diode : int
    Trigger diode
delay_time : float
    Used with async mode
shutter_control : int
    Normal, disabled open, or disabled closed
absorb_live : bool
    on / off
absorb_mode : int
    Reference strip or file
can_do_virtual_chip : bool
    True or False whether chip can do virtual chip
threshold_min_live : bool
    on / off
threshold_min_val : float
    Threshold minimum value
threshold_max_live : bool
    on / off
threshold_max_val : float
    Threshold maximum value
time_local : str
    Experiment local time
time_utc : str
    Experiment UTC time
adc_offset : int
    ADC offset
adc_rate : int
    ADC rate
adc_type : int
    ADC type
adc_resolution : int
    ADC resolution
adc_bit_adjust : int
    ADC bit adjust
gain : int
    gain
sw_version : str
    Version of software which created this file
spare_4 : bytes
    Reserved space
readout_time : float
    Experiment readout time
type : str
    Controller type
clockspeed_us : float
    Vertical clock speed in microseconds
readout_mode : ["full frame", "frame transfer", "kinetics", ""]
    Readout mode. Empty string means that this was not set by the
    Software.
window_size : int
    Window size for Kinetics mode
file_header_ver : float
    File header version
chip_size : [int, int]
    x and y dimensions of the camera chip
virt_chip_size : [int, int]
    Virtual chip x and y dimensions
pre_pixels : [int, int]
    Pre pixels in x and y dimensions
post_pixels : [int, int],
    Post pixels in x and y dimensions
geometric : list of {"rotate", "reverse", "flip"}
    Geometric operations
sdt_major_version : int
    (only for files created by SDT-control)
    Major version of SDT-control software
sdt_minor_version : int
    (only for files created by SDT-control)
    Minor version of SDT-control software
sdt_controller_name : str
    (only for files created by SDT-control)
    Controller name
exposure_time : float
    (only for files created by SDT-control)
    Exposure time in seconds
color_code : str
    (only for files created by SDT-control)
    Color channels used
detection_channels : int
    (only for files created by SDT-control)
    Number of channels
background_subtraction : bool
    (only for files created by SDT-control)
    Whether background subtraction war turned on
em_active : bool
    (only for files created by SDT-control)
    Whether EM was turned on
em_gain : int
    (only for files created by SDT-control)
    EM gain
modulation_active : bool
    (only for files created by SDT-control)
    Whether laser modulation (“attenuate”) was turned on
pixel_size : float
    (only for files created by SDT-control)
    Camera pixel size
sequence_type : str
    (only for files created by SDT-control)
    Type of sequnce (standard, TOCCSL, arbitrary, …)
grid : float
    (only for files created by SDT-control)
    Sequence time unit (“grid size”) in seconds
n_macro : int
    (only for files created by SDT-control)
    Number of macro loops
delay_macro : float
    (only for files created by SDT-control)
    Time between macro loops in seconds
n_mini : int
    (only for files created by SDT-control)
    Number of mini loops
delay_mini : float
    (only for files created by SDT-control)
    Time between mini loops in seconds
n_micro : int (only for files created by SDT-control)
    Number of micro loops
delay_micro : float (only for files created by SDT-control)
    Time between micro loops in seconds
n_subpics : int
    (only for files created by SDT-control)
    Number of sub-pictures
delay_shutter : float
    (only for files created by SDT-control)
    Camera shutter delay in seconds
delay_prebleach : float
    (only for files created by SDT-control)
    Pre-bleach delay in seconds
bleach_time : float
    (only for files created by SDT-control)
    Bleaching time in seconds
recovery_time : float
    (only for files created by SDT-control)
    Recovery time in seconds
comment : str
    (only for files created by SDT-control)
    User-entered comment. This replaces the "comments" field.
datetime : datetime.datetime
    (only for files created by SDT-control)
    Combines the "date" and "time_local" keys. The latter two plus
    "time_utc" are removed.
modulation_script : str
    (only for files created by SDT-control)
    Laser modulation script. Replaces the "spare_4" key.
bleach_piezo_active : bool
    (only for files created by SDT-control)
    Whether piezo for bleaching was enabled
)rJ  rE  rF  _metadata_pre_v3_metadata_post_v3)r   rX  rq  r   rr  s   &&&&&r   r   SpePlugin.metadata2  s]    X   1$"". $ 3 3~~)"nn((DD%%''r   c                B   < V ^8  d   QhRS[ RS[RS[S[ S[3,          /# )rX   r   rr  r   )r   r>  r   r   )r   r   s   "r   r   r?    s0     D Dc D DcSVh Dr   c                   V P                  \        P                  V4      pVP                  RR4      pV^8  d   ^MTp\	        VR,          RV 4      VR&   R Uu. uF  qSP                  VR4      NK  	  upVR&   R Uu. uF  qSP                  VR4      NK  	  upVR&   R Uu. uF  qSP                  VR4      NK  	  upVR&   R Uu. uF  qSP                  VR4      NK  	  upVR&   VR,           Uu. uF  p\        V4      NK  	  upVR&   . pVP                  R	^ 4      pV^,          '       d   VP                  R
4       V^,          '       d   VP                  R4       V^,          '       d   VP                  R4       WsR	&   VR,          p	^T	u;8:  d   \        \        P                  4      8:  d&   M M"\        P                  V	^,
          ,          VR&   MRVR&   VR,          p
^T
u;8:  d   \        \        P                  4      8:  d&   M M"\        P                  V
^,
          ,          VR&   MRVR&   R F  p\        W5,          4      W5&   K  	  V'       d   \        P                  W14       V# u upi u upi u upi u upi u upi )a  Extract metadata from SPE v2 files

Parameters
----------
char_encoding
    String character encoding
sdt_control
    If `True`, try to decode special metadata written by the
    SDT-control software.

Returns
-------
dict mapping metadata names to values.

r   Nr   	chip_sizevirt_chip_size
pre_pixelspost_pixelsr:   r;   rotatereversefliprC   rE   )r   r   )r   r   )r>   r@   )r?   rA   )r+   r-   r.   r0   )rI  r   r   r*  roi_array_to_dictr   appendlenr   r   r>  r   r2  )r   r   rr  mnrkr$  gftrs   &&&        r   rt  SpePlugin._metadata_pre_v3  s-   " t}}m<UU8T"q&Qb%ain5&	 3II2HQ%%4.2HI+7QR7Q!uuQ~7QR
3OP3Oa55D>3OP,4RS4RqEE!TN4RS- *+:7AQ7* EE+q!q55HHXq55HHYq55HHV+ fI*S))**((Q/AfIAfIn,S++,, $ 2 21q5 9An $An
A :AD
 ++A=Y JRPS 8s   I0>I5"I:I?1Jc                6   < V ^8  d   QhRS[ S[S[3,          /# ri  )r   r   r   )r   r   s   "r   r   r?  L  s      4S> r   c                    V P                  \        P                  R4      pV P                  P	                  VR,          4       V P                  P                  4       pRV/# )zqExtract XML metadata from SPE v3 files

Returns
-------
dict with key `"__xml"`, whose value is the XML metadata
r5  r   __xml)rI  r   r   rH  rN  rf  )r   r  xmls   &  r   ru  SpePlugin._metadata_post_v3L  sJ     !!$**h7

012jjoo~r   c                &   < V ^8  d   QhRS[ RS[/# rZ  )r   r   )r   r   s   "r   r   r?  Y  s     U U Uo Ur   c                    V\         J d<   \        V P                  .V P                  O5V P                  V P                  RR7      # \        V P                  V P                  RR7      # )a~  Standardized ndimage metadata.

Parameters
----------
index : int
    If the index is an integer, select the index-th frame and return
    its properties. If index is an Ellipsis (...), return the
    properties of all frames in the file stacked along a new batch
    dimension.

Returns
-------
properties : ImageProperties
    A dataclass filled with standardized image metadata.
T)shaper   n_imagesis_batchF)r  r   r  )r_  r   rM  rL  rK  )r   rX  s   &&r   
propertiesSpePlugin.propertiesY  sV    " H"yy/4;;/kk	  T[[eTTr   c                X   < V ^8  d   QhRS[ S[S[3,          RS[RS[S[S[3,          /# )rX   r  r   r   )r   r   r   r   r   )r   r   s   "r   r   r?  s  s6     , ,CJ',8;,	c3h,r   c                  a / p\         P                  ! V3R l4      pVP                  4        F  w  rVV P                  P	                  V^ ,          4       \        V4      ^8  d   ^MV^,          p\         P                  ! V P                  V^,          VR7      pVP                  P                  R8X  d   V\        P                  9  d
    V! V4      p VP                  4       pWV&   K  	  V#   \         d    \        P                  ! RT R24        LBi ; i  \         d    \         P                   ! T4      p LXi ; i)aN  Get information from SPE file header

Parameters
----------
spec
    Maps header entry name to its location, data type description and
    optionally number of entries. See :py:attr:`Spec.basic` and
    :py:attr:`Spec.metadata`.
char_encoding
    String character encoding

Returns
-------
Dict mapping header entry name to its value
c                 &   < V P                  S4      # r   )r,  )r   r   s   &r   r   )SpePlugin._parse_header.<locals>.<lambda>  s    (?r   r]  SzFailed to decode "z3" metadata string. Check `char_encoding` parameter.)r   	vectorizer  rH  rN  r  ra  r   kindr   r   r  r  r  itemr   squeeze)	r   r  r   retr,  r  spcntr  s	   &&f      r   rI  SpePlugin._parse_headers  s   & ?@

HDJJOOBqE"2w{!1CDJJbe3?Aww||s"t4>>'Aq	A" FFH I) %* 
 ! MM,TF 3C C  "JJqM"s$   C.D.%DD!D=<D=)rE  rK  rH  rJ  rM  rF  rL  )TNN).Tr5  T).)r~   r   r   r   r   rf  rn  r   rt  ru  r  rI  r   r   r7  r8  s   @@r   r:  r:    so     NS NS`#'3 #' #'J> >R( R(hD DL U U4, , ,r   r:  c                    V ^8  d   QhR\         P                  R\        \        \        \        \
        ,          3,          ,          /# )rX   ar   )r   r[  r   r   r   r   )r   s   "r   r   r     s0       T#tCy.-A(B r   c           
         . pV . RO,          p V  F\  w  r#rErgR\        V4      \        V4      .R\        V4      \        V4      .R\        V4      \        V4      ./pVP                  V4       K^  	  V# )a4  Convert the `ROIs` structured arrays to :py:class:`dict`

Parameters
----------
a
    Structured array containing ROI data

Returns
-------
One dict per ROI. Keys are "top_left", "bottom_right", and "bin",
values are tuples whose first element is the x axis value and the
second element is the y axis value.
top_leftbottom_rightbin)rM   rP   rN   rQ   rO   rR   )r   r  )	r  	dict_listsxsyexeygxgyroi_dicts	   &        r   r  r    sz     I	
BCA"#R#b'*SWc"g.CGSW%

 	" #$ r   ) r   r   loggingrO  typingr   r   r   r   r   r   r	   r
   r   r   r  numpyr   core.requestr   r   r   core.v3_plugin_apir   r   	getLoggerr~   r  r   r   r:  r  rG   r   r   <module>r     st   !F   	     ? ? :			8	$~ ~Bn! n!bm m`r   