pulse2percept.io.image

Functions

image2stim(img, implant[, coding, valrange, …]) Converts an image into a series of pulse trains
pulse2percept.io.image.image2stim(img, implant, coding='amplitude', valrange=[0, 50], max_contrast=False, const_val=20, invert=False, tsample=5e-06, dur=0.5, pulsedur=0.0005, interphasedur=0.0005, pulsetype='cathodicfirst')[source]

Converts an image into a series of pulse trains

This function creates an input stimulus from an RGB or grayscale image. The image is down-sampled to fit the spatial layout of the implant (currently supported are ArgusI and ArgusII arrays). Requires Scikit-Image.

Parameters:
  • img (str|array_like) – An input image, either a valid filename (string) or a numpy array (row x col x channels).
  • implant (ProsthesisSystem) – An ElectrodeArray object that describes the implant.
  • coding ({'amplitude', 'frequency'}, optional) –

    A string describing the coding scheme:

    • ’amplitude’: Image intensity is linearly converted to a current
      amplitude between valrange[0] and valrange[1]. Frequency is held constant at const_freq.
    • ’frequency’: Image intensity is linearly converted to a pulse
      frequency between valrange[0] and valrange[1]. Amplitude is held constant at const_amp.

    Default: ‘amplitude’

  • valrange (list, optional) – Range of stimulation values to be used (If coding is ‘amplitude’, specifies min and max current; if coding is ‘frequency’, specifies min and max frequency). Default: [0, 50]
  • max_contrast (bool, optional) – Flag wether to maximize image contrast (True) or not (False). Default: False
  • const_val (float, optional) – For frequency coding: The constant amplitude value to be used for all pulse trains. For amplitude coding: The constant frequency value to be used for all pulse trains. Default: 20
  • invert (bool, optional) – Flag whether to invert the grayscale values of the image (True) or not (False). Default: False
  • tsample (float, optional) – Sampling time step (seconds). Default: 0.005 / 1000 seconds.
  • dur (float, optional) – Stimulus duration (seconds). Default: 0.5 seconds.
  • pulsedur (float, optional) – Duration of single (positive or negative) pulse phase in seconds.
  • interphasedur (float, optional) – Duration of inter-phase interval (between positive and negative pulse) in seconds.
  • pulsetype ({'cathodicfirst', 'anodicfirst'}, optional) – A cathodic-first pulse has the negative phase first, whereas an anodic-first pulse has the positive phase first.
Returns:

pulses (list) – A list of p2p.stimuli.PulseTrain objects, one for each electrode in the implant.