U
    f»{j®Þ  ã                   @   s€  d Z ddlmZ ddlmZ ddlZddlm	Z	m
Z
mZmZmZmZmZmZmZmZmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZmZmZm Z  ddl!m"Z" ed9dd„ƒZ#d:dd„Z$dd„ Z%ed;dd„ƒZ&edddœdd„ƒZ'd<dd„Z(d=dd„Z)ed>dd „ƒZ*d!d"„ Z+ed?d$d%„ƒZ,d&d'„ Z-d@d)d*„Z.ed+d,„ ƒZ/edAd/d0„ƒZ0d1d2„ Z1eG d3d4„ d4e2ƒƒZ3d5d6œd7d8„Z4dS )Bz$IO with fif files containing events.é    N)ÚSequenceé   )Úcheck_fnameÚloggerÚverboseÚ_get_stim_channelÚwarnÚ_validate_typeÚ_check_optionÚfill_docÚ_check_fnameÚ_on_missingÚ_check_on_missing)ÚFIFF)Údir_tree_find)Úread_tag)Ú	fiff_open)Ú	write_intÚstart_blockÚstart_and_end_fileÚ	end_block)Úpick_channelsFc                 C   s  |dk	rzt |tƒs|g}tjt| ƒtd�}|D ]@}t || dd…df |k¡}|r.t || dd…df |k¡}q.| | } n„|dk	rôt |tƒs’|g}tjt| ƒtd�}|D ]@}t || dd…df |k¡}|r¨t || dd…df |k¡}q¨| | } n
t 	| ¡} t| ƒdk�rt
dƒ‚| S )aÞ  Select some :term:`events`.

    Parameters
    ----------
    %(events)s
    include : int | list | None
        A event id to include or a list of them.
        If None all events are included.
    exclude : int | list | None
        A event id to exclude or a list of them.
        If None no event is excluded. If include is not None
        the exclude parameter is ignored.
    step : bool
        If True (default is False), events have a step format according
        to the argument output='step' in the function find_events().
        In this case, the two last columns are considered in inclusion/
        exclusion criteria.

    Returns
    -------
    events : array, shape (n_events, 3)
        The list of events.
    N©Údtypeé   r   r   zNo events found)Ú
isinstanceÚlistÚnpÚzerosÚlenÚboolÚ
logical_orÚonesÚlogical_andÚcopyÚRuntimeError)ÚeventsÚincludeÚexcludeÚstepÚmaskÚe© r,   úH/var/www/html/bwave/python/venv/lib/python3.8/site-packages/mne/event.pyÚpick_events   s,    




r.   c              	   C   sr  |dkr|}d| }t || ƒ}	t || ƒ}
g }g }|  ¡  t ¡D ]Ä}|d |krB|d |	 }|d |
 }| | dd…df |k| dd…df |k @ | dd…df |k@  }| ¡ rà||d |d d  g7 }||d< ||g7 }qB|dk	rB||d< ||g7 }| tj¡ qBt |¡}tjdd�� tj	|dd�}W 5 Q R X | ¡ �rL||9 }n
t g ¡}| ¡ �rd|nt g ¡|fS )	aÍ  Define new events by co-occurrence of existing events.

    This function can be used to evaluate events depending on the
    temporal lag to another event. For example, this can be used to
    analyze evoked responses which were followed by a button press within
    a defined time window.

    Parameters
    ----------
    events : ndarray
        Array as returned by mne.find_events.
    reference_id : int
        The reference event. The event defining the epoch of interest.
    target_id : int
        The target event. The event co-occurring in within a certain time
        window around the reference event.
    sfreq : float
        The sampling frequency of the data.
    tmin : float
        The lower limit in seconds from the target event.
    tmax : float
        The upper limit border in seconds from the target event.
    new_id : int
        New ID for the new event.
    fill_na : int | None
        Fill event to be inserted if target is not available within the time
        window specified. If None, the 'null' events will be dropped.

    Returns
    -------
    new_events : ndarray
        The new defined events.
    lag : ndarray
        Time lag between reference and target in milliseconds.
    Ng     @�@r   r   Úignore)ÚinvalidZf8r   )
Úintr$   ÚastypeÚanyÚappendr   ÚnanÚarrayZerrstateÚabs)r&   Zreference_idZ	target_idÚsfreqÚtminÚtmaxÚnew_idZfill_naZtsampleZiminZimaxZ
new_eventsZlagÚeventÚlowerÚupperÚresr,   r,   r-   Údefine_target_eventsN   s>    %ÿÿ




r@   c           
      C   sR  t |tjƒ}t|ƒdkr(|  ¡  tdƒ‚|d }d}d}|d D ]4}|j}|j}|tjkr@t	| |ƒ}|j
}d|_ qvq@|dkr†tdƒ‚|d D ]º}|j}|j}|tjkrât	| |ƒ}|j
}dd„ | d	¡D ƒ}	d
d„ |	D ƒ} �qJqŽ|tjkrŽt	| |ƒ}|j
}| ¡  d¡ d¡dd… }t|ƒt|ƒk�s.t‚dd„ t||ƒD ƒ} �qJqŽ||fS )zAux function.r   zCould not find event dataNÚ	directory)éÿÿÿÿé   zCould not find any eventsc                 S   s,   g | ]$}d d„ |ddd…   dd¡D ƒ‘qS )c                 S   s   g | ]}|d d d… ‘qS )NrB   r,   )Ú.0Úsr,   r,   r-   Ú
<listcomp>³   s     z/_read_events_fif.<locals>.<listcomp>.<listcomp>NrB   ú:r   )Úsplit)rD   Úmr,   r,   r-   rF   ³   s   ÿz$_read_events_fif.<locals>.<listcomp>ú;c                 S   s   i | ]\}}|t |ƒ“qS r,   )r1   )rD   ÚvÚkr,   r,   r-   Ú
<dictcomp>µ   s      z$_read_events_fif.<locals>.<dictcomp>zlatin-1ú rB   c                 S   s   i | ]\}}||d  “qS ©r   r,   ©rD   rL   rK   r,   r,   r-   rM   ¼   s      )r   r   ÚFIFFB_MNE_EVENTSr   ÚcloseÚ
ValueErrorÚkindÚposÚFIFF_MNE_EVENT_LISTr   ÚdataÚshapeZFIFF_DESCRIPTIONrH   ZFIFF_MNE_EVENT_COMMENTSÚtobytesÚdecodeÚAssertionErrorÚzip)
ÚfidÚtreer&   Ú
event_listÚevent_idÚdrT   rU   ÚtagZm_r,   r,   r-   Ú_read_events_fif—   sH    



