spike.Interactive package — spike 0.99.23 documentation

# spike.Interactive package

## Submodules

## spike.Interactive.FTICR_INTER module

A tool to display 2D FT-ICR data-sets

to be embedded in jupyter notebook

class `spike.Interactive.FTICR_INTER.` `Calib`(data)

  Bases: `object`

  a simple tool to show and modify calibration cste

  `back`(event)
  `setref`(e=None)
  `update`(event)

class `spike.Interactive.FTICR_INTER.` `MR`(name, report=True, Debug=False)

  Bases: `object`

  this class handles multiresolution datasets

  `col`(i)

    return a column with coordinate in index

  `colmz`(i)

    return a column with coordinate in m/z

  `compute_absmax`()

    computes largest point from smaller resolution, and propagates

  `load`()

    load from file

  `report`()

    report object content

  `row`(i)

    return a row with coordinate in index

  `rowmz`(i)

    return a row with coordinate in m/z

  `to_display`(zoom=0, 10000000.0, 0, 10000000.0, verbose=False)

    computes and return which dataset to display at a given zoom and scale level” in: zoom = ((F1low, F1up), (F2low,F2up)) - in m/z

    out: a tuple (data, zoomwindow), where data is a NPKData and zoomwindow an eventually recalibrated zoom window

    so, if DATA is an MR() object and Zoom a defined window in m/z ((F1low, F1up), (F2low,F2up)) the sequence:

    > datasel, zz = DATA.to_display(Zoom) datasel.display(zoom=zz, scale=…)

    will display the selected zone with the best possible resolution

class `spike.Interactive.FTICR_INTER.` `MR_interact`(name, figsize=None, report=True, show=True, Debug=False)

  Bases: `spike.Interactive.FTICR_INTER.MR`

  `I1D`()

    show the 1D selector

  `back`(*arg)
  `bb`(name, desc, action, layout=None, tooltip='')

    build button

  `check_fig`()
  `check_fig1D`()
  `display`(zoom=None, scale=None, redraw=None)
  `display1D`()

    display the selected 1D

  `down`(b, factor=1.44)
  `ext_box`()

    defines the interactive tools for 1D

  `forw`(*arg)
  `fullzoom`()
  `left`(b, factor=1.44)
  `reset`(b)
  `reset_track`()
  `right`(b, factor=1.44)
  `scale1`(b)
  `scaledown`(b)
  `scaleup`(b)
  `show`()

    actually show the graphical tool and the interactive spectrum

  `up`(b, factor=1.44)
  `update`()
  property `zoom`
  `zoom_box`()
  `zoom_in`(b, factor=1.44)
    z_in: waft = wbef/factor => waft*factor = wbef

      dw = wbef/factor-wbef = wbef*(1-factor) dw = waft*factor*(1-factor)

  `zoom_out`(b, factor=1.44)

    z_in: dw = waft*factor*(1-factor) z_out:dw = wbef*(factor*(1-factor))

  `zoomwidth`()

class `spike.Interactive.FTICR_INTER.` `MSPeaker`(npkd, pkname)

  Bases: `object`

  a peak-picker for MS experiments

  `display`(event={'name': 'value'})

    display spectrum and peaks

  `done`(event)

    exit GUI

  `pickpeak`(event)

    interactive wrapper to peakpick

  `pkexport`(event)

    exports the peaklist to file

  `pklist`()

    creates peaklist

  `pkprint`(event)
  `pp`()

    do the peak-picking calling pp().centroid()

  `resetzoom`(b)

