{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "# 2D DOSY NMR Processing and Display\n",
    "\n",
    "\n",
    "a simplified environment for processing DOSY experiments from Bruker NMR datasets.\n",
    "The analysis is performed using the PALMA algorithm.\n",
    "\n",
    "## Principle\n",
    "The PALMA algorithm performs the Inverse Laplace Transform of each columns of the 2D DOSY experiment.\n",
    "This inversion is performed by optimizing a target function which maximizes the Entropy of the spectrum, and minimizes its $\\ell_1$ norm.\n",
    "\n",
    "More details are found in the original publication [DOI: 10.1039/c6an01902a](http://doi.org/10.1039/c6an01902a)\n",
    "or the [WEB server page](http://palma.labo.igbmc.fr/about.html) on which you will also find [advises](http://palma.labo.igbmc.fr/about.html) to obtain the best possible experiments. \n",
    "\n",
    "When using this program, please cite the following reference:\n",
    "\n",
    "A.Cherni, É.Chouzenoux, and M.-A.Delsuc. (2017) \"PALMA, an improved algorithm for DOSY signal processing\".\n",
    "*Analyst*, **142**(5), p772-779 \n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Usage\n",
    "Run each python cell in sequence by using the ⇥Run button above (or typing *shift* Enter).\n",
    "\n",
    "Cells are meant to be used in order, taking you to the complete analysis, but you can go back at any time.\n",
    "\n",
    "The SPIKE code used for processing is visible in the cells, and can be used as a minimal tutorial.\n",
    "\n",
    "***Remark*** *to use this program, you should have installed the following packages:*\n",
    "\n",
    "- *a complete scientific python environment* ( *tested with python 3.6 - [anaconda](https://www.anaconda.com/) \n",
    " but it should also work in python 2.7*)\n",
    "- [`spike`](https://www.bitbucket.org/delsuc/spike) ( *version 0.99.9 minimum* )\n",
    "- [`ipywidgets`](https://ipywidgets.readthedocs.io/en/latest/)  ( *tested with version 7.1* )\n",
    "\n",
    "## Initialization\n",
    "the following cell should be run only once, at the beginning of the processing"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-21T09:33:15.801287Z",
     "start_time": "2019-06-21T09:33:10.418883Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/markdown": [
       "## STARTING Environment..."
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "\n",
      "    ========================\n",
      "          SPIKE\n",
      "    ========================\n",
      "    Version     : 0.99.21\n",
      "    Date        : 23-02-2021\n",
      "    Revision Id : 490\n",
      "    ========================\n",
      "*** zoom3D not loaded ***\n",
      "plugins loaded:\n",
      "Fitter,  Linear_prediction,  Peaks,  bcorr,  fastclean,  gaussenh,  rem_ridge,  sane,  sg,  test,  urQRd, \n",
      "\n",
      "spike.plugins.report() for a short description of each plugins\n",
      "spike.plugins.report('module_name') for complete documentation on one plugin\n",
      "*** PALMA not loaded ***\n",
      "plugins loaded:\n",
      "Bruker_NMR_FT,  Bucketing,  Integrate,  apmin, \n"
     ]
    },
    {
     "data": {
      "text/markdown": [
       "## ...program is Ready"
      ],
      "text/plain": [
       "<IPython.core.display.Markdown object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "\n",
       "<script>\n",
       "code_show=false; \n",
       "function code_toggle()\n",
       "    { if (code_show)\n",
       "        { $('div.input').hide(); $('#but').val(\"show python code\");\n",
       "        } else { $('div.input').show(); $('#but').val(\"hide python code\");\n",
       "    }\n",
       "    code_show = !code_show } \n",
       "$(document).ready(code_toggle);\n",
       "</script>\n",
       "<form action=\"javascript:code_toggle()\">\n",
       "<input id=\"but\" type=\"submit\" style=\"border:1px solid black; background-color:#DDD\">\n",
       "<i>usefull to show/print a clean screen when processing is finished</i>\n",
       "</form>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "# load all python and interactive tools\n",
    "from __future__ import print_function, division\n",
    "from importlib import reload\n",
    "from IPython.display import display, HTML, Markdown, Image, Javascript\n",
    "display(Markdown('## STARTING Environment...'))\n",
    "%matplotlib notebook\n",
    "import os.path as op\n",
    "import spike\n",
    "from spike.File.BrukerNMR import Import_2D\n",
    "from spike.plugins.NMR.PALMA import Import_DOSY\n",
    "from spike.Interactive import INTER as I\n",
    "from spike.Interactive.ipyfilechooser import FileChooser\n",
    "display(Markdown('## ...program is Ready'))\n",
    "I.hidecode()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Choose the file\n",
    "The `FileChooser()` tool creates a dialog box which allows to choose a file on your disk\n",
    "\n",
    "- use the `Select` button\n",
    "- modify the ( *optional* ) `path` argument, to start the exploration on a given location\n",
    "- choose the `ser  file of your DOSY experiment\n",
    "    - *note, the* `difflist` *file should be present*\n",
    "- After the selection, the selected filename is found in `FC.selected`"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-21T09:34:50.404908Z",
     "start_time": "2019-06-21T09:34:50.328239Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "8f7e24828b774bc98b4f53d084879fc0",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "FileChooser(path='/home/mad', filename='ser', show_hidden='False')"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "FC = FileChooser(path='/home/mad',filename='ser')\n",
    "display(FC)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Import dataset\n",
    "\n",
    "This is simply done with the `Import_2D()` tool, which returns a `SPIKE` object.\n",
    "\n",
    "We store the dataset into a variable, typing the variable name shows a summary of the dataset. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-21T09:35:09.463624Z",
     "start_time": "2019-06-21T09:35:09.216878Z"
    }
   },
   "outputs": [
    {
     "data": {
      "application/javascript": [
       "alert('No difflist file present - is this a DOSY experiment ?')"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Reading file  /home/mad/Documents/DATA/SM_ARTE_v3/ARTEref_161123/20/ser\n"
     ]
    },
    {
     "ename": "FileNotFoundError",
     "evalue": "[Errno 2] No such file or directory: '/home/mad/Documents/DATA/SM_ARTE_v3/ARTEref_161123/20/difflist'",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mFileNotFoundError\u001b[0m                         Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-6-880c525db2b4>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      2\u001b[0m     \u001b[0mI\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjsalert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'No difflist file present - is this a DOSY experiment ?'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'Reading file '\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mFC\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mselected\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0md2\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mImport_DOSY\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mFC\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mselected\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0md2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfilename\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mFC\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mselected\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      6\u001b[0m \u001b[0md2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mpulprog\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0md2\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mparams\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'acqu'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'$PULPROG'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/Documents/spike/spike/plugins/NMR/PALMA.py\u001b[0m in \u001b[0;36mImport_DOSY\u001b[0;34m(fname, nucleus, verbose)\u001b[0m\n\u001b[1;32m    420\u001b[0m     \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mLaplaceAxis\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize1\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    421\u001b[0m     \u001b[0mdire\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdirname\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfname\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 422\u001b[0;31m     \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_qvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mop\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mjoin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdire\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\"difflist\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    423\u001b[0m     \u001b[0;32mif\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m \u001b[0;34m!=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqvalues\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    424\u001b[0m         \u001b[0ml\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msize\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0maxis1\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqvalues\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/Documents/spike/spike/NPKData.py\u001b[0m in \u001b[0;36mload_qvalues\u001b[0;34m(self, fname)\u001b[0m\n\u001b[1;32m    595\u001b[0m         \u001b[0mdoc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    596\u001b[0m         \"\"\"\n\u001b[0;32m--> 597\u001b[0;31m         \u001b[0;32mwith\u001b[0m \u001b[0mopen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mfname\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m'r'\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0mF\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    598\u001b[0m             \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqvalues\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0marray\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mfloat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0ml\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mF\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreadlines\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstartswith\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'#'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    599\u001b[0m         \u001b[0;32mreturn\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mqvalues\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mFileNotFoundError\u001b[0m: [Errno 2] No such file or directory: '/home/mad/Documents/DATA/SM_ARTE_v3/ARTEref_161123/20/difflist'"
     ]
    }
   ],
   "source": [
    "if not op.exists(op.join(FC.selected_path,'difflist')):\n",
    "    I.jsalert('No difflist file present - is this a DOSY experiment ?')\n",
    "print('Reading file ',FC.selected)\n",
    "d2 = Import_DOSY(FC.selected)\n",
    "d2.filename = FC.selected\n",
    "d2.pulprog = d2.params['acqu']['$PULPROG']\n",
    "print (d2.params['acqu']['title'])\n",
    "d2.axis2.currentunit = 'sec'\n",
    "d2.axis1.currentunit = 'points'\n",
    "d2.display(title=\"%s/ser %s\"%(FC.nmrname,d2.pulprog), scale='auto')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In the current set-up, the figure can be explored *(zoom, shift, resize, etc)* with the jupyter tools displayed  below the dataset.\n",
    "The figure can also be saved as a `png` graphic file.\n",
    "\n",
    "At anytime, the figure can be frozen by clicking on the blue button on the upper right corner, just rerun the cell to make it interactive again.\n",
    "\n",
    "## Data Preparation\n",
    "We are going to use a basic processing set-up, check the documentation for advanced processing\n",
    "\n",
    "### Fourier Transform"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2019-06-21T09:35:27.335864Z",
     "start_time": "2019-06-21T09:35:27.094925Z"
    }
   },
   "outputs": [],
   "source": [
    "D2 = d2.copy() # copy the imported data-set to another object for processing\n",
    "# bk_ftF2 and bk_ftF1 (define in the Bruker plugin) find which FT to apply depending on FnMODE\n",
    "D2.apod_sin(maxi=0.1,axis='F2').zf(1,2).bk_ftF2().bk_pk()  # chaining  apodisation - zerofill - FT\n",
    "D2.axis2.currentunit = 'ppm'\n",
    "D2.display(scale=\"auto\", autoscalethresh=6.0, title=\"%s %s\"%(FC.nmrname,d2.pulprog))  # chain  set to ppm unit - and display"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Optimize phase\n",
    "If required, rephase first rows, and the correction will be applied to the whole dataset."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "R1 = D2.row(0) # copy the first line to another object for processing\n",
    "for i in range(4):\n",
    "    R1 += D2.row(i+1)\n",
    "Ph = I.Phaser1D(R1)  # phase it\n",
    "def loc(b):    # patch the on_done action o the phaser to propagate to DOSY\n",
    "#    Ph.on_Apply(b)\n",
    "    lp0, lp1 = Ph.ppivot() # get centered values\n",
    "    if lp0 != 0 or lp1 != 0:\n",
    "        D2.phase(lp0, lp1, axis=2)\n",
    "        D2.display(scale=\"auto\", autoscalethresh=6.0, title=\"%s %s\"%(FC.nmrname,d2.pulprog))\n",
    "Ph.button.on_click(loc)\n",
    "display(Ph)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### baseline correction\n",
    "A flat baseline centered on 0 is a requisite for a correct analysis.\n",
    "The following tool allows to point baseline positions on a extracted 1D, see the effect of the correction, and apply it to the whole 2D experiment.\n",
    "\n",
    "- use `add` and `rem` buttons to place points at the location of the selector.\n",
    "- the `auto` button populates with a first set of 8 positions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "R1 = D2.row(0) # copy the imported data-set to another object for processing\n",
    "for i in range(4):\n",
    "    R1 += D2.row(i+1)\n",
    "D2.projF2 = R1\n",
    "b = I.baseline2D_F2(D2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Verify your data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "I.Show2D(D2)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## PALMA processing\n",
    "First set you parameters\n",
    "\n",
    "Processing time is proportional to $N$ `x nbiter x finalsize`\n",
    "\n",
    "where $N$ is the number of processed columns (chosen with `miniSNR`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# Diffusion axis\n",
    "finalsize = 256  # The final of the DOSY on the diffusion axis\n",
    "Dmin = 10       # the minimum diffusion coefficient (in µm2/sec) typical is 1-100\n",
    "Dmax = 10000     # the maximum diffusion coefficient (in µm2/sec) typical is 5000-50000\n",
    "\n",
    "# Processing\n",
    "nbiter=1000      # number of iterations - the more the better (usually)\n",
    "lamda=0.1        # weight between \"pure\" MaxEnt (1.0) and \"pure\" l1 (0.0)\n",
    "\n",
    "# Optionnal parameters\n",
    "miniSNR=16       # minimum SNR in column to do processing - 32 is optimal -\n",
    "# uncertainty=1.2  # if >1 allows more room for algo when data quality is poor\n",
    "# precision=1e-08  # stopping criterium\n",
    "\n",
    "# MultiProcessing\n",
    "mppool=None         # a multiprocessing pool to do a parallel processing (faster)\n",
    "# if you want to use the mp capability, uncomment the following 3 lines\n",
    "#import multiprocessing as mp\n",
    "#NProc = 2           # here for 2 cores - adapt to your own set-up\n",
    "#mppool = mp.Pool(processes=NProc)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": true
   },
   "outputs": [],
   "source": [
    "D2.prepare_palma(finalsize, Dmin, Dmax)      # set-up diffusion axis\n",
    "DD2 = D2.do_palma(nbiter=nbiter, lamda=lamda, mppool=mppool)  # launch computation\n",
    "if mppool: mppool.close()  # clean-up"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### And display result\n",
    "Diffusion coefficients are along the vertical axis. Values are in $\\mu m^2 / sec$ which is $10^{-12} m^2 / sec$.\n",
    "Typical diffusion of small molecules in a solvent are between 100 and 1000 $\\mu m^2 / sec$ ($10^{-10} - 10^{-9} m^2 / sec$). Expect water around $3000 \\, \\mu m^2 / sec$ ($3 \\, 10^{-10} m^2 / sec$)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DD2.axis1.currentunit = 'Diff'\n",
    "DD2.projF2 = D2.row(0)\n",
    "DD2.projF1 = DD2.proj(axis=1,)\n",
    "I.Show2D(DD2, title=\"%s %s\"%(FC.nmrname,d2.pulprog))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Save the data-set\n",
    "either as stand alone native SPIKE files, (there are other formats)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "DD2.save('dosy.gs2')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "*Tools in this page is under intensive development - things are going to change rapidly.*"
   ]
  }
 ],
 "metadata": {
  "jupytext": {
   "encoding": "# -*- coding: utf-8 -*-",
   "formats": "ipynb,py:percent"
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.5"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": true,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": true,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "position": {
    "height": "227px",
    "left": "1125px",
    "right": "20px",
    "top": "120px",
    "width": "330px"
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