ÿ

rc   Úandc              	   C   s¸  t | ddƒ t | ¡d  ¡ }|dks.|dkrft| ƒ\}}	}
|�}t||	ƒ\}}W 5 Q R X | t¡}nÖtj	| tj
d� t¡}t|ƒdkr�tdƒ‚|jdkr¬|tjd	d	…f }t|d ƒd
krÈdddg}n$t|d ƒdkrädddg}ntdƒ‚|d	d	…|f }|d	k	�r8|jd dk�r8|d dk�r8|dd	… }tdƒ d	}t|||ƒ}|jd }|d	k	�r�t|||ƒ}|jd }||k �r�td || |¡ƒ |}|�r´|d	k�r¬tdƒ‚||f}|S )a
  Read :term:`events` from fif or text file.

    See :ref:`tut-events-vs-annotations` and :ref:`tut-event-arrays`
    for more information about events.

    Parameters
    ----------
    filename : str
        Name of the input file.
        If the extension is .fif, events are read assuming
        the file is in FIF format, otherwise (e.g., .eve,
        .lst, .txt) events are read as coming from text.
        Note that new format event files do not contain
        the "time" column (used to be the second column).
    include : int | list | None
        A event id to include or a list of them.
        If None all events are included.
    exclude : int | list | None
        A event id to exclude or a list of them.
        If None no event is excluded. If include is not None
        the exclude parameter is ignored.
    mask : int | None
        The value of the digital mask to apply to the stim channel values.
        If None (default), no masking is performed.
    mask_type : 'and' | 'not_and'
        The type of operation between the mask and the trigger.
        Choose 'and' (default) for MNE-C masking behavior.

        .. versionadded:: 0.13
    return_event_id : bool
        If True, ``event_id`` will be returned. This is only possible for
        ``-annot.fif`` files produced with MNE-C ``mne_browse_raw``.

        .. versionadded:: 0.20
    %(verbose)s

    Returns
    -------
    %(events)s
    event_id : dict
        Dictionary of ``{str: int}`` mappings of event IDs.

    See Also
    --------
    find_events, write_events

    Notes
    -----
    This function will discard the offset line (i.e., first line with zero
    event number) if it is present in a text file.

    For more information on ``mask`` and ``mask_type``, see
    :func:`mne.find_events`.
    r&   )
ú.eveú-eve.fifú-eve.fif.gzú-eve.lstú-eve.txtú_eve.fifú_eve.fif.gzú_eve.lstú_eve.txtz
-annot.fifr   ú.fifú.gzr   r   zNo text lines foundNé   r   rC   z,Unknown number of columns in event text file)r   r   z/first row of event file discarded (zero-valued)z{} of {} events maskedzNo event_id found in the file)r   ÚopÚsplitextr=   r   rc   r2   r1   r   ZloadtxtZfloat64r   rS   ÚndimÚnewaxisrX   r   r.   Ú_mask_trigsÚformatr%   )Úfilenamer'   r(   r*   Ú	mask_typeZreturn_event_idr   Úextr]   r^   Ú_Úfr_   r`   ÚlinesZgoodsZunmasked_lenZ
masked_lenÚoutr,   r,   r-   Úread_eventsÁ   sN    9

ÿ



ÿ
r~   )Ú	overwriter   c             	   C   s¦   t | |d�} t| ddƒ t | ¡d  ¡ }|dkrpt| ƒ�.}t|tjƒ t	|tj
|jƒ t|tjƒ W 5 Q R X n2t| dƒ�"}|D ]}| dt|ƒ ¡ q€W 5 Q R X dS )	aã  Write :term:`events` to file.

    Parameters
    ----------
    filename : str
        Name of the output file.
        If the extension is .fif, events are written in
        binary FIF format, otherwise (e.g., .eve, .lst,
        .txt) events are written as plain text.
        Note that new format event files do not contain
        the "time" column (used to be the second column).
    %(events)s
    %(overwrite)s
    %(verbose)s

    See Also
    --------
    read_events
    )r   r&   )	re   rf   rg   rh   ri   rj   rk   rl   rm   r   )rn   ro   Úwz%6d %6d %3d
N)r   r   rq   rr   r=   r   r   r   rQ   r   rV   ÚTr   ÚopenÚwriteÚtuple)rw   r&   r   r   ry   r]   r{   r+   r,   r,   r-   Úwrite_events/  s    
r…   c                 C   sÊ  t j| dd�dk}t  t j|dd�¡d }t|ƒdkrDt jddd�S | d|f }|d7 }| d|f }||7 }t j|||f }	|d k	r¬|	d }
|
|kr¬t j|	dd||
gdd�}	|d k	rì|	d }
|
|krìt| d ƒ| }t j|	||
|ggdd�}	|dk�rÆt  |	d d …df ¡}|t	|ƒk}t  
|¡�rÆt  |¡d }t  |¡}|dk�rl|	|df |	|d df< t  |d	¡}n&|	|d d
f |	|d
f< t  |dd	¡}|	d d …df |	d d …d
f k}t  ||¡}|	| }	|	S )Nr   ©Zaxisr   ©r   rC   Úint32r   )r   r   )rB   r   Tr   )r   ÚdiffÚwhereÚallr   ÚemptyÚc_Úinsertr4   r7   r3   Zlogical_notr#   )rW   Ú
first_sampÚ	pad_startÚpad_stopÚmergeÚchangedÚidxZpre_stepZ	post_stepZstepsrK   Zlast_idxr‰   rŠ   ZkeepÚis_stepr,   r,   r-   Ú_find_stim_stepsU  sB    


 r–   c                 C   s†   t || jƒ}t| jd |d�}t|ƒdkr2tdƒ‚| |dd…f \}}t |dk ¡rftdƒ t |¡}| 	tj