class `spike.Interactive.FTICR_INTER.` `Show1D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  `on_reset`(b=None)

class `spike.Interactive.FTICR_INTER.` `SpforSuper`(i, name)

  Bases: `object`

  a holder for SuperImpose

  `display`()

class `spike.Interactive.FTICR_INTER.` `SuperImpose`(base=None, filetype='*.msh5', N=None)

  Bases: `object`

  a tool to superimpose spectra

  `Show`()
  `copy`(event)
  `display`(event)

## spike.Interactive.FTICR_INTER_v2 module

A tool to display FT-ICR data-sets

to be embedded in jupyter notebook

MAD Sept 2019

This version requires ipympl (see: https://github.com/matplotlib/jupyter-matplotlib ) and the notebook to be opened with %matplotlib widget

class `spike.Interactive.FTICR_INTER_v2.` `Calib`(data)

  Bases: `object`

  a simple tool to show and modify calibration cste

  `back`(event)
  `update`(event)

class `spike.Interactive.FTICR_INTER_v2.` `MR`(name, report=True, Debug=False)

  Bases: `object`

  this class handles multiresolution datasets

  `col`(i)

    return a column with coordinate in index

  `colmz`(i)

    return a column with coordinate in m/z

  `compute_absmax`()

    computes largest point from smaller resolution, and propagates

  `load`()

    load from file

  `report`()

    report object content

  `row`(i)

    return a row with coordinate in index

  `rowmz`(i)

    return a row with coordinate in m/z

  `to_display`(zoom=0, 10000000.0, 0, 10000000.0, verbose=False)

    computes and return which dataset to display at a given zoom and scale level” in: zoom = ((F1low, F1up), (F2low,F2up)) - in m/z

    out: a tuple (data, zoomwindow), where data is a NPKData and zoomwindow an eventually recalibrated zoom window

    so, if DATA is an MR() object and Zoom a defined window in m/z ((F1low, F1up), (F2low,F2up)) the sequence:

    > datasel, zz = DATA.to_display(Zoom) datasel.display(zoom=zz, scale=…)

    will display the selected zone with the best possible resolution

class `spike.Interactive.FTICR_INTER_v2.` `MR_interact`(name, figsize=None, report=True, show=True, Debug=False)

  Bases: `spike.Interactive.FTICR_INTER_v2.MR`

  `I1D`()

    show the 1D selector

  `bb`(name, desc, action, layout=None, tooltip='')

    build a button into self

  `check_fig`()

    create figure if missing

  `check_fig1D`()
  `display`(zoom=None, scale=None)

    computes pictures (display in the SPIKE sense - not ipywidget one)

  `display1D`()

    display the selected 1D

  `ext_box`()

    defines the interactive tools for 1D

  `fullzoom`()
  `ob`(event)

    observe events and display

  `reset`(b)
  `reset_track`()
  `scale_up`(step)
  `set_on_redraw`()
  `show`()

    actually show the graphical tool and the interactive spectrum

  `spec_box`()

    defines the spectral box widget

  `update`(e)

    update internal zoom coordinates

  `zoom_box`()

    defines the zoom box widget

class `spike.Interactive.FTICR_INTER_v2.` `MS2Dscene`(**kwargs)

  Bases: `ipywidgets.widgets.widget_box.HBox`

  a widget to set all MS tools into one screen

  `load2D`(e)

    create 2D object and display

class `spike.Interactive.FTICR_INTER_v2.` `MSPeaker`(npkd, pkname)

  Bases: `object`

  a peak-picker for MS experiments

  `display`(event={'name': 'value'})

    display spectrum and peaks

  `done`(event)

    exit GUI

  `pickpeak`(event)

    interactive wrapper to peakpick

  `pkexport`(event)

    exports the peaklist to file

  `pklist`()

    creates peaklist

  `pkprint`(event)
  `pp`()

    do the peak-picking calling pp().centroid()

class `spike.Interactive.FTICR_INTER_v2.` `SpforSuper`(i, name)

  Bases: `object`

  a holder for SuperImpose

  `display`()

class `spike.Interactive.FTICR_INTER_v2.` `SuperImpose`(base=None, filetype='*.msh5', N=None)

  Bases: `object`

  a tool to superimpose spectra

  `Show`()
  `copy`(event)
  `display`(event)

## spike.Interactive.INTER copy module

## spike.Interactive.INTER module

A set of utilities to use spike in NMR or FTMS within jupyter

First version MAD june 2017 Intermediate version MAD october 2019 Improvements MAD spring - summer - automn 2021 - winter 2022

class `spike.Interactive.INTER.` `AvProc1D`(filename='')

  Bases: `object`

  Detailed 1D NMR Processing

  `apmin_select`(e)
  `apod`()
  `apod_select`(e)
  `display`()
  `load`()
  `process`(e)
  `show`()
  `show_apod`(e)

`spike.Interactive.INTER.` `Logo`(width=150)

  display the Logo

`spike.Interactive.INTER.` `Logofile`()

  return the address on disk of the Logo file

class `spike.Interactive.INTER.` `NMRIntegrate`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  an integrator for NMR experiments

  `disp`()
  `draw`()

    refresh display from event - if zoom is True, display only in xbound

  `int`()

    do the automatic integration from peaks and parameters

  `integrate`(event)
  `ob`(event)

    observe events and redraw

  `on_add`(b)
  `on_cancel`(b)
  `on_done`(b)
  `on_rem`(b)
  `peak_and_integrate`(event)
  `print`(event)
  `set_value`(b)

class `spike.Interactive.INTER.` `NMRPeaker1D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  a peak-picker for NMR experiments

  `disp`()
  `draw`()

    interactive wrapper to peakpick

  `ob`(event)

    observe events and redraw

  `on_add`(b)
  `on_cancel`(b)
  `on_done`(b)
  `on_rem`(b)
  `on_reset`(b=None)
  `on_setcalib`(e)
  `pickpeak`(event)

    interactive wrapper to pp

  `pklist`()

    creates peaklist for printing or exporting

  `pkprint`(event)
  `pp`(**kwargs)

