In [1]:
%load_ext autoreload
%autoreload 2
import sys
import os
sys.path.append("/Users/palmer/Documents/python_codebase")
import pyImagingMSpec.convert.h5_to_imzml as h5_to_imzml

In [2]:
fin = "/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5"
fout = "/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.imzML"
h5_to_imzml.hdf5_centroids_IMS(fin,fout)


file loaded
dim: 223 x 257
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 2.2%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 4.5%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 6.7%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 9.0%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 11.2%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 13.4%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 15.7%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 17.9%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 20.1%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 22.4%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 24.6%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 26.9%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 29.1%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 31.3%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 33.6%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 35.8%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 38.1%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 40.3%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 42.5%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 44.8%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 47.0%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 49.2%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 51.5%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 53.7%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 56.0%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 58.2%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 60.4%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 62.7%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 64.9%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 67.2%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 69.4%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 71.6%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 73.9%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 76.1%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 78.3%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 80.6%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 82.8%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 85.1%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 87.3%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 89.5%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 91.8%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 94.0%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 96.3%
[/Users/palmer/Documents/tmp_data/RatBrain_IMS/single_smooth/Rat_brain_1M_50um_97_trim_centoids_IMS.hdf5] progress: 98.5%
finished!
/usr/local/lib/python2.7/site-packages/numpy/core/_methods.py:59: RuntimeWarning: Mean of empty slice.
  warnings.warn("Mean of empty slice.", RuntimeWarning)
/usr/local/lib/python2.7/site-packages/numpy/core/_methods.py:70: RuntimeWarning: invalid value encountered in double_scalars
  ret = ret.dtype.type(ret / rcount)

In [3]:
from pyImagingMSpec.hdf5.inMemoryIMS import inMemoryIMS
fout = "/Users/palmer/Documents/tmp_data/UCSD01902/UCSD_01902_centroids_IMS.imzML"

imsDataset = inMemoryIMS(fout,cache_spectra=True,min_mz=100., max_mz=200.)


TODO: convert indices into real world coordinates
loaded spectra
file loaded

In [4]:
import matplotlib.pyplot as plt
import numpy as np
%matplotlib notebook
ionIm = imsDataset.get_ion_image(np.asarray([174.492797852,]),np.asarray([100,]))
im = ionIm.xic_to_image(0)
plt.figure()
plt.imshow(im)
plt.clim([np.min(ionIm.xic),np.percentile(ionIm.xic,99)])
plt.colorbar()
plt.show()


/usr/local/lib/python2.7/site-packages/IPython/kernel/__init__.py:13: ShimWarning: The `IPython.kernel` package has been deprecated. You should import from ipykernel or jupyter_client instead.
  "You should import from ipykernel or jupyter_client instead.", ShimWarning)

In [5]:
print imsDataset.mz_list[np.argmax(imsDataset.count_list)]


174.492797852

In [6]:
filename = "/Volumes/alexandr/palmer/data_store/IMS/2015_08/20150813_ADP_KS_DHBsub_PRM_70x55_15um_fullms/20150813_ADP_KS_DHBsub_mouseBrain_70x55_15um_fullms.imzML"
imsDataset2 = inMemoryIMS(filename,cache_spectra=True)


TODO: convert indices into real world coordinates
loaded spectra
file loaded

In [7]:
ionIm = imsDataset2.get_ion_image(np.asarray([730.5745,]),np.asarray([100,]))
im = ionIm.xic_to_image(0)
plt.figure()
plt.imshow(im,interpolation='nearest')
plt.clim([np.min(ionIm.xic),np.percentile(ionIm.xic,99)])
plt.colorbar()
plt.show()