¡}t|| j|||d�S )a\  Find all steps in data from a stim channel.

    Parameters
    ----------
    raw : Raw object
        The raw data.
    pad_start : None | int
        Values to assume outside of the stim channel (e.g., if pad_start=0 and
        the stim channel starts with value 5, an event of [0, 0, 5] will be
        inserted at the beginning). With None, no steps will be inserted.
    pad_stop : None | int
        Values to assume outside of the stim channel, see ``pad_start``.
    merge : int
        Merge steps occurring in neighboring samples. The integer value
        indicates over how many samples events should be merged, and the sign
        indicates in which direction they should be merged (negative means
        towards the earlier event, positive towards the later event).
    stim_channel : None | str | list of str
        Name of the stim channel or all the stim channels
        affected by the trigger. If None, the config variables
        'MNE_STIM_CHANNEL', 'MNE_STIM_CHANNEL_1', 'MNE_STIM_CHANNEL_2',
        etc. are read. If these are not found, it will default to
        'STI101' or 'STI 014', whichever is present.

    Returns
    -------
    steps : array, shape = (n_samples, 3)
        For each step in the stim channel the values [sample, v_from, v_to].
        The first column contains the event time in samples (the first sample
        with the new value). The second column contains the stim channel value
        before the step, and the third column contains value after the step.

    See Also
    --------
    find_events : More sophisticated options for finding events in a Raw file.
    Úch_names©r'   r   ú0No stim channel found to extract event triggers.Nz?Trigger channel contains negative values, using absolute value.)r�   r‘   r’   )r   Úinfor   r   rS   r   r3   r   r7   r2   Úint64r–   r�   )Úrawr�   r‘   r’   Ústim_channelÚpicksrW   rz   r,   r,   r-   Úfind_stim_steps‚  s    '

 ÿrŸ   ÚonsetÚ
increasingc
                 C   s   | j d dkst‚|dkr8t|d ƒ}