class `spike.Interactive.INTER.` `Phaser1D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  An interactive phaser in 1D NMR

  > Phaser1D(spectrum, …)

  `ctopivot`(p0, p1)

    convert from centered to pivot values

  `disconnect_press`()

    should be called before close()

  `disp`()

    update display and display pivot

  `draw`()

    copied from super() as it does not display the spectrum !

  `ob`(event)

    observe changes and start phasing

  `on_Apply`(b)
  `on_cancel`(b)
  `on_movepivot`(event)
  `phase`()
  `phase_n_disp`()

    apply phase and disp

  `ppivot`()

    converts from pivot values to centered ones

  `rescale_p1`(**kwargs)

class `spike.Interactive.INTER.` `Show1D`(**kwargs)

  Bases: `ipywidgets.widgets.widget_box.HBox`

  An interactive display, 1D NMR

    Show1D(spectrum)

  `disp`()
  `draw`()

    builds and display the picture

  `ob`(event)

    observe events and redraw

  `obdisp`(event)

    observe events and display

  `on_done`(b)
  `on_reset`(b=None)
  `scale_up`(**kwargs)
  `set_on_redraw`()

    set-up mouse scroll control and click

class `spike.Interactive.INTER.` `Show1Dplus`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  `copy`(event)
  `draw`(zoom=False)

    refresh display - if zoom is True, display only in xbound

  `on_done`(e)

class `spike.Interactive.INTER.` `SpforSuper`(i, filename='None', axref=False, ref=None)

  Bases: `object`

  a holder for one spectrum to SuperImpose

  `B`(text, size='auto')

    bold HTML widget

  `I`(text, size='auto')

    Italic HTML widget

  `activate`(e)

    called when state changes

  `disp`()

    refresh

  `draw`(unit='ppm')
  `injectobserve`(method)

    used to to observe form outer object for draw

  `move_xdata`()

    adapt self.xdata to offset and stretching, then return the value

  `move_ydata`()

    adapt self.ydata to direct, scale, and offset and return the value

  property `mult`
  `nactivate`(e)

    called to check name validity, when name is entered

  property `nmrname`
  `ob`(event)

    observe events and display

  `simpledisplay`()

    a simplified widget

class `spike.Interactive.INTER.` `Timer`(timeout, callback)

  Bases: `object`

  `cancel`()
  `start`()

`spike.Interactive.INTER.` `UserLogofile`()

  return the address on disk of the User Logo file - located in $HOME/Spike/Logo.png

class `spike.Interactive.INTER.` `baseline1D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  An interactive baseline for 1D NMR

  > baseline1D(spectrum, …)

  `clear`()

    remove artists created by draw()

  `corrected`()
  `correction`()

    returns the correction to apply as a numpy array

  `disconnect_press`()

    should be called before close()

  `disp`()

    used to refresh view

  `draw`()

    used to create the view with additional artists

  `itoc3`(value)
  `on_auto`(e)

    automatically set baseline points

  `on_cancel`(e)
  `on_done`(e)
  `on_set`(e)

    add baseline points at selector

  `on_unset`(e)

    remove baseline points closest from selector

`spike.Interactive.INTER.` `debounce`(wait)

  Decorator that will postpone a function’s execution until after wait seconds have elapsed since the last time it was invoked.

`spike.Interactive.INTER.` `hidecode`(initial='show', message='<i>useful to show/print a clean screen when processing is finished</i>')

  this func adds a button to hide/show the code on a jupyter page initial is either ‘show’ or ‘hide’ inspired from: https://stackoverflow.com/questions/27934885/how-to-hide-code-from-cells-in-ipython-notebook-visualized-with-nbviewer/28073228#28073228

`spike.Interactive.INTER.` `hidedoc`(initial='show', message='<i>useful to show/print a clean screen when processing is finished</i>')

  this func adds a button to hide/show the doc on a jupyter page initial is either ‘show’ or ‘hide’ inspired from: https://stackoverflow.com/questions/27934885/how-to-hide-code-from-cells-in-ipython-notebook-visualized-with-nbviewer/28073228#28073228

`spike.Interactive.INTER.` `initCSS`()

  adapt some CSS

`spike.Interactive.INTER.` `initialize`(verb=1)

  initialize notebook interface for Spike

`spike.Interactive.INTER.` `jsalert`(msg='Alert text')

  send a javascript alert

`spike.Interactive.INTER.` `param_line`(acqus, paramlist=None, output='string')

  given a acqus dictionary, and a list of parameters to extract, this functions return either a plain text or a HTML table depending on output value either “string” or “HTML” )

