spike.Interactive package — spike 0.99.20-480 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

First version MAD jan 2019 preliminary and not fully tested !

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

  Bases: `object`

  a simple tool to show and modify calibration cste

  `back`(event)
  `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()

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`(show=True, root='/')

  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 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.` `AvProc1D`(filename='')

  Bases: `object`

  Detailed 1D NMR Processing

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

class `spike.Interactive.INTER.` `FileChooser`(base=None, filetype=['fid', 'ser'], mode='r', show=True)

  Bases: `object`

  a simple file chooser for Jupyter - obsolete - not used

  property `basename`

    the basename of the chosen file

  `dirlist`()
  property `dirname`

    the final dirname containing the chosen file

  property `file`

    the chosen complete filename

  `filelist`()
  property `nmrname`

    the final dirname containing the chosen file for TopSpin files

  `setdir`(e)
  `show`()
  `updir`(e)
  `wob`(e)

class `spike.Interactive.INTER.` `NMRIntegrate`(data, figsize=None, reverse_scroll=False, show=True)

  Bases: `spike.Interactive.INTER.Show1D`

  an integrator for NMR experiments

  `disp`(zoom=False)

    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 display

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

class `spike.Interactive.INTER.` `NMRPeaker1D`(data, figsize=None, reverse_scroll=False, show=True)

  Bases: `spike.Interactive.INTER.Show1D`

  a peak-picker for NMR experiments

  `disp`()

    interactive wrapper to peakpick

  `ob`(event)

    observe events and display

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

    interactive wrapper to peakpick

  `pklist`()

    creates peaklist for printing or exporting

  `pkprint`(event)
  `pp`()

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

  `show`()

class `spike.Interactive.INTER.` `Phaser1D`(data, figsize=None, title=None, reverse_scroll=False, show=True)

  Bases: `spike.Interactive.INTER.Show1D`

  An interactive phaser in 1D NMR

  > Phaser1D(spectrum)

  requires %matplotlib widget

  `ctopivot`(p0, p1)

    convert from centered to pivot values

  `ob`(event)

    observe changes and start phasing

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

    apply phase and display

  `ppivot`()

    converts from pivot values to centered ones

  `show`()

class `spike.Interactive.INTER.` `Phaser2D`(data)

  Bases: `object`

  An interactive phaser in 2D NMR

  > Phaser2D(spec)

  best when in %matplotlib inline

  `close`()
  `display`(todisplay=None)

    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)
  `phase`()

    compute phase and display

class `spike.Interactive.INTER.` `Show1D`(data, title=None, figsize=None, reverse_scroll=False, show=True)

  Bases: `ipywidgets.widgets.widget_box.HBox`

  An interactive display, 1D NMR

    Show1D(spectrum)

  to be developped for peaks and integrals

  `disp`()
  `ob`(event)

    observe events and display

  `on_done`(b)
  `on_reset`(b)
  `scale_up`(step)
  `set_on_redraw`()

class `spike.Interactive.INTER.` `Show1Dplus`(data, base='/DATA', N=9, figsize=None, title=None, reverse_scroll=False)

  Bases: `spike.Interactive.INTER.Show1D`

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

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

  `on_done`(e)

class `spike.Interactive.INTER.` `Show2D`(data, title=None, figsize=None)

  Bases: `object`

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

  `disp`(new=False)
  `ob`(event)

    observe events and display

  `on_done`(b)

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

  Bases: `object`

  a holder for SuperImpose

  `display`(unit='ppm')

class `spike.Interactive.INTER.` `baseline1D`(data, figsize=None, reverse_scroll=False, show=True)

  Bases: `spike.Interactive.INTER.Show1D`

  `close`()

    close all widget

  `corrected`()
  `correction`()

    returns the correction to apply as a numpy array

  `disp`()

    compute and display the spectrum

  `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

  `selpos`()

    returns selector pos in ppm

  `show`()

    create the widget and display the spectrum

  `smoothed`()

    returns a smoothed version of the data

class `spike.Interactive.INTER.` `baseline2D_F2`(data, figsize=None)

  Bases: `spike.Interactive.INTER.baseline1D`

  `on_done`(e)

`spike.Interactive.INTER.` `hidecode`(initial='show', message=True)

  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.` `jsalert`(msg)

  send a javascript alert

## spike.Interactive.ipyfilechooser module

class `spike.Interactive.ipyfilechooser.` `FileChooser`(path='/home/mad/Documents/spike/spike_make_sphinx', filename='', show_hidden=False, **kwargs)

  Bases: `ipywidgets.widgets.widget_box.VBox`

  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