|
|kr<|
d8 }
nd}
|  tj¡} |r`|  tj¡ tj¡} |  ¡ dk r~tdƒ t 	| ¡} t
| |d|
d�}| d }|dkrÌ|	r¼tj|d|d|gdd�}nt d |¡¡ t|||ƒ}|dk�r8|d	d	…d
f |d	d	…df k}t t ||d	d	…d
f dk¡|d	d	…df dk¡}nX|�rh|d	d	…d
f dk}|d	d	…df dk}n(|d	d	…df dk}|d	d	…d
f dk}t |¡d }t |¡d }t|ƒdk�sÈt|ƒdk�rÖtjddd�S |d |d k�rþt d¡ t |d¡}|d |d k�r&t d¡ t |d¡}|dk�r:|| }n�|dk�rZt ||¡}|| }np|dk�r¾||d
f }|| }|d	d	…d
f |d	d	…df< ||d	d	…d
f< |d	d	…df  d8  < ntd| ƒ‚t dt|ƒ ¡ t dt |d	d	…d
f ¡ ¡ |S )zHelp find events.r   r   z¾Trigger channel contains negative values, using absolute value. If data were acquired on a Neuromag system with STI016 active, consider using uint_cast=True to work around an acquisition bug)r‘   r’   )r   r   r†   zkTrigger channel has a non-zero initial value of {} (consider using initial_event=True to detect this event)r¡   Nr   r‡   rˆ   r   z6Removing orphaned offset at the beginning of the file.rB   z/Removing orphaned onset at the end of the file.r    r)   ÚoffsetzInvalid output parameter %rz%s events foundzEvent IDs: %s)rX   r[   r1   r2   r   r›   Zuint16Úminr   r7   r–   rŽ   r   rš   rv   ru   r#   r!   rŠ   r   rŒ   ÚdeleteZunion1drS   Úunique)rW   r�   r   ÚoutputÚconsecutiveÚmin_samplesr*   Ú	uint_castrx   Úinitial_eventr’   r&   Úinitial_valueZonsetsÚoffsetsZ	onset_idxZ
offset_idxr”   r`   r,   r,   r-   Ú_find_events¸  sz    

   ÿþ
 ÿ






 r­   c                 C   sh   t  | ¡ t  t j| jj| jd  f¡¡}t j|dd�\}}t| ƒt|ƒ }|dkr`t	d| ƒ | | S )z+Uniquify events (ie remove duplicated rows.r   T)Zreturn_indexr   zhSome events are duplicated in your different stim channels. %d events were ignored during deduplication.)
r   ZascontiguousarrayÚviewr   ÚvoidÚitemsizerX   r¥   r   r   )r&   r+   rz   r”   Zn_dupesr,   r,   r-   Ú_find_unique_events  s    
ÿÿr±   r   c                 C   s4  || j d  }zt|| j ƒ}W n. tk
rL   t| jƒdkrFtdƒ‚n‚ Y nX t| j d |d�}t|ƒdkrttdƒ‚| |dd…f \}}g }|D ]n}t|tjdd…f | j	|
|||||||	d�
}t 
t |dd…df ¡|k ¡}|dkrôtd	| ƒ‚| |¡ q�tj|dd
�}t|ƒ}|t |dd…df ¡ }|S )a+  Find :term:`events` from raw file.

    See :ref:`tut-events-vs-annotations` and :ref:`tut-event-arrays`
    for more information about events.

    Parameters
    ----------
    raw : Raw object
        The raw data.
    stim_channel : None | str | list of str
        Name of the stim channel or all the stim channels
        affected by triggers. If None, the config variables
        'MNE_STIM_CHANNEL', 'MNE_STIM_CHANNEL_1', 'MNE_STIM_CHANNEL_2',
        etc. are read. If these are not found, it will fall back to
        'STI 014' if present, then fall back to the first channel of type
        'stim', if present. If multiple channels are provided
        then the returned events are the union of all the events
        extracted from individual stim channels.
    output : 'onset' | 'offset' | 'step'
        Whether to report when events start, when events end, or both.
    consecutive : bool | 'increasing'
        If True, consider instances where the value of the events
        channel changes without first returning to zero as multiple
        events. If False, report only instances where the value of the
        events channel changes from/to zero. If 'increasing', report
        adjacent events only when the second event code is greater than
        the first.
    min_duration : float
        The minimum duration of a change in the events channel required
        to consider it as an event (in seconds).
    shortest_event : int
        Minimum number of samples an event must last (default is 2). If the
        duration is less than this an exception will be raised.
    mask : int | None
        The value of the digital mask to apply to the stim channel values.
        If None (default), no masking is performed.
    uint_cast : bool
        If True (default False), do a cast to ``uint16`` on the channel
        data. This can be used to fix a bug with STI101 and STI014 in
        Neuromag acquisition setups that use channel STI016 (channel 16
        turns data into e.g. -32768), similar to ``mne_fix_stim14 --32``
        in MNE-C.

        .. versionadded:: 0.12
    mask_type : 'and' | 'not_and'
        The type of operation between the mask and the trigger.
        Choose 'and' (default) for MNE-C masking behavior.

        .. versionadded:: 0.13
    initial_event : bool
        If True (default False), an event is created if the stim channel has a
        value different from 0 as its first sample. This is useful if an event
        at t=0s is present.

        .. versionadded:: 0.16
    %(verbose)s

    Returns
    -------
    %(events)s

    See Also
    --------
    find_stim_steps : Find all the steps in the stim channel.
    read_events : Read events from disk.
    write_events : Write events to disk.

    Notes
    -----
    .. warning:: If you are working with downsampled data, events computed
                 before decimation are no longer valid. Please recompute
                 your events after decimation, but note this reduces the
                 precision of event timing.

    Examples
    --------
    Consider data with a stim channel that looks like::

        [0, 32, 32, 33, 32, 0]

    By default, find_events returns all samples at which the value of the
    stim channel increases::

        >>> print(find_events(raw)) # doctest: +SKIP
        [[ 1  0 32]
         [ 3 32 33]]

    If consecutive is False, find_events only returns the samples at which
    the stim channel changes from zero to a non-zero value::

        >>> print(find_events(raw, consecutive=False)) # doctest: +SKIP
        [[ 1  0 32]]

    If consecutive is True, find_events returns samples at which the
    event changes, regardless of whether it first returns to zero::

        >>> print(find_events(raw, consecutive=True)) # doctest: +SKIP
        [[ 1  0 32]
         [ 3 32 33]
         [ 4 33 32]]

    If output is 'offset', find_events returns the last sample of each event
    instead of the first one::

        >>> print(find_events(raw, consecutive=True, # doctest: +SKIP
        ...                   output='offset'))
        [[ 2 33 32]
         [ 3 32 33]
         [ 4  0 32]]

    If output is 'step', find_events returns the samples at which an event
    starts or ends::

        >>> print(find_events(raw, consecutive=True, # doctest: +SKIP
        ...                   output='step'))
        [[ 1  0 32]
         [ 3 32 33]
         [ 4 33 32]
         [ 5 32  0]]

    To ignore spurious events, it is also possible to specify a minimum
    event duration. Assuming our events channel has a sample rate of
    1000 Hz::

        >>> print(find_events(raw, consecutive=True, # doctest: +SKIP
        ...                   min_duration=0.002))
        [[ 1  0 32]]

    For the digital mask, if mask_type is set to 'and' it will take the
    binary representation of the digital mask, e.g. 5 -> '00000101', and will
    allow the values to pass where mask is one, e.g.::

              7 '0000111' <- trigger value
             37 '0100101' <- mask
         ----------------
              5 '0000101'

    For the digital mask, if mask_type is set to 'not_and' it will take the
    binary representation of the digital mask, e.g. 5 -> '00000101', and will
    block the values where mask is one, e.g.::

              7 '0000111' <- trigger value
             37 '0100101' <- mask
         ----------------
              2 '0000010'
    r8   r   z‚No stim channels found, but the raw object has annotations. Consider using mne.events_from_annotations to convert these to events.r—   r˜   r™   N)r   r¦   r§   r¨   r*   r©   rx   rª   zØYou have %i events shorter than the shortest_event. These are very unusual and you may want to set min_duration to a larger value e.g. x / raw.info['sfreq']. Where x = 1 sample shorter than the shortest event length.r†   )rš   r   rS   r   Úannotationsr   r­   r   rt   r�   Úsumr‰   r4   Úconcatenater±   Zargsort)rœ   r�   r¦   r§   Zmin_durationÚshortest_eventr*   r©   rx   rª   r   r¨   rž   rW   rz   Zevents_listra   r&   Zn_short_eventsr,   r,   r-   Úfind_events  sD     
    ü ûr¶   c                 C   sÂ   t d|ddgƒ |dk	r&t|dddƒ t| ƒ}|dkr>|  ¡ S |dk	rš|dkrZt |¡}n|dkrntd	| ƒ‚t | dd…d
d…f |¡| dd…d
d…f< | | dd…d
f | dd…df k } | S )zMask digital trigger values.rx   Znot_andrd   Nr1   r*   zint or Noner   z@'mask_type' should be either 'and' or 'not_and', instead of '%s'r   r   )r
   r	   r   r$   r   Zbitwise_notrS   Úbitwise_and)r&   r*   rx   Ún_eventsr,   r,   r-   ru   Ü  s     ÿ,$ru   Tc           	      C   s¦   t  | ¡} |  ¡ }g }dD ]B}|D ]8}| dd…|f |k}||||f< | t  |¡d ¡ q"q|s¢t  t  |¡¡}t j|| | fdd�}|t  |jddd… ¡ }|S )aÞ  Merge a set of :term:`events`.

    Parameters
    ----------
    events : array, shape (n_events_in, 3)
        Events.
    ids : array of int
        The ids of events to merge.
    new_id : int
        The new id.
    replace_events : bool
        If True (default), old event ids are replaced. Otherwise,
        new events will be added to the old event list.

    Returns
    -------
    new_events : array, shape (n_events_out, 3)
        The new events.

    Notes
    -----
    Rather than merging events you can use hierarchical event_id
    in Epochs. For example, here::

        >>> event_id = {'auditory/left': 1, 'auditory/right': 2}

    And the condition 'auditory' would correspond to either 1 or 2.

    Examples
    --------
    Here is quick example of the behavior::

        >>> events = [[134, 0, 1], [341, 0, 2], [502, 0, 3]]
        >>> merge_events(events, [1, 2], 12, replace_events=True)
        array([[134,   0,  12],
               [341,   0,  12],
               [502,   0,   3]])
        >>> merge_events(events, [1, 2], 12, replace_events=False)
        array([[134,   0,   1],
               [134,   0,  12],
               [341,   0,   2],
               [341,   0,  12],
               [502,   0,   3]])
    )r   r   Nr   r†   rB   )	r   Zasarrayr$   r4   rŠ   r¥   r´   Zlexsortr�   )	r&   Úidsr;   Zreplace_eventsÚ
events_outZidx_touchedÚcolÚir*   r,   r,   r-   Úmerge_eventsñ  s    -
r½   c                 C   sR   |   ¡ } |dkrtdƒ}nt | dd…df |¡}| |df  t|| ƒ7  < | S )aÐ  Shift a set of :term:`events`.

    Parameters
    ----------
    %(events)s
    ids : ndarray of int | None
        The ids of events to shift.
    tshift : float
        Time-shift event. Use positive value tshift for forward shifting
        the event and negative value for backward shift.
    sfreq : float
        The sampling frequency of the data.

    Returns
    -------
    new_events : array of int, shape (n_new_events, 3)
        The new events.
    Nr   r   )r$   Úslicer   Zin1dr1   )r&   r¹   Ztshiftr8   r*   r,   r,   r-   Úshift_time_events.  s    
r¿   ç      ð?ç        c                 C   sn  ddl m} t| |dƒ t|tdƒ t|ddƒ t|ddƒ t|ƒt|ƒ }}d|  krb|k stn td	||f ƒ‚| j|d
d�d }|dk	r¢| j|d
d�d }n
| jd }|rÔ|| j }t	|| j | jd gƒ}nt	|t
| jƒgƒ}|tt | jd | ¡ƒ8 }t ||d | jd ||  ¡ t¡}t
|ƒ}	|	dk�rBtdƒ‚tj|tj|	td�|tj|	td� f }
|
S )a  Make a set of :term:`events` separated by a fixed duration.

    Parameters
    ----------
    raw : instance of Raw
        A raw object to use the data from.
    id : int
        The id to use (default 1).
    start : float
        Time of first event (in seconds).
    stop : float | None
        Maximum time of last event (in seconds). If None, events extend to the
        end of the recording.
    duration : float
        The duration to separate events by (in seconds).
    first_samp : bool
        If True (default), times will have :term:`first_samp` added to them, as
        in :func:`mne.find_events`. This behavior is not desirable if the
        returned events will be combined with event times that already
        have :term:`first_samp` added to them, e.g. event times that come
        from :func:`mne.find_events`.
    overlap : float
        The overlap between events (in seconds).
        Must be ``0 <= overlap < duration``.

        .. versionadded:: 0.18

    Returns
    -------
    %(events)s
    r   )ÚBaseRawrœ   ÚidÚnumericÚdurationÚoverlapr   z/overlap must be >=0 but < duration (%s), got %sT)Zuse_roundingNr8   zANo events produced, check the values of start, stop, and durationr   )Zio.baserÂ   r	   r1   ÚfloatrS   Ztime_as_indexZ	last_sampr�   r£   r   Útimesr   Úroundrš   Zaranger2   r�   r   r"   )rœ   rÃ   ÚstartÚstoprÅ   r�   rÆ   rÂ   Útsr¸   r&   r,   r,   r-   Úmake_fixed_length_eventsL  s>    "ÿ

ÿÿ
ÿrÍ   c           	      C   sè   t | tdƒ t| ƒt|ƒkr,t| ƒt|ƒks4tdƒ‚t |¡}t |¡}t || d ¡}| d }t| dd… |dd… |dd… ƒD ]\\}}}| ¡ }|dd…df  |8  < |dd…df  ||d  7  < tj	||fdd�}q†|S )aè  Concatenate event lists to be compatible with concatenate_raws.

    This is useful, for example, if you processed and/or changed
    events in raw files separately before combining them using
    :func:`mne.concatenate_raws`.

    Parameters
    ----------
    events : list of array
        List of :term:`events` arrays, typically each extracted from a
        corresponding raw file that is being concatenated.
    first_samps : list or array of int
        First sample numbers of the raw files concatenated.
    last_samps : list or array of int
        Last sample numbers of the raw files concatenated.

    Returns
    -------
    events : array
        The concatenated events.

    See Also
    --------
    mne.concatenate_raws
    r&   zBevents, first_samps, and last_samps must all have the same lengthsr   r   NrB   r†   )
r	   r   r   rS   r   r6   Zcumsumr\   r$   r´   )	r&   Zfirst_sampsZ
last_sampsZn_sampsrº   r+   r{   ÚnÚe2r,   r,   r-   Úconcatenate_events�  s    ÿ

. rÐ   c                   @   sº   e Zd ZdZddddgZdZdZdZed	 Zed
 Z	dd„ Z
dd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zedd„ ƒZedd „ ƒZed!d"„ ƒZed#d$„ ƒZd*d(d)„Zd%S )+ÚAcqParserFIFaê  Parser for Elekta data acquisition settings.

    This class parses parameters (e.g. events and averaging categories) that
    are defined in the Elekta TRIUX/VectorView data acquisition software (DACQ)
    and stored in ``info['acq_pars']``. It can be used to reaverage raw data
    according to DACQ settings and modify original averaging settings if
    necessary.

    Parameters
    ----------
    %(info_not_none)s This is where the DACQ parameters will be taken from.

    Attributes
    ----------
    categories : list
        List of averaging categories marked active in DACQ.
    events : list
        List of events that are in use (referenced by some averaging category).
    reject : dict
        Rejection criteria from DACQ that can be used with mne.Epochs.
        Note that mne does not support all DACQ rejection criteria
        (e.g. spike, slope).
    flat : dict
        Flatness rejection criteria from DACQ that can be used with mne.Epochs.
    acq_dict : dict
        All DACQ parameters.

    See Also
    --------
    mne.io.Raw.acqparser : Access the parser through a Raw attribute.

    Notes
    -----
    Any averaging category (also non-active ones) can be accessed by indexing
    as ``acqparserfif['category_name']``.
    ÚERFZDEFZACQZTCP)ZmegMaxZmegMinZmegNoiseZmegSlopeZmegSpikeZeegMaxZeegMinZeegNoiseZeegSlopeZeegSpikeZeogMaxZecgMaxÚncategÚneventZ
stimSourceZ
triggerMapÚupdateZartefIgnoreZ
averUpdate)ÚCommentZDelay)rÖ   ZDisplayZStartÚStateZEndÚEventZNaveZReqEventZReqWhenZ	ReqWithinZSubAve)ZmagMaxZmagMinZmagNoiseZmagSlopeZmagSpikeÚversion)ÚNameZChannelZNewBitsZOldBitsZNewMaskZOldMaskc                 C   s¢  |d }|st dƒ‚t|  |¡ƒ| _d| jkr6d| _nd| jkrHd| _nt dƒ‚| jr\| jn| j}|D ]L}| jd|  }|d d	… d
kr’t|ƒ}n|dkr¢t|ƒ}t	| | 
¡ |ƒ qf| jdkrÂdnd| _|  ¡ | _|  ¡ | _| j ¡ D ]:}|d �rd| j|d  d< |d ræd| j|d  d< qæ| j| j| j| jdœ| _| j�sN| j| jd< dd„ | j ¡ D ƒ| _| j| jdœ| _| j�sˆ| j| jd< dd„ | j ¡ D ƒ| _d S )NÚacq_parszNo acquisition parametersZ
ERFversionFZ	ERFncategTú#Cannot parse acquisition parametersrÒ   rC   )ÚmagZmegÚeegÚeogÚecg)rÓ   rÔ   Ú1ZInternalZExternalr<   Úin_useÚreqevent)ÚgradrÞ   rß   rà   rÝ   c                 S   s&   i | ]\}}t |ƒd kr|t |ƒ“qS ©r   ©rÇ   rP   r,   r,   r-   rM      s    ÿ z)AcqParserFIF.__init__.<locals>.<dictcomp>)rä   rÞ   c                 S   s&   i | ]\}}t |ƒd kr|t |ƒ“qS rå   ræ   rP   r,   r,   r-   rM   %  s    ÿ )rS   ÚdictÚ_acqpars_genÚacq_dictÚcompatÚ_dacq_vars_compatÚ
_dacq_varsrÇ   r1   Úsetattrr=   Z
stimsourceÚ_events_from_acq_parsÚ_eventsÚ_categories_from_acq_parsÚ_categoriesÚvaluesZmegmaxZeegmaxZeogmaxZecgmaxZrejectZmagmaxÚitemsZmegminZeegminZflatZmagmin)Úselfrš   rÛ   Z	dacq_varsÚvarÚvalÚcatr,   r,   r-   Ú__init__ü  sJ    


ÿ


 ÿzAcqParserFIF.__init__c                 C   sŠ   d}|d| j  7 }t| jƒ}|d| 7 }|d| j 7 }t| jƒ}|d| 7 }| jr~|d7 }| jD ]}|d|d |d	 f 7 }q`|d