`spike.Interactive.INTER.` `param_table`(data, output='string')

  return the complete parameter table held into data output is either “string” or “HTML

`spike.Interactive.INTER.` `popup_param_table`(data)

`spike.Interactive.INTER.` `readplist`(paramtoadd, paramdict)

  parse lists from acqus files - only that ones defined in arraynames

`spike.Interactive.INTER.` `space`(width='80px')

  defines a layout of width, width should be a string in CSS syntax

`spike.Interactive.INTER.` `spacer`(width='80px')

  defines a spacer to be used in widgets.Box - width should be a string in CSS syntax

`spike.Interactive.INTER.` `summary`(data, param=True, output='string')

  produces a summary of the data set if param is True, a short list of 1D parameters is given, using the globally defined Paramlist output is either “string” or “HTML”

## spike.Interactive.INTER_2D module

A set of utilities to use spike in NMR or FTMS within jupyter

First version MAD june 2017 definitive ? version MAD october 2019

class `spike.Interactive.INTER_2D.` `Phaser2D`(**kwargs)

  Bases: `spike.Interactive.INTER_2D.Show2D`

  An interactive phaser in 2D NMR

  > Phaser2D(spec)

  `ctopivot`(F1p0, F1p1, F2p0, F2p1)

    convert from centered to pivot values

  `draw`(todisplay=None, new=True)

    display either the current data or the one provided - red and blue

  `ob`(event)

    observe changes and start phasing

  `on_Apply`(b)
  `on_cancel`(b)
  `on_movepivot`(event)
  `phase`()

    compute phase and display

  `phdisp`(todisplay=None)

    display either the current data or the one provided - red and blue

  `ppivot`()

    converts from pivot values to centered ones

class `spike.Interactive.INTER_2D.` `Show2D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  A display for 2D NMR with a scale cursor Show2D(spectrum) where spectrum is a NPKData object - special display for DOSY.

  `disp`(**kwargs)
  `draw`(**kwargs)

    builds and display the picture

  `on_reset`(e=None)

class `spike.Interactive.INTER_2D.` `baseline2D_F2`(**kwargs)

  Bases: `spike.Interactive.INTER.baseline1D`

  `on_done`(e)

`spike.Interactive.INTER_2D.` `sidedisplay`(dt1d, ax)

## spike.Interactive.INTER_MS (copy) module

## spike.Interactive.INTER_MS module

## spike.Interactive.INTER_MS_turn module

A set of utilities to use spike in NMR or FTMS within jupyter

First version MAD june 2017 definitive ? version MAD october 2019

class `spike.Interactive.INTER_MS_turn.` `FloatButt`(**kwargs)

  Bases: `ipywidgets.widgets.widget_box.HBox`

  a float text with buttons rounds is a list on power of 10 to set

  `decrem`(e)
  `increm`(e)
  property `value`

class `spike.Interactive.INTER_MS_turn.` `Phaser1D`(**kwargs)

  Bases: `spike.Interactive.INTER.Show1D`

  An interactive phaser in 1D MS

  > Phaser1D(spectrum)

  requires %matplotlib widget

  `ctopivot`(p0, p1, p2, pv)

    convert from centered to pivot values - not used in PHASEQUAD

  `ob`(event)

    observe changes and start phasing

  `on_Apply`(b)
  `on_addlist`(b)
  `on_cancel`(b)
  `on_clearlist`(b)
  `on_movepivot`(event)
  `on_printlist`(b)
  `phase`()

    apply phase and display

  `ppivot`()

    converts current pivot values to centered ones - not used in PHASEQUAD

  `show`()

## spike.Interactive.ipyfilechooser module

class `spike.Interactive.ipyfilechooser.` `FileChooser`(**kwargs)

  Bases: `ipywidgets.widgets.widget_box.VBox`

  # FileChooser code is from # https://github.com/crahan/ipyfilechooser

  property `default`

    Get the default value

  property `default_filename`

    Get the default_filename value

  property `default_path`

    Get the default_path value

  property `nmrname`
  `refresh`()

    Re-render the form

  `reset`(path=None, filename=None)

    Reset the form to the default path and filename

  property `rows`

    Get current number of rows

  property `selected`

    Get selected value

  property `selected_filename`

    Get the selected_filename

  property `selected_path`

    Get selected_path value

  property `show_hidden`

    Get current number of rows

`spike.Interactive.ipyfilechooser.` `get_dir_contents`(path, hidden=False)

  Get directory contents

`spike.Interactive.ipyfilechooser.` `get_subpaths`(path)

  Walk a path and return a list of subpaths

`spike.Interactive.ipyfilechooser.` `has_parent`(path)

  Check if a path has a parent folder

`spike.Interactive.ipyfilechooser.` `update_path`(path, item)

  Update path with new item

## Module contents