Skip to content

Commit

Permalink
Ran Jupyter notebooks and included output of each cell in the files
Browse files Browse the repository at this point in the history
  • Loading branch information
domdfcoding committed May 19, 2020
1 parent 303c956 commit 516f640
Show file tree
Hide file tree
Showing 20 changed files with 2,617 additions and 2,219 deletions.
202 changes: 101 additions & 101 deletions pyms-demo/jupyter/BaselineCorrection.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
},
"source": [
"# Baseline Correction\n",
"\n",
Expand All @@ -27,17 +33,18 @@
"of the noise.\n",
"\n",
"First, setup the paths to the datafiles and the output directory, then import ANDI_reader, savitzky_golay and tophat."
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"import pathlib\n",
Expand All @@ -49,135 +56,134 @@
"from pyms.GCMS.IO.ANDI import ANDI_reader\n",
"from pyms.Noise.SavitzkyGolay import savitzky_golay\n",
"from pyms.TopHat import tophat"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
}
}
]
},
{
"cell_type": "markdown",
"source": [
"Read the raw data files and extract the TIC."
],
"metadata": {
"collapsed": false
}
},
"source": [
"Read the raw data files and extract the TIC."
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" -> Reading netCDF file '/home/domdf/Python/00 Projects/pyms-github/pyms-data/gc01_0812_066.cdf'\n"
],
"output_type": "stream"
" -> Reading netCDF file '/home/vagrant/PyMassSpec/pyms-data/gc01_0812_066.cdf'\n"
]
}
],
"source": [
"andi_file = data_directory / \"gc01_0812_066.cdf\"\n",
"data = ANDI_reader(andi_file)\n",
"tic = data.tic"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
}
}
]
},
{
"cell_type": "markdown",
"source": [
"Perform Savitzky-Golay smoothing\n",
" "
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
"source": [
"Perform Savitzky-Golay smoothing\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 3,
"outputs": [],
"source": [
"tic1 = savitzky_golay(tic)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
"is_executing": false,
"name": "#%%\n"
}
}
},
"outputs": [],
"source": [
"tic1 = savitzky_golay(tic)"
]
},
{
"cell_type": "markdown",
"source": [
"Perform Tophat baseline correction"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
"source": [
"Perform Tophat baseline correction"
]
},
{
"cell_type": "code",
"source": [
"tic2 = tophat(tic1, struct=\"1.5m\")"
],
"execution_count": 4,
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% \n",
"is_executing": false
"is_executing": false,
"name": "#%% \n"
}
},
"execution_count": 4,
"outputs": []
"outputs": [],
"source": [
"tic2 = tophat(tic1, struct=\"1.5m\")"
]
},
{
"cell_type": "markdown",
"source": [
"Save the output to disk"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
},
"source": [
"Save the output to disk"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"tic.write(output_directory / \"baseline_correction_tic.dat\",minutes=True)\n",
"tic1.write(output_directory / \"baseline_correction_tic_smooth.dat\",minutes=True)\n",
"tic2.write(output_directory / \"baseline_correction_tic_smooth_bc.dat\",minutes=True)"
],
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
"name": "#%% md\n"
}
}
},
{
"cell_type": "markdown",
},
"source": [
"## Tophat Baseline correction on an Intensity Matrix object\n",
"\n",
Expand All @@ -186,70 +192,64 @@
"the |tophat_im()| function may be used.\n",
"\n",
"Using the same value for `struct` as above, |tophat_im()| is used as follows:"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n"
}
}
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"from pyms.TopHat import tophat_im\n",
"from pyms.IntensityMatrix import build_intensity_matrix\n",
"im = build_intensity_matrix(data)\n",
"im_base_corr = tophat_im(im, struct=\"1.5m\")"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
}
}
]
},
{
"cell_type": "markdown",
"source": [
"Write the IC for mass 73 to disk for both the original and smoothed |IntensityMatrix|:"
],
"metadata": {
"collapsed": false
}
},
"source": [
"Write the IC for mass 73 to disk for both the original and smoothed |IntensityMatrix|:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"pycharm": {
"is_executing": false,
"name": "#%%\n"
}
},
"outputs": [],
"source": [
"ic = im.get_ic_at_index(73)\n",
"ic_base_corr = im_base_corr.get_ic_at_index(73)\n",
"\n",
"ic.write(output_directory/\"baseline_correction_ic.dat\",minutes=True)\n",
"ic_base_corr.write(output_directory/\"baseline_correction_ic_base_corr.dat\",minutes=True)"
],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%%\n",
"is_executing": false
}
}
]
},
{
"cell_type": "markdown",
"source": [],
"metadata": {
"collapsed": false,
"pycharm": {
"name": "#%% md\n",
"is_executing": false
"is_executing": false,
"name": "#%% md\n"
}
}
},
"source": []
}
],
"metadata": {
Expand All @@ -261,25 +261,25 @@
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.6"
"pygments_lexer": "ipython3",
"version": "3.6.9"
},
"pycharm": {
"stem_cell": {
"cell_type": "raw",
"source": [],
"metadata": {
"collapsed": false
}
},
"source": []
}
}
},
"nbformat": 4,
"nbformat_minor": 0
}
}
Loading

0 comments on commit 516f640

Please sign in to comment.