7 }|S )Nz<AcqParserFIF | zcategories: %d z(%d in use), zevents: %d z(%d in use)z
Averaging categories:z	
%d: "%s"ÚindexÚcommentú>)rÓ   r   Ú_categories_in_userÔ   Ú_events_in_useÚ
categories)rô   rE   Zcats_in_useZ
evs_in_user÷   r,   r,   r-   Ú__repr__(  s    


zAcqParserFIF.__repr__c                 C   sl   t |tƒr|g}nt|tddƒ tƒ }|D ](}|| jkrJ| | j| ¡ q*tdƒ‚q*t|ƒdkrh|d S |S )aµ  Return an averaging category, or list of categories.

        Parameters
        ----------
        item : str | list of str
            Name of the category (comment field in DACQ).

        Returns
        -------
        conds : dict | list of dict
            Each dict should have the following keys:

            comment: str
                The comment field in DACQ.
            state : bool
                Whether the category was marked enabled in DACQ.
            index : int
                The index of the category in DACQ. Indices start from 1.
            event : int
                DACQ index of the reference event (trigger event, zero time for
                the corresponding epochs). Note that the event indices start
                from 1.
            start : float
                Start time of epoch relative to the reference event.
            end : float
                End time of epoch relative to the reference event.
            reqevent : int
                Index of the required (conditional) event.
            reqwhen : int
                Whether the required event is required before (1) or after (2)
                the reference event.
            reqwithin : float
                The time range within which the required event must occur,
                before or after the reference event.
            display : bool
                Whether the category was displayed online in DACQ.
            nave : int
                Desired number of averages. DACQ stops collecting averages once
                this number is reached.
            subave : int
                Whether to compute normal and alternating subaverages, and
                how many epochs to include. See the Elekta data acquisition
                manual for details. Currently the class does not offer any
                facility for computing subaverages, but it can be done manually
                by the user after collecting the epochs.

        ZKeyszcategory nameszNo such categoryr   r   )r   Ústrr	   r   rñ   r4   ÚKeyErrorr   )rô   ÚitemÚcatsÚitr,   r,   r-   Ú__getitem__7  s    0


