Commit 71c61a07 authored by Unknown's avatar Unknown
Browse files

Remove NFINDR from example

parent a1fd4830
......@@ -16,14 +16,10 @@ In this notebook we load some spectral data, and perform basic data analysis, in
* KMeans Clustering
* Non-negative Matrix Factorization
* Principal Component Analysis
* NFINDR
Software Prerequisites:
=======================
* Standard distribution of **Anaconda** (includes numpy, scipy, matplotlib and sci-kit learn)
* **pysptools** (will automatically be installed in the next step)
* **cvxopt** for fully constrained least squares fitting
* install in a terminal via **`conda install -c https://conda.anaconda.org/omnia cvxopt`**
* **pycroscopy** : Though pycroscopy is mainly used here for plotting purposes only, it's true capabilities
are realized through the ability to seamlessly perform these analyses on any imaging dataset (regardless
of origin, size, complexity) and storing the results back into the same dataset among other things
......@@ -222,63 +218,6 @@ axis.set_ylabel(y_label, fontsize=12)
axis.set_title('NMF Components', fontsize=14)
axis.legend(bbox_to_anchor=[1.0, 1.0], fontsize=12)
#####################################################################################
# 4. NFINDR
# =========
#
# NFINDR is a geometric decomposition technique that can aid in determination of constitent spectra in data.
# The basic idea is as follows. Assume that at any point *x*, the spectra measured *A(w,x)* is a
# linear superposition of *k* 'pure' spectra, i.e.
#
# *A(w,x)* = c\ :sub:`0`\ (x)a\ :sub:`0` + c\ :sub:`1`\ (x)a\ :sub:`1` + ... + c\ :sub:`k`\ (x)a\ :sub:`k`
#
# In this case, our task consists of first determining the pure spectra {a\ :sub:`0`\ ,...,a\ :sub:`k`\ },
# and then determining the coefficients {c\ :sub:`0`\ ,...,c\ :sub:`k`\ }. NFINDR determines the 'pure'
# spectra by first projecting the data into a low-dimensional sub-space (typically using PCA), and then
# taking the convex hull of the points in this space. Then, points are picked at random along the convex
# hull and the volume of the simplex that the points form is determined. If (k+1) pure spectra are needed,
# the data is reduced to (k) dimensions for this purpose. The points that maximize the volume of the
# simples are taken as the most representative pure spectra available in the dataset. One way to think of
# this is that any spectra that lie within the given volume can be represented as a superposition of these
# constituent spectra; thus maximizing this volume allows the purest spectra to be determined.
#
# The second task is to determine the coefficients. This is done usign the fully constrained least squares
# optimization, and involves the sum-to-one constraint, to allow quantitative comparisons to be made.
# More information can be found in the paper below:
#
# `Winter, Michael E. "N-FINDR: An algorithm for fast autonomous spectral end-member determination in
# hyperspectral data." SPIE's International Symposium on Optical Science, Engineering, and Instrumentation.
# International Society for Optics and Photonics, 1999.
# <http://proceedings.spiedigitallibrary.org/proceeding.aspx?articleid=994814>`_)
#
# Yet again, we will only work with the non-negative portion of the data (Amplitude)
num_comps = 4
# get the amplitude component of the dataset
data_mat = np.abs(h5_main)
nfindr_results = eea.nfindr.NFINDR(data_mat, num_comps) #Find endmembers
end_members = nfindr_results[0]
fig, axis = plt.subplots(figsize=(5.5, 5))
px.plot_utils.plot_line_family(axis, freq_vec, end_members, label_prefix='NFINDR endmember #')
axis.set_title('NFINDR Endmembers', fontsize=14)
axis.set_xlabel(x_label, fontsize=12)
axis.set_ylabel(y_label, fontsize=12)
axis.legend(bbox_to_anchor=[1.0,1.0], fontsize=12)
# fully constrained least squares model:
fcls = amp.FCLS()
# Find abundances:
amap = fcls.map(data_mat[np.newaxis, :, :], end_members)
# Reshaping amap
amap = np.reshape(np.squeeze(amap), (num_rows, num_cols, -1))
px.plot_utils.plot_map_stack(amap, heading='NFINDR Abundance maps', cmap=plt.cm.inferno,
color_bar_mode='single');
#####################################################################################
# Close and delete the h5_file
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment