<commit_before>"""Analysis functions (mostly for psychophysics data).
"""

import numpy as np

from ..visual import FixationDot
from ..analyze import sigmoid
from .._utils import logger, verbose_dec
from ..stimuli import window_edges


def _check_pyeparse():
    """Helper to ensure package is available"""
    try:
        import pyeparse  # noqa analysis:ignore
    except ImportError:
        raise ImportError('Cannot run, requires "pyeparse" package')


def _load_raw(el, fname):
    """Helper to load some pupil data"""
    import pyeparse
    fname = el.transfer_remote_file(fname)
    # Load and parse data
    logger.info('Pupillometry: Parsing local file "{0}"'.format(fname))
    raw = pyeparse.Raw(fname)
    raw.remove_blink_artifacts()
    events = raw.find_events('SYNCTIME', 1)
    return raw, events


@verbose_dec
def find_pupil_dynamic_range(ec, el, prompt=True, verbose=None):
    """Find pupil dynamic range

    Parameters
    ----------<commit_msg>fix: class 'Raw' doesn't work with current pyeparse (#369)<commit_after>"""Analysis functions (mostly for psychophysics data).
"""

import numpy as np

from ..visual import FixationDot
from ..analyze import sigmoid
from .._utils import logger, verbose_dec
from ..stimuli import window_edges


def _check_pyeparse():
    """Helper to ensure package is available"""
    try:
        import pyeparse  # noqa analysis:ignore
    except ImportError:
        raise ImportError('Cannot run, requires "pyeparse" package')


def _load_raw(el, fname):
    """Helper to load some pupil data"""
    import pyeparse
    fname = el.transfer_remote_file(fname)
    # Load and parse data
    logger.info('Pupillometry: Parsing local file "{0}"'.format(fname))
    raw = pyeparse.RawEDF(fname)
    raw.remove_blink_artifacts()
    events = raw.find_events('SYNCTIME', 1)
    return raw, events


@verbose_dec
def find_pupil_dynamic_range(ec, el, prompt=True, verbose=None):
    """Find pupil dynamic range

    Parameters
    ----------
{'fraction_non_alphanumeric': 0.1100502512562814, 'fraction_numerical': 0.0035175879396984926, 'mean_word_length': 3.706855791962175, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6627864', 'n_tokens_mistral': 633, 'n_tokens_neox': 601, 'n_words': 188}