zAcqParserFIF.__getitem__c                 C   s
   t | jƒS )z Return number of averaging categories marked active in DACQ.

        Returns
        -------
        n_cat : int
            The number of categories.
        )r   rþ   ©rô   r,   r,   r-   Ú__len__s  s    zAcqParserFIF.__len__c                 C   s  ddddddddd	d
ddddddddœ}t ƒ }td| jd ƒD ]Ì}t|ƒ d¡}t ƒ }| jrb| jn| j}|D ]T}d| | }| ¡ }	| j	| }
|	dkr t
|
ƒ}
n|	dkr°t|
ƒ}
|
||	< d|d< ql||d< | j�rt|ƒ|d< d|d< d|d< d|d< || |d< |||< q>|S ) zÐCollect DACQ events into a dict.

        Events are keyed by number starting from 1 (DACQ index of event).
        Each event is itself represented by a dict containing the event
        parameters.
        r   r   rp   é   é   é    rC   é   é   é   é	   é
   é   é   é   é   é   )r   r   rC   rp   r  r  r  r  r  r  r  r  r  r  r  r	  é   ZERFevent)ÚnewbitsÚoldbitsÚnewmaskÚoldmask)ÚdelayFrâ   rù   Únameé?   r  r  r   r  r  )rç   ÚrangerÔ   r   Úzfillrê   Ú_event_vars_compatÚ_event_varsr=   ré   r1   rÇ   )rô   Z_compat_event_lookupr&   ZevnumZevnum_sZevdiZ
event_varsrõ   Úacq_keyZdict_keyrö   r,   r,   r-   rî   }  sL            þÿ



z"AcqParserFIF._events_from_acq_parsc                 #   sf   d\}}|  ¡ D ]P‰ t‡ fdd„| jD ƒƒr6ˆ }d}n |sBtdƒ‚||rPdˆ  nˆ 7 }||fV  qdS )z1Yield key/value pairs from ``info['acq_pars'])``.)Ú r"  c                    s   g | ]}ˆ   |¡‘qS r,   )Ú
startswith©rD   Úx©Úliner,   r-   rF   ©  s     z-AcqParserFIF._acqpars_gen.<locals>.<listcomp>r"  rÜ   ú N)rH   r3   Ú_acq_var_magicrS   )rô   rÛ   Úkeyrö   r,   r&  r-   rè   ¥  s    zAcqParserFIF._acqpars_genc           	      C   sÎ   t ƒ }dd„ td| jd ƒD ƒD ]¨}t ƒ }| jD ]*}d| | }| ¡ }| j| }|||< q0|d dk|d< |d dk|d< dD ]}t|| ƒ||< q€d	D ]}t|| ƒ||< qšt|ƒ|d
< |||d < q |S )zÊCollect DACQ averaging categories into a dict.

        Categories are keyed by the comment field in DACQ. Each category is
        itself represented a dict containing the category parameters.
        c                 S   s   g | ]}t |ƒ d ¡‘qS rO   )r   r  r$  r,   r,   r-   rF   º  s     z:AcqParserFIF._categories_from_acq_pars.<locals>.<listcomp>r   ZERFcatÚdisplayrá   Ústate)rÊ   ÚendÚ	reqwithin)Znaver<   rã   ÚreqwhenZsubaverù   rú   )rç   r  rÔ   Ú	_cat_varsr=   ré   rÇ   r1   )	rô   r  ZcatnumZcatdirõ   r!  Z	class_keyrö   r*  r,   r,   r-   rð   ³  s"    


z&AcqParserFIF._categories_from_acq_parsc                 C   s®   |  ¡ }d|dd…dd…f< | j ¡ D ]‚\}}|d r&t |d |dd…df ¡|d k}t |d |dd…d	f ¡|d
 k}t ||@ ¡}||d	f  d|d > O  < q&|S )aç  Create list of DACQ events based on mne trigger transitions list.

        mne_events is typically given by mne.find_events (use consecutive=True
        to get all transitions). Output consists of rows in the form
        [t, 0, event_codes] where t is time in samples and event_codes is all
        DACQ events compatible with the transition, bitwise ORed together:
        e.g. [t1, 0, 5] means that events 1 and 3 occurred at time t1,
        as 2**(1 - 1) + 2**(3 - 1) = 5.
        r   Nr   rC   râ   r  r  r  r   r  )r$   rï   ró   r   r·   rŠ   )rô   Ú
mne_eventsZevents_rÎ   ÚevZpre_okZpost_okZok_indr,   r,   r-   Ú_events_mne_to_dacqÎ  s&    

ÿÿÿ
ÿÿÿz AcqParserFIF._events_mne_to_dacqc                 C   sX  |d }|d }|   |¡}|dd…df }t |dd…df d|d > @ ¡d }|| }	|�r4t |dd…df d|d > @ ¡d }
||
 }dd|d  |d	  g}t t t|ƒ¡| ¡}|	dd…df | }tj|jtd
�}|D ]8}t 	||dd…df k||dd…df k¡}||O }qä|t |¡ }|| }	|	t
t | j| d | ¡ƒ7 }	|	S )a!  Translate mne_events to epoch zero times (t0).

        First mne events (trigger transitions) are converted into DACQ events.
        Then the zero times for the epochs are obtained by considering the
        reference and conditional (required) events and the delay to stimulus.
        r<   rã   Nr   r   r   rB   r/  r.  r   r  )r3  r   rŠ   rÉ   r6   Úsortedr   rX   r    r#   r1   rï   )rô   r÷   r1  r8   Zcat_evZ	cat_reqevr&   rÈ   ZrefEvents_indsZrefEvents_tZreqEvents_indsZreqEvents_tZtwinÚwinZrefEvents_winsZreq_accÚtZreqEvent_in_winr,   r,   r-   Ú_mne_events_to_category_t0æ  s6    
&
ÿÿ ÿ
 z'AcqParserFIF._mne_events_to_category_t0c                 C   s   t | j ¡ dd„ d�}|S )z{Return list of averaging categories ordered by DACQ index.

        Only returns categories marked active in DACQ.
        c                 S   s   | d S ©Nrù   r,   )r÷   r,   r,   r-   Ú<lambda>  ó    z)AcqParserFIF.categories.<locals>.<lambda>©r*  )r4  rü   rò   )rô   r  r,   r,   r-   rþ     s    
ÿzAcqParserFIF.categoriesc                 C   s   t | j ¡ dd„ d�}|S )zwReturn events ordered by DACQ index.

        Only returns events that are in use (referred to by a category).
        c                 S   s   | d S r8  r,   )r2  r,   r,   r-   r9    r:  z%AcqParserFIF.events.<locals>.<lambda>r;  )r4  rý   rò   )rô   Zevsr,   r,   r-   r&     s    zAcqParserFIF.eventsc                 C   s   dd„ | j  ¡ D ƒS )Nc                 S   s   i | ]\}}|d  r||“qS )r,  r,   rP   r,   r,   r-   rM   "  s       z3AcqParserFIF._categories_in_use.<locals>.<dictcomp>)rñ   ró   r  r,   r,   r-   rü      s    zAcqParserFIF._categories_in_usec                 C   s   dd„ | j  ¡ D ƒS )Nc                 S   s   i | ]\}}|d  r||“qS )râ   r,   rP   r,   r,   r-   rM   &  s       z/AcqParserFIF._events_in_use.<locals>.<dictcomp>)rï   ró   r  r,   r,   r-   rý   $  s    zAcqParserFIF._events_in_useNrd   Tc                 C   s`  |dkr| j }t|tƒs|g}tƒ }|D �]}	t|	tƒr@| |	 }	t||||d|dddd�	}
|rÄt t |
dd…df ¡dk¡d }dt |¡kr˜tdƒ‚|
|d d	f |
|d	f< tj	|
|d dd
�}
|j
d }|  |	|
|¡}tj|t |j¡|	d t |j¡ f  tj¡}|	d |	d i}|	d |	d  }}| t||||d�¡ q(t|ƒdk�r\|d S |S )aJ  Get averaging parameters for a condition (averaging category).

        Output is designed to be used with the Epochs class to extract the
        corresponding epochs.

        Parameters
        ----------
        raw : Raw object
            An instance of Raw.
        condition : None | str | dict | list of dict
            Condition or a list of conditions. Conditions can be strings
            (DACQ comment field, e.g. 'Auditory left') or category dicts
            (e.g. acqp['Auditory left'], where acqp is an instance of
            AcqParserFIF). If None, get all conditions marked active in
            DACQ.
        stim_channel : None | str | list of str
            Name of the stim channel or all the stim channels
            affected by the trigger. If None, the config variables
            'MNE_STIM_CHANNEL', 'MNE_STIM_CHANNEL_1', 'MNE_STIM_CHANNEL_2',
            etc. are read. If these are not found, it will fall back to
            'STI101' or 'STI 014' if present, then fall back to the first
            channel of type 'stim', if present.
        mask : int | None
            The value of the digital mask to apply to the stim channel values.
            If None (default), no masking is performed.
        uint_cast : bool
            If True (default False), do a cast to ``uint16`` on the channel
            data. This can be used to fix a bug with STI101 and STI014 in
            Neuromag acquisition setups that use channel STI016 (channel 16
            turns data into e.g. -32768), similar to ``mne_fix_stim14 --32``
            in MNE-C.
        mask_type : 'and' | 'not_and'
            The type of operation between the mask and the trigger.
            Choose 'and' for MNE-C masking behavior.
        delayed_lookup : bool
            If True, use the 'delayed lookup' procedure implemented in Elekta
            software. When a trigger transition occurs, the lookup of
            the new trigger value will not happen immediately at the following
            sample, but with a 1-sample delay. This allows a slight
            asynchrony between trigger onsets, when they are intended to be
            synchronous. If you have accurate hardware and want to detect
            transitions with a resolution of one sample, use
            delayed_lookup=False.

        Returns
        -------
        conds_data : dict or list of dict
            Each dict has the following keys:

            events : array, shape (n_epochs_out, 3)
                List of zero time points (t0) for the epochs matching the
                condition. Use as the ``events`` parameter to Epochs. Note
                that these are not (necessarily) actual events.
            event_id : dict
                Name of condition and index compatible with ``events``.
                Should be passed as the ``event_id`` parameter to Epochs.
            tmin : float
                Epoch starting time relative to t0. Use as the ``tmin``
                parameter to Epochs.
            tmax : float
                Epoch ending time relative to t0. Use as the ``tmax``
                parameter to Epochs.
        Nr)   TFr   )r�   r*   rx   r¦   r©   r§   r   rµ   r   z¸There are several subsequent transitions on the trigger channel. This will not work well with delayed_lookup=True. You may want to check your trigger data and set delayed_lookup=False.r   r†   r8   rù   rú   rÊ   r-  )r&   r`   r9   r:   )rþ   r   r   r   r¶   r   rŠ   r‰   rS   r¤   rš   r7  r�   r   rX   r"   r2   Zuint32r4   rç   r   )rô   rœ   Ú	conditionr�   r*   r©   rx   Zdelayed_lookupZ
conds_datar÷   r1  Úindr8   Zcat_t0_Zcat_t0Zcat_idr9   r:   r,   r,   r-   Úget_condition(  sH    A


   ý$
ÿþ
 ÿ
zAcqParserFIF.get_condition)NNNNrd   T)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)  rë   r  r0  rì   r   rø   rÿ   r  r  rî   rè   rð   r3  r7  Úpropertyrþ   r&   rü   rý   r>  r,   r,   r,   r-   rÑ   ¾  s:   &,<
('
	


      ÿrÑ   Úraise)Ú
on_missingc                   sÂ   t |ƒ t| tƒrt| ƒ} t|ttjfƒr>t|tƒs>t|ƒ}n|g}g }|D ]@‰ tˆ tƒsttdt	ˆ ƒ› dˆ › d�ƒ‚| 
‡ fdd„| D ƒ¡ qL|s²t|dˆ › dd | ¡› �td	� tt|ƒƒ}|S )
aÉ  Search a collection of event names for matching (sub-)groups of events.

    This function is particularly helpful when using grouped event names
    (i.e., event names containing forward slashes ``/``). Please see the
    Examples section below for a working example.

    Parameters
    ----------
    event_names : array-like of str | dict
        Either a collection of event names, or the ``event_id`` dictionary
        mapping event names to event codes.
    keys : array-like of str | str
        One or multiple event names or groups to search for in ``event_names``.
    on_missing : 'raise' | 'warn' | 'ignore'
        How to handle situations when none of the ``keys`` can be found in
        ``event_names``. If ``'warn'`` or ``'ignore'``, an empty list will be
        returned.

    Returns
    -------
    matches : list of str
        All event names that match any of the ``keys`` provided.

    Notes
    -----
    .. versionadded:: 1.0

    Examples
    --------
    Assuming the following grouped event names in the data, you could easily
    query for all ``auditory`` and ``left`` event names::

        >>> event_names = [
        ...     'auditory/left',
        ...     'auditory/right',
        ...     'visual/left',
        ...     'visual/right'
        ... ]
        >>> match_event_names(
        ...     event_names=event_names,
        ...     keys=['auditory', 'left']
        ... )
        ['auditory/left', 'auditory/right', 'visual/left']
    zkeys must be strings, got z (ú)c                 3   s,   | ]$}t ˆ  d ¡ƒ | d ¡¡r|V  qdS )ú/N)ÚsetrH   Úissubset)rD   r  r;  r,   r-   Ú	<genexpr>Ï  s   ÿz$match_event_names.<locals>.<genexpr>zEvent name "zD" could not be found. The following events are present in the data: z, )rE  ÚmsgZerror_klass)r   r   rç   r   r   r   Zndarrayr   rS   ÚtypeÚextendr   Újoinr  r4  rH  )Zevent_namesÚkeysrE  Úmatchesr,   r;  r-   Úmatch_event_names�  s0    -
ÿþ

ÿ
ürQ  )NNF)NN)NNNrd   FN)NNr   )NNr   N)Nr    r¡   r   NFrd   F)
Nr    r¡   r   r   NFrd   FN)T)r   r   NrÀ   TrÁ   )5rB  Úos.pathÚpathrq   Úcollections.abcr   Únumpyr   Úutilsr   r   r   r   r   r	   r
   r   r   r   r   Zio.constantsr   Zio.treer   Zio.tagr   Zio.openr   Zio.writer   r   r   r   Zio.pickr   r.   r@   rc   r~   r…   r–   rŸ   r­   r±   r¶   ru   r½   r¿   rÍ   rÐ   ÚobjectrÑ   rQ  r,   r,   r,   r-   Ú<module>   s„   	44   ÿ
I*      ÿm%
-  ÿ
6           þS              ý D
=
    ÿC.   Q