summaryrefslogtreecommitdiff
path: root/python-spectramap.spec
blob: f8009b782a7cd9b4ed7418dda11c458d8e6f3664 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
%global _empty_manifest_terminate_build 0
Name:		python-spectramap
Version:	0.5.3
Release:	1
Summary:	Hyperspectral package for spectroscopists
License:	MIT License
URL:		https://github.com/spectramap/spectramap
Source0:	https://mirrors.nju.edu.cn/pypi/web/packages/c0/3d/113329285ccca34c91e8e1198fc0390a5559f5149a996b0f005159e7e010/spectramap-0.5.3.tar.gz
BuildArch:	noarch

Requires:	python3-scikit-learn
Requires:	python3-pyspectra
Requires:	python3-scipy

%description
<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mndHVHqnpqVudLMiDZbho2Gi45g9sNnh1OzVkAY0MOwWH9Fm5keWXSrxCdfAum-K4yijPD3dSUTbxPHVeI9OHoa-EkMWfGn2d4XARNHqiGBVr25fCJUx0IWYZYgrDnW2nGtS0PuPDR1M-KvSmoSnC5tNuqH_KatsV68MFPr984_eUQWGk0GEjd5vtvpafqrGN?width=500&height=394&cropmode=none" />

## *SpectraMap (SpMap): Hyperspectral package for spectroscopists in Python*

<p align="justify">Hyperspectral imaging presents important applications in medicine, agriculture, pharmaceutical, space, food and many upcoming applications. The analysis of hyperspectral images requires advanced software. The upcoming developments related to fast hyperspectral imaging, automation and deep learning applications demand innovative software developments for analyzing hyperspectral data. The Figure 1 shows the hyperspectral imaging by a standard spectrometer instrument. More information regarding novel medical imaging is found in <a href= "https://advancesimaging.blogspot.com"> advances in imaging</a>.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mFDcOdm5472CEwuu-1aCTB20ZzS5wxLSO9bMZer1YgIQE2ekouGnfET2yuRF4jQbr9MoxPhw4FLX7ZbpBTF4vrYUnnMK3WP3_bQg7oyFdxTTYJmX7bSvu6k3gjZoWJL2wToqf52Ga3dopLGuaGXqxu4LHhQjot9_8yGPowpjisnI8vpPQ-7URYfgRNNH5oJ8S?width=660&height=371&cropmode=none" />

<p align="center">Figure 1 Raman Imaging Instrument

## Features

<p align="justify">The package includes standard tools such as reading, preprocessing, processing and visualization. The designing was focused on working hyperspectral images from Raman datasets. The package is extended to other spectroscopies as long as the data follows the type data structure.  Some features are shown by the next figures.

- <p align="justify">Preprocessing: some tool such as smoothing, removal of spikes, normalization and advanced baseline corrections are included. Figure 2 illustrates a mean and standard deviation of a tissue signature.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mplHFW8SLZNdnUpXqO6g4scKHgzE0F2HF-24bwCf5qTiZnX-S1WjV95CU_8PFufzzf2PeQewZTcuUyhAuFpOyMub5NCail6phkrkXjpldosPcdwTFOpAFhq8i0stGiEoUETcUKvnSMBFVp_R7bKl66-vU36itVQl5hdAntSP71hJ6qMXPbtDmnWacYo-YdBro?width=550&height=400&cropmode=none" />

<p align="center"> Figure 2 Visualization of tissue Raman signature

- <p align="justify">Processing: some tools such as unmixing, pca, pls, vca and hierarchical and kmeans clustering are included. Figure 3 displays application of clustering for locating microplastics on complex matrices.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4mCv3oo8wnXEf1lEJiK01NOUET8Sbt3yMIlkReJ3CsKhBV2yaVJ43ZLUFEhW0i7vGdLAagLDJAlomRYrutpLl2mbg8oxa5QPCmHjP2Ktz1dzoRtkroi8vJWCtA67hbCC6sElL0LvyyKhwao7ZhqE5TZQQA_EV-tl3qctMSOalqcREcFyTXiULJXz-FtlpEBZdD?width=660&height=574&cropmode=none" />
  
  <p align="center"> Figure 3 Segmentation by clustering: (a) clustered image, (b) unmixing image, (c) image and (d) mean clusters

- <p align="justify">Visualization: the next examples shows the pca scores of several biomolecules.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4m2IgtZawTrfzKz36eecSGjwkXsjp5Zp5vognNGr-v-VeNX4nLSWbid62R28cW6_gqsxS5JJfNBeF2pzQArOPDEsb3BqTYyyzGo2qA5CuXZaLCER_a6PiwVubWL2B9GB0n6hgHXkSXouTZKLYEHPve_TwUVOtYN9inEhgU3wH5kazukHsbqeyRar4fdgNUg6Bz?width=450&height=501&cropmode=none" />

<p align="center">Figure 4 PCA scores

## Further upcoming developments:

- [] Graphical User Interface

- [] Supervised tools

- [] Deep learning - CNN

- [x] Optimizing speed and organizing main code 

- [x] More examples

## Installation

<p align="justify">The predetermined work interface is Python 3. The library comes with 8 different hyperspectral examples and analysis. A manual presents the relevant functions and examples <a href="https://github.com/spectramap/spectramap/tree/main/docs"> Manual</a>.
<p align="justify">Install the library and required packages: (admin rights):

```python
pip install spectramap
```

## Examples

#### Reading and processing a spc file

<p align = "justify"> In the <a href = "https://github.com/spectramap/spectramap/tree/main/examples"> examples </a>, there is ps.spc file for this example. The next lines show some basic tools. The function read_single_spc reads the path directory of the file.

```python
from spectramap import spmap as sp #reading spmap
pigm = sp.hyper_object('pigment') #creating the hyperobject
pigm.read_single_spc('pigment') #reading the spc file
pigm.keep(400, 1800) #Keeping fingerprint region
pigm_original = pigm.copy() #Copying hyperobject
pigm_original.set_label('original') #renaming hyperobject to original
pigm.set_label('processed') #renaming hyperobject to processed

pigm.rubber() #basic baseline correction rubber band
pigm.gol(15, 3, 0) #savitzky-golay filter
both = sp.hyper_object('result') #creating an auxilary hyperobject
both.concat([pigm_original, pigm]) #concatenating the original and processed data
both.show(False) #show both spectra 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m-pe9JbCoAZrJW-nBGBe4LGPLALTafIo3ZJPznScF9felxCXxVSLdA83DGLCKy_wlIj37r8UXBFWlgh1P0imLcFbEvveTJ46j4japWXklN8qttiM3X_y1Hid1YmANAq9EJS0crhltOFXjQt39S0ofUbHqQ0NxgF449sw8NUG92xTLjBq3B1niaUk7S4-qYg47?width=660&height=408&cropmode=none"  />

```python
both.show_stack(0.2, 0, 'auto') #advanced stack visualization 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mnECDWTSH0PtXtx4Gjc1Vv_Us0gv4T2e9U-bFuSOW6CBbHOGdyvsiCoFeGmYGvDVlsF52sTsKopv63xxTyaXOLQhZk5vd3twL1aAsz9xT-lFr9Qv1WT5aATpPjUOMlg6kV_42FPKbpfoIAdufFmKEWzziLok3n0ngefa2BIynR-UkqHKgpoj0ftX4d3B6EdUd?width=660&height=408&cropmode=none" />

<p align="center">Figure 6 Second visualization

#### Reading and processing a comma separated vector file with depth profiling

<p align="justify">In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a>, there is a layers.csv.xz file for this example. The next lines show some basic tools. The function read_csv requires the path directory of the file. The csv file must keep the structure of the <a href="https://github.com/spectramap/spectramap/tree/main/docs"> manual </a> (hyperspectral object). The example shows how to analise the data of spectroscopic profiles.

```python
from spectramap import spmap as sp # reading spectramap library
stack = sp.hyper_object('plastics') # creating the hyper_object
stack.read_csv_xz('layers') # reading compressed csv of plastics profile
stack.keep(500, 1800) # keeping fingerprint region
stack.rubber() # baseline correciton rubber band
stack.vector() # vector normalization
endmember = stack.vca(6) # number of endmembers  
endmember.show_stack(0.2, 0, 'auto') # advanced stack plot of endmembers 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m30AdeakA3242L2iGqNBf75gkIgpNdA1SWwgV3I2bq41q8oOZ0wiVkrRSw9-z-D3sbsLA6aBBZZuyQ01JkzdebzEoEuxcWmbzRj7EvnTRjSJDYYjyY1y5oiU3-G4iolIqAtjiEmqVtAzmzPMw2KOqIUxPQB-n9JoK4xbX24_Krql4TiwhU-2rTSyg_VF6wI8M?width=660&height=408&cropmode=none" />

```python
abundance = stack.abundance(endmember, 'NNLS') # estimation of concentrations by NNLS
abundance.set_resolution(0.01) # setting the step size resolution
abundance.show_profile('auto') # plotting spectral profile 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mLDJEXyCgxNqLUYQkDAD8qKZWBF8PGpvEz0oX-Iie6TdKMACBpc1Bl4EqZwSfIoLVNWnstFK_q36k5RY-lJHQtAyr8or_TOMetowWHjrdc6xipY8PSbeSSDrXeE7YoKTa0xVCqZraJ5ec-ySyYd01cdFi4k_XTq-etSZGq8uJQf5WQHoiV0IYjEmYWJ0izLd_?width=660&height=408&cropmode=none" />

#### Processing hyperspectral images by VCA and Clustering

comming soon. For now on, Check the manual.

#### Processing hyperspectral data of plastics by PCA and PLS-LDA

<p align="justify"> In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a> , there is a layers.csv.xz file for this example. The next processing steps computes unsupervised principal component analysis and double supervised partial least square + linear discriminant analysis. The scatter plots show the separation of the plastics: red, light_blue and blue are the most different ones.

```python
from spectramap import spmap as sp # reading spectramap library
sample = sp.hyper_object("sample") # creating hyper_object
sample.read_csv_xz("layers") # reading compressed csv of plastics profile
sample.remove(1800, 2700) # removing silent region
sample.keep(400, 3300) # keeping finger print and high wavenumber region
sample.gaussian(2) # appliying gaussian filter
sample.rubber() # rubber baseline correction
sample.kmeans(2) # kmeans 2 clusters
sample.rename_label([1, 2], ["first", "second"]) # rename labels
sub_label = sample.get_label()  # saving sub_labels
sub_label.name = "sub_label" # renaming the title of sub_label
sample.show_stack(0,0, "auto") # showing a stack
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m1LwvuTidoiBCa9enm-_OaENR3KfWSFkgyHGANrk2ii-uY9-vWwmWF5fjSM9dF-H9w-O0TOTfR3MWh8lmVOIN5iHwhb7UxcI6nzHHdAwLucGaXEKMuXVktgZ83eYljUHmCwzRhAfevqW63EWywF0WgBnvw_XRribVVREalh9XS9Eoe5IE9thY9hd_f3utuIvx?width=660&height=410&cropmode=none" />

```python
sample.kmeans(6) # kmeans clustering example for main_label
main_label = sample.get_label() # saving the main_label
main_label.name = "main_label" # renaming the title of the label
sample.show_stack(0,0, "auto") # showing the 6 components
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mYlaMwL3OhKuch2tv4XR_4q9o0EoGK6sn-I6PwKjtvkqJECcDAmz76rLSXdMw_v86tLSKltHM756ULIpkkpuOZO8s3ATOUkzsgzWakF7JShfxlBOUFp-vgexi33aID4Jj6NzxBVGZSUdFFPaAhTxJLg7oUJwkgapfoBpzg1mT89uTUC4dHqEXG5XTbLyLonD5?width=660&height=410&cropmode=none" />

```python
scores_pca, loadings_pca = sample.pca(3, False) # 3 components pca
scores_pca.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublabel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXLVSKKaTqp_chimU_qvxTGXiNIq0LegkAQmVHTrkjQ4nIXICALBisIk2bQNmMaGgVQGEkAdmoYQaKuH-bXVgDMDRGct9_9cW5ABHOVsx-aYmbXQKtcHYLZNwT8Kz7PFqmQkuZBkzM5dmjfjkK0N4AxTSl4OM2XRHbwaUqflvLzH-UWF7Ts4IpowpphDU2Zwx?width=660&height=426&cropmode=none" />

```python
scores_pls, loadings_pls = sample.pls_lda(3, False, 0.7) # 3 components pls-lda  and 70% training data
scores_pls.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublevel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXbKMwtXDVcngG68AW4hhLYbPvEsLHZ5Y4hdBuO-JxicuoSZegq-YbNgmNET-kuMC_dW2dqE-CBOQ05FSt29Yx8rT_eeFE_vPyXTxBczgY90b4gChRx3IR3iei0MpERo1yrD6t9hN1TCmGjEzakPU17w8rbMvQ3dbnzV1eBgP-Kol8jlraVtnZHKpTHhWtnf-?width=660&height=431&cropmode=none" />

<p align="justify"> The next figures shows the precision, recall (sensititivity), f1-score (weighted average of preceision) and support for the 6 components. Accuracy and average accuracy.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mj56vCKYH1LPHMS4if0mezHNO5YFzrZxxV626ocQLgfGeXu5eYJNR0fn8_Ap33DKZEURqAUuYvBXrNNm4Qg94-hd598m6cJdBg7w0NWwzNZVFcFuOoJhNUn3aF5T6ARXB_8h8qdodKjYpJhCVQDLvsfN53v5eM__BV_AKYIN2vmK8YuL9TLqqJD8fo6JLyd3V?width=474&height=227&cropmode=none" />

#### Raman wavenumber calibration by paracetaminol

<p align="justify"> Reproducibility and replicativity are fundamental parameters for Raman spectroscopy. One common way for wavenumber axis calibration is discussed in this section. The requirements are a paracetaminol sample (powder) and the calibration file (well-measured peaks) and a polynomial regression.

```python
from spectramap import spmap as sp # reading spectramap library
import pandas as pd
import numpy as np

### Paracetaminol 
path = 'para.csv' # path of the paracetaminol data
table = pd.read_table(path, sep = ',', header = None) # read data
table['label'] = "Para" # create label
table[['x', 'y']] = np.zeros((20,2)) # create fake positions
### Processing
mp = sp.hyper_object("Para") # creation of hyper object
mp.set_data(table.iloc[:,:len(table.columns)-3]) # reading the intensity 
mp.set_position(table[['x', 'y']]) # reading positions
mp.set_label(pd.Series(table['label'])) # reading labeling
copy = mp.copy() # copy data
peaks = copy.calibration_peaks(mp, 0.05) # finding peaks of para (next plot)
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mJ89jfrxDF_p5mLQFMbpHL0rsk58_6yoLwOI1_lMk9aT4wMLZyyGSP89l0QfnWipiAZiWDje_UxmuS6uB3LzDHvL7QmnO3ml2dCs4F6pafztjocJLADDlsXVo324KZM2ycI9FyMFLfqMdnumqRwIZpa5VI_uhFsJ8mvHFMUNsStw2OQ3tRZQq0XlQURRozrMN?width=660&height=379&cropmode=none" />

```python
copy.calibration_regression(peaks) # determining regression for the calibration
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mKTK3bLA_XkVa6pTbs_x7VFxmOsiLI9hmczm-77fwTnKfOYaF4UiP_BZAVnQZkJP2kDilM-dlCLBYnvncwh6eBfGJvdvt9rYxvghpaztSNHX7kCAGphEUJEQarK_OdaGNU11tAUEACOn1mavJrK-v8W-Jdbdg_367GmcO2CpxLpiDgT8PGtDNHQkPsGrs5kkT?width=660&height=379&cropmode=none" />

```python
mp.set_wavenumber(copy.get_wavenumber()) # set the new wavenumber to the original mp
mp.show(True) # show calibrated data
mp.add_peaks(0.1, 'r') # add peaks (not inline mode)
mp.save_data("", "calibration") # save calibrated data
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m8GE0Ho0DvmWdXyE0ZN_aqpVjWxdma-c_Ll_QD9R20Ke9B9dEinZR8er0Fjg3HMJRVcv_AYsqHNyWUKevvBeG6nj07EE9vIWDC2zr3uaIpvMcJKhnF_Rcu1zpxmymWqiCnNLlIpeTnxGnXwW734ZVQjb9mCEfniU-aXDgufoLvFEgQgWgTs4w7e3XOG6nWrur?width=660&height=324&cropmode=none" />

#### Processing hyperspectral images from biological tissue

comming soon. For now on, Check the manual.

#### Raman Intensity Calibration

The next lines show how to calibrate intensity axis in Ramam spectroscopy. It is required a standard spectrum of halogen lamp and the experimental measurement of the halogen lamp with the Raman instrument.

```python
from spectramap import spmap as sp # reading spectramap package
reference_trial = sp.hyper_object("reference") # creating reference hyper object
reference_trial.read_single_spc(path + "reference") # reading the referece data spectrum 
reference_trial.show(True) # showing the spectrum in the next plot
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mS7E9jF96MGDDSPRsp_PO7IJGDX_WVsDNkVU1snc2zNsT9mciLmQ331-BiAAR3_tEDd8a9AANrr-liAzAMbCmAWcAcHDuphckkyu6gCQjChHQy4zm4ISreOfS7CWz-MAwREfhfzkOuUAQG6kRtECnD5tG-rOkOYFHeB49J_93eF0uNo_QKW_Pt5HQmfRnqgI3?width=660&height=401&cropmode=none" />

Now the experimental spectrum.

```python
measured_trial = sp.hyper_object("measured") # creating hyper object
measured_trial.read_single_spc(path + "lamp") # reading data
measured_trial.keep(400, 1900) # keeping finger print region
measured_trial.show(True) # showing the plot as the next figures shows
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mgHiVbaq4PTIwV4-OUf0NhA2HVImJLqbgk_vKGOQ_k7afhEgLaPT0eXU3mCM_VlzELEWSoSE81W_OgM39E_F1gggRt-ILiOSH1jpPbCwtNlSCkjXScUzm0b--LubKANx-zqW5iyklz2f7-axSjnwDi5G-hQpc_21ycVoGtrUp7k_ZGpgETY4iCYSx1iQ5P6TT?width=660&height=401&cropmode=none" />

Reading the Raman sample. 

```python
sample = sp.hyper_object("sample") # declareting hyper object
sample.read_single_spc(path + "sample") # reading tissue data
sample.keep(400, 1900) # keeping finger print region
sample.show(True) # showing plot in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mfkYUhxDhwjI0Qel4lqN36GRZpNzyrqBalwxq35lhbz55CJej9k5x5_rtug0DQOEB_lHp7aB5tQfjVlQdw-VfrMUNZgyWSDt-bJq-BxHwB3g2HNtyMBW82iCWFeAW9I4QFAoLNx11gNVQjULOKj9N9EDAONR569qAUCy-qbkTbwyNIQuOk4GSVPD3Tx-IAuVO?width=660&height=401&cropmode=none" />>

Calibration of the Raman sample.

```python
sample.intensity_calibration(reference_trial, measured_trial) # intensity calibration function
sample.show(True) # showing the calibrated data in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mE8dFFtM-NvQ28s53Md-f9AnhF9rDh0gfn5EBnIin2LRh10eeJJ4cmUZMK4NFTEt7emCIowieDxA2dQ65G4qPtMyeBK0f0kDvtUg7kq7WEibWGL_Z5Wo3FqzSaNWdfnMFNn13dCdzPYSD9Fm17tPsywidPadvWBG4R142LRJ3YEimLDQo_wsPta4-aMh_zm-0?width=660&height=401&cropmode=none" />

## Working Team

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mHmwP0VTHTFAZZqccQFPVNHS5BTz5fg1mOqqbv_sizMho2majbgupRfZZYl_A1nYzQHXjI5W4T3vgJTKcksjWqe_axT4Ko2-QcEWLgz9YbPn-4qpdbnVFouUPrNza1YS6gV7Kx2_tb_rqxifev3NE-YJIp_vnawgNmEr2eEJcyIQ_Xl-VZNv7qIsh16kl4AKn?width=800&height=250&cropmode=none" />

## License

<p style="text-align: center;">
    MIT

<p align="justify">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

<p align="justify">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

<p align="justify">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## References

[1] F. Pedregosa, G. Varoquaux, and A. Gramfort, “Scikit-learn: Machine Learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825-- 2830, 2011.

[2] J. M. P. Nascimento and J. M. B. Dias, “Vertex component analysis: A fast algorithm to unmix hyperspectral data,” IEEE Transactions on Geoscience and Remote Sensing, vol. 43, no. 4, pp. 898–910, 2005, doi: 10.1109/TGRS.2005.844293.

[3] Z. M. Zhang, S. Chen, and Y. Z. Liang, “Baseline correction using adaptive iteratively reweighted penalized least squares,” Analyst, vol. 135, no. 5, pp. 1138–1146, 2010, doi: 10.1039/b922045c.

[4] L. McInnes, J. Healy, S. Astels, *hdbscan: Hierarchical density based clustering* In: Journal of Open Source Software, The Open Journal, volume 2, number 11. 2017


%package -n python3-spectramap
Summary:	Hyperspectral package for spectroscopists
Provides:	python-spectramap
BuildRequires:	python3-devel
BuildRequires:	python3-setuptools
BuildRequires:	python3-pip
%description -n python3-spectramap
<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mndHVHqnpqVudLMiDZbho2Gi45g9sNnh1OzVkAY0MOwWH9Fm5keWXSrxCdfAum-K4yijPD3dSUTbxPHVeI9OHoa-EkMWfGn2d4XARNHqiGBVr25fCJUx0IWYZYgrDnW2nGtS0PuPDR1M-KvSmoSnC5tNuqH_KatsV68MFPr984_eUQWGk0GEjd5vtvpafqrGN?width=500&height=394&cropmode=none" />

## *SpectraMap (SpMap): Hyperspectral package for spectroscopists in Python*

<p align="justify">Hyperspectral imaging presents important applications in medicine, agriculture, pharmaceutical, space, food and many upcoming applications. The analysis of hyperspectral images requires advanced software. The upcoming developments related to fast hyperspectral imaging, automation and deep learning applications demand innovative software developments for analyzing hyperspectral data. The Figure 1 shows the hyperspectral imaging by a standard spectrometer instrument. More information regarding novel medical imaging is found in <a href= "https://advancesimaging.blogspot.com"> advances in imaging</a>.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mFDcOdm5472CEwuu-1aCTB20ZzS5wxLSO9bMZer1YgIQE2ekouGnfET2yuRF4jQbr9MoxPhw4FLX7ZbpBTF4vrYUnnMK3WP3_bQg7oyFdxTTYJmX7bSvu6k3gjZoWJL2wToqf52Ga3dopLGuaGXqxu4LHhQjot9_8yGPowpjisnI8vpPQ-7URYfgRNNH5oJ8S?width=660&height=371&cropmode=none" />

<p align="center">Figure 1 Raman Imaging Instrument

## Features

<p align="justify">The package includes standard tools such as reading, preprocessing, processing and visualization. The designing was focused on working hyperspectral images from Raman datasets. The package is extended to other spectroscopies as long as the data follows the type data structure.  Some features are shown by the next figures.

- <p align="justify">Preprocessing: some tool such as smoothing, removal of spikes, normalization and advanced baseline corrections are included. Figure 2 illustrates a mean and standard deviation of a tissue signature.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mplHFW8SLZNdnUpXqO6g4scKHgzE0F2HF-24bwCf5qTiZnX-S1WjV95CU_8PFufzzf2PeQewZTcuUyhAuFpOyMub5NCail6phkrkXjpldosPcdwTFOpAFhq8i0stGiEoUETcUKvnSMBFVp_R7bKl66-vU36itVQl5hdAntSP71hJ6qMXPbtDmnWacYo-YdBro?width=550&height=400&cropmode=none" />

<p align="center"> Figure 2 Visualization of tissue Raman signature

- <p align="justify">Processing: some tools such as unmixing, pca, pls, vca and hierarchical and kmeans clustering are included. Figure 3 displays application of clustering for locating microplastics on complex matrices.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4mCv3oo8wnXEf1lEJiK01NOUET8Sbt3yMIlkReJ3CsKhBV2yaVJ43ZLUFEhW0i7vGdLAagLDJAlomRYrutpLl2mbg8oxa5QPCmHjP2Ktz1dzoRtkroi8vJWCtA67hbCC6sElL0LvyyKhwao7ZhqE5TZQQA_EV-tl3qctMSOalqcREcFyTXiULJXz-FtlpEBZdD?width=660&height=574&cropmode=none" />
  
  <p align="center"> Figure 3 Segmentation by clustering: (a) clustered image, (b) unmixing image, (c) image and (d) mean clusters

- <p align="justify">Visualization: the next examples shows the pca scores of several biomolecules.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4m2IgtZawTrfzKz36eecSGjwkXsjp5Zp5vognNGr-v-VeNX4nLSWbid62R28cW6_gqsxS5JJfNBeF2pzQArOPDEsb3BqTYyyzGo2qA5CuXZaLCER_a6PiwVubWL2B9GB0n6hgHXkSXouTZKLYEHPve_TwUVOtYN9inEhgU3wH5kazukHsbqeyRar4fdgNUg6Bz?width=450&height=501&cropmode=none" />

<p align="center">Figure 4 PCA scores

## Further upcoming developments:

- [] Graphical User Interface

- [] Supervised tools

- [] Deep learning - CNN

- [x] Optimizing speed and organizing main code 

- [x] More examples

## Installation

<p align="justify">The predetermined work interface is Python 3. The library comes with 8 different hyperspectral examples and analysis. A manual presents the relevant functions and examples <a href="https://github.com/spectramap/spectramap/tree/main/docs"> Manual</a>.
<p align="justify">Install the library and required packages: (admin rights):

```python
pip install spectramap
```

## Examples

#### Reading and processing a spc file

<p align = "justify"> In the <a href = "https://github.com/spectramap/spectramap/tree/main/examples"> examples </a>, there is ps.spc file for this example. The next lines show some basic tools. The function read_single_spc reads the path directory of the file.

```python
from spectramap import spmap as sp #reading spmap
pigm = sp.hyper_object('pigment') #creating the hyperobject
pigm.read_single_spc('pigment') #reading the spc file
pigm.keep(400, 1800) #Keeping fingerprint region
pigm_original = pigm.copy() #Copying hyperobject
pigm_original.set_label('original') #renaming hyperobject to original
pigm.set_label('processed') #renaming hyperobject to processed

pigm.rubber() #basic baseline correction rubber band
pigm.gol(15, 3, 0) #savitzky-golay filter
both = sp.hyper_object('result') #creating an auxilary hyperobject
both.concat([pigm_original, pigm]) #concatenating the original and processed data
both.show(False) #show both spectra 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m-pe9JbCoAZrJW-nBGBe4LGPLALTafIo3ZJPznScF9felxCXxVSLdA83DGLCKy_wlIj37r8UXBFWlgh1P0imLcFbEvveTJ46j4japWXklN8qttiM3X_y1Hid1YmANAq9EJS0crhltOFXjQt39S0ofUbHqQ0NxgF449sw8NUG92xTLjBq3B1niaUk7S4-qYg47?width=660&height=408&cropmode=none"  />

```python
both.show_stack(0.2, 0, 'auto') #advanced stack visualization 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mnECDWTSH0PtXtx4Gjc1Vv_Us0gv4T2e9U-bFuSOW6CBbHOGdyvsiCoFeGmYGvDVlsF52sTsKopv63xxTyaXOLQhZk5vd3twL1aAsz9xT-lFr9Qv1WT5aATpPjUOMlg6kV_42FPKbpfoIAdufFmKEWzziLok3n0ngefa2BIynR-UkqHKgpoj0ftX4d3B6EdUd?width=660&height=408&cropmode=none" />

<p align="center">Figure 6 Second visualization

#### Reading and processing a comma separated vector file with depth profiling

<p align="justify">In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a>, there is a layers.csv.xz file for this example. The next lines show some basic tools. The function read_csv requires the path directory of the file. The csv file must keep the structure of the <a href="https://github.com/spectramap/spectramap/tree/main/docs"> manual </a> (hyperspectral object). The example shows how to analise the data of spectroscopic profiles.

```python
from spectramap import spmap as sp # reading spectramap library
stack = sp.hyper_object('plastics') # creating the hyper_object
stack.read_csv_xz('layers') # reading compressed csv of plastics profile
stack.keep(500, 1800) # keeping fingerprint region
stack.rubber() # baseline correciton rubber band
stack.vector() # vector normalization
endmember = stack.vca(6) # number of endmembers  
endmember.show_stack(0.2, 0, 'auto') # advanced stack plot of endmembers 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m30AdeakA3242L2iGqNBf75gkIgpNdA1SWwgV3I2bq41q8oOZ0wiVkrRSw9-z-D3sbsLA6aBBZZuyQ01JkzdebzEoEuxcWmbzRj7EvnTRjSJDYYjyY1y5oiU3-G4iolIqAtjiEmqVtAzmzPMw2KOqIUxPQB-n9JoK4xbX24_Krql4TiwhU-2rTSyg_VF6wI8M?width=660&height=408&cropmode=none" />

```python
abundance = stack.abundance(endmember, 'NNLS') # estimation of concentrations by NNLS
abundance.set_resolution(0.01) # setting the step size resolution
abundance.show_profile('auto') # plotting spectral profile 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mLDJEXyCgxNqLUYQkDAD8qKZWBF8PGpvEz0oX-Iie6TdKMACBpc1Bl4EqZwSfIoLVNWnstFK_q36k5RY-lJHQtAyr8or_TOMetowWHjrdc6xipY8PSbeSSDrXeE7YoKTa0xVCqZraJ5ec-ySyYd01cdFi4k_XTq-etSZGq8uJQf5WQHoiV0IYjEmYWJ0izLd_?width=660&height=408&cropmode=none" />

#### Processing hyperspectral images by VCA and Clustering

comming soon. For now on, Check the manual.

#### Processing hyperspectral data of plastics by PCA and PLS-LDA

<p align="justify"> In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a> , there is a layers.csv.xz file for this example. The next processing steps computes unsupervised principal component analysis and double supervised partial least square + linear discriminant analysis. The scatter plots show the separation of the plastics: red, light_blue and blue are the most different ones.

```python
from spectramap import spmap as sp # reading spectramap library
sample = sp.hyper_object("sample") # creating hyper_object
sample.read_csv_xz("layers") # reading compressed csv of plastics profile
sample.remove(1800, 2700) # removing silent region
sample.keep(400, 3300) # keeping finger print and high wavenumber region
sample.gaussian(2) # appliying gaussian filter
sample.rubber() # rubber baseline correction
sample.kmeans(2) # kmeans 2 clusters
sample.rename_label([1, 2], ["first", "second"]) # rename labels
sub_label = sample.get_label()  # saving sub_labels
sub_label.name = "sub_label" # renaming the title of sub_label
sample.show_stack(0,0, "auto") # showing a stack
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m1LwvuTidoiBCa9enm-_OaENR3KfWSFkgyHGANrk2ii-uY9-vWwmWF5fjSM9dF-H9w-O0TOTfR3MWh8lmVOIN5iHwhb7UxcI6nzHHdAwLucGaXEKMuXVktgZ83eYljUHmCwzRhAfevqW63EWywF0WgBnvw_XRribVVREalh9XS9Eoe5IE9thY9hd_f3utuIvx?width=660&height=410&cropmode=none" />

```python
sample.kmeans(6) # kmeans clustering example for main_label
main_label = sample.get_label() # saving the main_label
main_label.name = "main_label" # renaming the title of the label
sample.show_stack(0,0, "auto") # showing the 6 components
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mYlaMwL3OhKuch2tv4XR_4q9o0EoGK6sn-I6PwKjtvkqJECcDAmz76rLSXdMw_v86tLSKltHM756ULIpkkpuOZO8s3ATOUkzsgzWakF7JShfxlBOUFp-vgexi33aID4Jj6NzxBVGZSUdFFPaAhTxJLg7oUJwkgapfoBpzg1mT89uTUC4dHqEXG5XTbLyLonD5?width=660&height=410&cropmode=none" />

```python
scores_pca, loadings_pca = sample.pca(3, False) # 3 components pca
scores_pca.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublabel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXLVSKKaTqp_chimU_qvxTGXiNIq0LegkAQmVHTrkjQ4nIXICALBisIk2bQNmMaGgVQGEkAdmoYQaKuH-bXVgDMDRGct9_9cW5ABHOVsx-aYmbXQKtcHYLZNwT8Kz7PFqmQkuZBkzM5dmjfjkK0N4AxTSl4OM2XRHbwaUqflvLzH-UWF7Ts4IpowpphDU2Zwx?width=660&height=426&cropmode=none" />

```python
scores_pls, loadings_pls = sample.pls_lda(3, False, 0.7) # 3 components pls-lda  and 70% training data
scores_pls.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublevel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXbKMwtXDVcngG68AW4hhLYbPvEsLHZ5Y4hdBuO-JxicuoSZegq-YbNgmNET-kuMC_dW2dqE-CBOQ05FSt29Yx8rT_eeFE_vPyXTxBczgY90b4gChRx3IR3iei0MpERo1yrD6t9hN1TCmGjEzakPU17w8rbMvQ3dbnzV1eBgP-Kol8jlraVtnZHKpTHhWtnf-?width=660&height=431&cropmode=none" />

<p align="justify"> The next figures shows the precision, recall (sensititivity), f1-score (weighted average of preceision) and support for the 6 components. Accuracy and average accuracy.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mj56vCKYH1LPHMS4if0mezHNO5YFzrZxxV626ocQLgfGeXu5eYJNR0fn8_Ap33DKZEURqAUuYvBXrNNm4Qg94-hd598m6cJdBg7w0NWwzNZVFcFuOoJhNUn3aF5T6ARXB_8h8qdodKjYpJhCVQDLvsfN53v5eM__BV_AKYIN2vmK8YuL9TLqqJD8fo6JLyd3V?width=474&height=227&cropmode=none" />

#### Raman wavenumber calibration by paracetaminol

<p align="justify"> Reproducibility and replicativity are fundamental parameters for Raman spectroscopy. One common way for wavenumber axis calibration is discussed in this section. The requirements are a paracetaminol sample (powder) and the calibration file (well-measured peaks) and a polynomial regression.

```python
from spectramap import spmap as sp # reading spectramap library
import pandas as pd
import numpy as np

### Paracetaminol 
path = 'para.csv' # path of the paracetaminol data
table = pd.read_table(path, sep = ',', header = None) # read data
table['label'] = "Para" # create label
table[['x', 'y']] = np.zeros((20,2)) # create fake positions
### Processing
mp = sp.hyper_object("Para") # creation of hyper object
mp.set_data(table.iloc[:,:len(table.columns)-3]) # reading the intensity 
mp.set_position(table[['x', 'y']]) # reading positions
mp.set_label(pd.Series(table['label'])) # reading labeling
copy = mp.copy() # copy data
peaks = copy.calibration_peaks(mp, 0.05) # finding peaks of para (next plot)
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mJ89jfrxDF_p5mLQFMbpHL0rsk58_6yoLwOI1_lMk9aT4wMLZyyGSP89l0QfnWipiAZiWDje_UxmuS6uB3LzDHvL7QmnO3ml2dCs4F6pafztjocJLADDlsXVo324KZM2ycI9FyMFLfqMdnumqRwIZpa5VI_uhFsJ8mvHFMUNsStw2OQ3tRZQq0XlQURRozrMN?width=660&height=379&cropmode=none" />

```python
copy.calibration_regression(peaks) # determining regression for the calibration
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mKTK3bLA_XkVa6pTbs_x7VFxmOsiLI9hmczm-77fwTnKfOYaF4UiP_BZAVnQZkJP2kDilM-dlCLBYnvncwh6eBfGJvdvt9rYxvghpaztSNHX7kCAGphEUJEQarK_OdaGNU11tAUEACOn1mavJrK-v8W-Jdbdg_367GmcO2CpxLpiDgT8PGtDNHQkPsGrs5kkT?width=660&height=379&cropmode=none" />

```python
mp.set_wavenumber(copy.get_wavenumber()) # set the new wavenumber to the original mp
mp.show(True) # show calibrated data
mp.add_peaks(0.1, 'r') # add peaks (not inline mode)
mp.save_data("", "calibration") # save calibrated data
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m8GE0Ho0DvmWdXyE0ZN_aqpVjWxdma-c_Ll_QD9R20Ke9B9dEinZR8er0Fjg3HMJRVcv_AYsqHNyWUKevvBeG6nj07EE9vIWDC2zr3uaIpvMcJKhnF_Rcu1zpxmymWqiCnNLlIpeTnxGnXwW734ZVQjb9mCEfniU-aXDgufoLvFEgQgWgTs4w7e3XOG6nWrur?width=660&height=324&cropmode=none" />

#### Processing hyperspectral images from biological tissue

comming soon. For now on, Check the manual.

#### Raman Intensity Calibration

The next lines show how to calibrate intensity axis in Ramam spectroscopy. It is required a standard spectrum of halogen lamp and the experimental measurement of the halogen lamp with the Raman instrument.

```python
from spectramap import spmap as sp # reading spectramap package
reference_trial = sp.hyper_object("reference") # creating reference hyper object
reference_trial.read_single_spc(path + "reference") # reading the referece data spectrum 
reference_trial.show(True) # showing the spectrum in the next plot
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mS7E9jF96MGDDSPRsp_PO7IJGDX_WVsDNkVU1snc2zNsT9mciLmQ331-BiAAR3_tEDd8a9AANrr-liAzAMbCmAWcAcHDuphckkyu6gCQjChHQy4zm4ISreOfS7CWz-MAwREfhfzkOuUAQG6kRtECnD5tG-rOkOYFHeB49J_93eF0uNo_QKW_Pt5HQmfRnqgI3?width=660&height=401&cropmode=none" />

Now the experimental spectrum.

```python
measured_trial = sp.hyper_object("measured") # creating hyper object
measured_trial.read_single_spc(path + "lamp") # reading data
measured_trial.keep(400, 1900) # keeping finger print region
measured_trial.show(True) # showing the plot as the next figures shows
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mgHiVbaq4PTIwV4-OUf0NhA2HVImJLqbgk_vKGOQ_k7afhEgLaPT0eXU3mCM_VlzELEWSoSE81W_OgM39E_F1gggRt-ILiOSH1jpPbCwtNlSCkjXScUzm0b--LubKANx-zqW5iyklz2f7-axSjnwDi5G-hQpc_21ycVoGtrUp7k_ZGpgETY4iCYSx1iQ5P6TT?width=660&height=401&cropmode=none" />

Reading the Raman sample. 

```python
sample = sp.hyper_object("sample") # declareting hyper object
sample.read_single_spc(path + "sample") # reading tissue data
sample.keep(400, 1900) # keeping finger print region
sample.show(True) # showing plot in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mfkYUhxDhwjI0Qel4lqN36GRZpNzyrqBalwxq35lhbz55CJej9k5x5_rtug0DQOEB_lHp7aB5tQfjVlQdw-VfrMUNZgyWSDt-bJq-BxHwB3g2HNtyMBW82iCWFeAW9I4QFAoLNx11gNVQjULOKj9N9EDAONR569qAUCy-qbkTbwyNIQuOk4GSVPD3Tx-IAuVO?width=660&height=401&cropmode=none" />>

Calibration of the Raman sample.

```python
sample.intensity_calibration(reference_trial, measured_trial) # intensity calibration function
sample.show(True) # showing the calibrated data in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mE8dFFtM-NvQ28s53Md-f9AnhF9rDh0gfn5EBnIin2LRh10eeJJ4cmUZMK4NFTEt7emCIowieDxA2dQ65G4qPtMyeBK0f0kDvtUg7kq7WEibWGL_Z5Wo3FqzSaNWdfnMFNn13dCdzPYSD9Fm17tPsywidPadvWBG4R142LRJ3YEimLDQo_wsPta4-aMh_zm-0?width=660&height=401&cropmode=none" />

## Working Team

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mHmwP0VTHTFAZZqccQFPVNHS5BTz5fg1mOqqbv_sizMho2majbgupRfZZYl_A1nYzQHXjI5W4T3vgJTKcksjWqe_axT4Ko2-QcEWLgz9YbPn-4qpdbnVFouUPrNza1YS6gV7Kx2_tb_rqxifev3NE-YJIp_vnawgNmEr2eEJcyIQ_Xl-VZNv7qIsh16kl4AKn?width=800&height=250&cropmode=none" />

## License

<p style="text-align: center;">
    MIT

<p align="justify">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

<p align="justify">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

<p align="justify">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## References

[1] F. Pedregosa, G. Varoquaux, and A. Gramfort, “Scikit-learn: Machine Learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825-- 2830, 2011.

[2] J. M. P. Nascimento and J. M. B. Dias, “Vertex component analysis: A fast algorithm to unmix hyperspectral data,” IEEE Transactions on Geoscience and Remote Sensing, vol. 43, no. 4, pp. 898–910, 2005, doi: 10.1109/TGRS.2005.844293.

[3] Z. M. Zhang, S. Chen, and Y. Z. Liang, “Baseline correction using adaptive iteratively reweighted penalized least squares,” Analyst, vol. 135, no. 5, pp. 1138–1146, 2010, doi: 10.1039/b922045c.

[4] L. McInnes, J. Healy, S. Astels, *hdbscan: Hierarchical density based clustering* In: Journal of Open Source Software, The Open Journal, volume 2, number 11. 2017


%package help
Summary:	Development documents and examples for spectramap
Provides:	python3-spectramap-doc
%description help
<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mndHVHqnpqVudLMiDZbho2Gi45g9sNnh1OzVkAY0MOwWH9Fm5keWXSrxCdfAum-K4yijPD3dSUTbxPHVeI9OHoa-EkMWfGn2d4XARNHqiGBVr25fCJUx0IWYZYgrDnW2nGtS0PuPDR1M-KvSmoSnC5tNuqH_KatsV68MFPr984_eUQWGk0GEjd5vtvpafqrGN?width=500&height=394&cropmode=none" />

## *SpectraMap (SpMap): Hyperspectral package for spectroscopists in Python*

<p align="justify">Hyperspectral imaging presents important applications in medicine, agriculture, pharmaceutical, space, food and many upcoming applications. The analysis of hyperspectral images requires advanced software. The upcoming developments related to fast hyperspectral imaging, automation and deep learning applications demand innovative software developments for analyzing hyperspectral data. The Figure 1 shows the hyperspectral imaging by a standard spectrometer instrument. More information regarding novel medical imaging is found in <a href= "https://advancesimaging.blogspot.com"> advances in imaging</a>.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mFDcOdm5472CEwuu-1aCTB20ZzS5wxLSO9bMZer1YgIQE2ekouGnfET2yuRF4jQbr9MoxPhw4FLX7ZbpBTF4vrYUnnMK3WP3_bQg7oyFdxTTYJmX7bSvu6k3gjZoWJL2wToqf52Ga3dopLGuaGXqxu4LHhQjot9_8yGPowpjisnI8vpPQ-7URYfgRNNH5oJ8S?width=660&height=371&cropmode=none" />

<p align="center">Figure 1 Raman Imaging Instrument

## Features

<p align="justify">The package includes standard tools such as reading, preprocessing, processing and visualization. The designing was focused on working hyperspectral images from Raman datasets. The package is extended to other spectroscopies as long as the data follows the type data structure.  Some features are shown by the next figures.

- <p align="justify">Preprocessing: some tool such as smoothing, removal of spikes, normalization and advanced baseline corrections are included. Figure 2 illustrates a mean and standard deviation of a tissue signature.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mplHFW8SLZNdnUpXqO6g4scKHgzE0F2HF-24bwCf5qTiZnX-S1WjV95CU_8PFufzzf2PeQewZTcuUyhAuFpOyMub5NCail6phkrkXjpldosPcdwTFOpAFhq8i0stGiEoUETcUKvnSMBFVp_R7bKl66-vU36itVQl5hdAntSP71hJ6qMXPbtDmnWacYo-YdBro?width=550&height=400&cropmode=none" />

<p align="center"> Figure 2 Visualization of tissue Raman signature

- <p align="justify">Processing: some tools such as unmixing, pca, pls, vca and hierarchical and kmeans clustering are included. Figure 3 displays application of clustering for locating microplastics on complex matrices.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4mCv3oo8wnXEf1lEJiK01NOUET8Sbt3yMIlkReJ3CsKhBV2yaVJ43ZLUFEhW0i7vGdLAagLDJAlomRYrutpLl2mbg8oxa5QPCmHjP2Ktz1dzoRtkroi8vJWCtA67hbCC6sElL0LvyyKhwao7ZhqE5TZQQA_EV-tl3qctMSOalqcREcFyTXiULJXz-FtlpEBZdD?width=660&height=574&cropmode=none" />
  
  <p align="center"> Figure 3 Segmentation by clustering: (a) clustered image, (b) unmixing image, (c) image and (d) mean clusters

- <p align="justify">Visualization: the next examples shows the pca scores of several biomolecules.
  
  <p align="center"><img src="https://bl6pap003files.storage.live.com/y4m2IgtZawTrfzKz36eecSGjwkXsjp5Zp5vognNGr-v-VeNX4nLSWbid62R28cW6_gqsxS5JJfNBeF2pzQArOPDEsb3BqTYyyzGo2qA5CuXZaLCER_a6PiwVubWL2B9GB0n6hgHXkSXouTZKLYEHPve_TwUVOtYN9inEhgU3wH5kazukHsbqeyRar4fdgNUg6Bz?width=450&height=501&cropmode=none" />

<p align="center">Figure 4 PCA scores

## Further upcoming developments:

- [] Graphical User Interface

- [] Supervised tools

- [] Deep learning - CNN

- [x] Optimizing speed and organizing main code 

- [x] More examples

## Installation

<p align="justify">The predetermined work interface is Python 3. The library comes with 8 different hyperspectral examples and analysis. A manual presents the relevant functions and examples <a href="https://github.com/spectramap/spectramap/tree/main/docs"> Manual</a>.
<p align="justify">Install the library and required packages: (admin rights):

```python
pip install spectramap
```

## Examples

#### Reading and processing a spc file

<p align = "justify"> In the <a href = "https://github.com/spectramap/spectramap/tree/main/examples"> examples </a>, there is ps.spc file for this example. The next lines show some basic tools. The function read_single_spc reads the path directory of the file.

```python
from spectramap import spmap as sp #reading spmap
pigm = sp.hyper_object('pigment') #creating the hyperobject
pigm.read_single_spc('pigment') #reading the spc file
pigm.keep(400, 1800) #Keeping fingerprint region
pigm_original = pigm.copy() #Copying hyperobject
pigm_original.set_label('original') #renaming hyperobject to original
pigm.set_label('processed') #renaming hyperobject to processed

pigm.rubber() #basic baseline correction rubber band
pigm.gol(15, 3, 0) #savitzky-golay filter
both = sp.hyper_object('result') #creating an auxilary hyperobject
both.concat([pigm_original, pigm]) #concatenating the original and processed data
both.show(False) #show both spectra 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m-pe9JbCoAZrJW-nBGBe4LGPLALTafIo3ZJPznScF9felxCXxVSLdA83DGLCKy_wlIj37r8UXBFWlgh1P0imLcFbEvveTJ46j4japWXklN8qttiM3X_y1Hid1YmANAq9EJS0crhltOFXjQt39S0ofUbHqQ0NxgF449sw8NUG92xTLjBq3B1niaUk7S4-qYg47?width=660&height=408&cropmode=none"  />

```python
both.show_stack(0.2, 0, 'auto') #advanced stack visualization 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mnECDWTSH0PtXtx4Gjc1Vv_Us0gv4T2e9U-bFuSOW6CBbHOGdyvsiCoFeGmYGvDVlsF52sTsKopv63xxTyaXOLQhZk5vd3twL1aAsz9xT-lFr9Qv1WT5aATpPjUOMlg6kV_42FPKbpfoIAdufFmKEWzziLok3n0ngefa2BIynR-UkqHKgpoj0ftX4d3B6EdUd?width=660&height=408&cropmode=none" />

<p align="center">Figure 6 Second visualization

#### Reading and processing a comma separated vector file with depth profiling

<p align="justify">In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a>, there is a layers.csv.xz file for this example. The next lines show some basic tools. The function read_csv requires the path directory of the file. The csv file must keep the structure of the <a href="https://github.com/spectramap/spectramap/tree/main/docs"> manual </a> (hyperspectral object). The example shows how to analise the data of spectroscopic profiles.

```python
from spectramap import spmap as sp # reading spectramap library
stack = sp.hyper_object('plastics') # creating the hyper_object
stack.read_csv_xz('layers') # reading compressed csv of plastics profile
stack.keep(500, 1800) # keeping fingerprint region
stack.rubber() # baseline correciton rubber band
stack.vector() # vector normalization
endmember = stack.vca(6) # number of endmembers  
endmember.show_stack(0.2, 0, 'auto') # advanced stack plot of endmembers 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m30AdeakA3242L2iGqNBf75gkIgpNdA1SWwgV3I2bq41q8oOZ0wiVkrRSw9-z-D3sbsLA6aBBZZuyQ01JkzdebzEoEuxcWmbzRj7EvnTRjSJDYYjyY1y5oiU3-G4iolIqAtjiEmqVtAzmzPMw2KOqIUxPQB-n9JoK4xbX24_Krql4TiwhU-2rTSyg_VF6wI8M?width=660&height=408&cropmode=none" />

```python
abundance = stack.abundance(endmember, 'NNLS') # estimation of concentrations by NNLS
abundance.set_resolution(0.01) # setting the step size resolution
abundance.show_profile('auto') # plotting spectral profile 
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mLDJEXyCgxNqLUYQkDAD8qKZWBF8PGpvEz0oX-Iie6TdKMACBpc1Bl4EqZwSfIoLVNWnstFK_q36k5RY-lJHQtAyr8or_TOMetowWHjrdc6xipY8PSbeSSDrXeE7YoKTa0xVCqZraJ5ec-ySyYd01cdFi4k_XTq-etSZGq8uJQf5WQHoiV0IYjEmYWJ0izLd_?width=660&height=408&cropmode=none" />

#### Processing hyperspectral images by VCA and Clustering

comming soon. For now on, Check the manual.

#### Processing hyperspectral data of plastics by PCA and PLS-LDA

<p align="justify"> In the <a href="https://github.com/spectramap/spectramap/tree/main/examples"> example</a> , there is a layers.csv.xz file for this example. The next processing steps computes unsupervised principal component analysis and double supervised partial least square + linear discriminant analysis. The scatter plots show the separation of the plastics: red, light_blue and blue are the most different ones.

```python
from spectramap import spmap as sp # reading spectramap library
sample = sp.hyper_object("sample") # creating hyper_object
sample.read_csv_xz("layers") # reading compressed csv of plastics profile
sample.remove(1800, 2700) # removing silent region
sample.keep(400, 3300) # keeping finger print and high wavenumber region
sample.gaussian(2) # appliying gaussian filter
sample.rubber() # rubber baseline correction
sample.kmeans(2) # kmeans 2 clusters
sample.rename_label([1, 2], ["first", "second"]) # rename labels
sub_label = sample.get_label()  # saving sub_labels
sub_label.name = "sub_label" # renaming the title of sub_label
sample.show_stack(0,0, "auto") # showing a stack
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m1LwvuTidoiBCa9enm-_OaENR3KfWSFkgyHGANrk2ii-uY9-vWwmWF5fjSM9dF-H9w-O0TOTfR3MWh8lmVOIN5iHwhb7UxcI6nzHHdAwLucGaXEKMuXVktgZ83eYljUHmCwzRhAfevqW63EWywF0WgBnvw_XRribVVREalh9XS9Eoe5IE9thY9hd_f3utuIvx?width=660&height=410&cropmode=none" />

```python
sample.kmeans(6) # kmeans clustering example for main_label
main_label = sample.get_label() # saving the main_label
main_label.name = "main_label" # renaming the title of the label
sample.show_stack(0,0, "auto") # showing the 6 components
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mYlaMwL3OhKuch2tv4XR_4q9o0EoGK6sn-I6PwKjtvkqJECcDAmz76rLSXdMw_v86tLSKltHM756ULIpkkpuOZO8s3ATOUkzsgzWakF7JShfxlBOUFp-vgexi33aID4Jj6NzxBVGZSUdFFPaAhTxJLg7oUJwkgapfoBpzg1mT89uTUC4dHqEXG5XTbLyLonD5?width=660&height=410&cropmode=none" />

```python
scores_pca, loadings_pca = sample.pca(3, False) # 3 components pca
scores_pca.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublabel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXLVSKKaTqp_chimU_qvxTGXiNIq0LegkAQmVHTrkjQ4nIXICALBisIk2bQNmMaGgVQGEkAdmoYQaKuH-bXVgDMDRGct9_9cW5ABHOVsx-aYmbXQKtcHYLZNwT8Kz7PFqmQkuZBkzM5dmjfjkK0N4AxTSl4OM2XRHbwaUqflvLzH-UWF7Ts4IpowpphDU2Zwx?width=660&height=426&cropmode=none" />

```python
scores_pls, loadings_pls = sample.pls_lda(3, False, 0.7) # 3 components pls-lda  and 70% training data
scores_pls.show_scatter("auto", main_label, sub_label, 15) # showing scatter with sublevel
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mXbKMwtXDVcngG68AW4hhLYbPvEsLHZ5Y4hdBuO-JxicuoSZegq-YbNgmNET-kuMC_dW2dqE-CBOQ05FSt29Yx8rT_eeFE_vPyXTxBczgY90b4gChRx3IR3iei0MpERo1yrD6t9hN1TCmGjEzakPU17w8rbMvQ3dbnzV1eBgP-Kol8jlraVtnZHKpTHhWtnf-?width=660&height=431&cropmode=none" />

<p align="justify"> The next figures shows the precision, recall (sensititivity), f1-score (weighted average of preceision) and support for the 6 components. Accuracy and average accuracy.

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mj56vCKYH1LPHMS4if0mezHNO5YFzrZxxV626ocQLgfGeXu5eYJNR0fn8_Ap33DKZEURqAUuYvBXrNNm4Qg94-hd598m6cJdBg7w0NWwzNZVFcFuOoJhNUn3aF5T6ARXB_8h8qdodKjYpJhCVQDLvsfN53v5eM__BV_AKYIN2vmK8YuL9TLqqJD8fo6JLyd3V?width=474&height=227&cropmode=none" />

#### Raman wavenumber calibration by paracetaminol

<p align="justify"> Reproducibility and replicativity are fundamental parameters for Raman spectroscopy. One common way for wavenumber axis calibration is discussed in this section. The requirements are a paracetaminol sample (powder) and the calibration file (well-measured peaks) and a polynomial regression.

```python
from spectramap import spmap as sp # reading spectramap library
import pandas as pd
import numpy as np

### Paracetaminol 
path = 'para.csv' # path of the paracetaminol data
table = pd.read_table(path, sep = ',', header = None) # read data
table['label'] = "Para" # create label
table[['x', 'y']] = np.zeros((20,2)) # create fake positions
### Processing
mp = sp.hyper_object("Para") # creation of hyper object
mp.set_data(table.iloc[:,:len(table.columns)-3]) # reading the intensity 
mp.set_position(table[['x', 'y']]) # reading positions
mp.set_label(pd.Series(table['label'])) # reading labeling
copy = mp.copy() # copy data
peaks = copy.calibration_peaks(mp, 0.05) # finding peaks of para (next plot)
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mJ89jfrxDF_p5mLQFMbpHL0rsk58_6yoLwOI1_lMk9aT4wMLZyyGSP89l0QfnWipiAZiWDje_UxmuS6uB3LzDHvL7QmnO3ml2dCs4F6pafztjocJLADDlsXVo324KZM2ycI9FyMFLfqMdnumqRwIZpa5VI_uhFsJ8mvHFMUNsStw2OQ3tRZQq0XlQURRozrMN?width=660&height=379&cropmode=none" />

```python
copy.calibration_regression(peaks) # determining regression for the calibration
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mKTK3bLA_XkVa6pTbs_x7VFxmOsiLI9hmczm-77fwTnKfOYaF4UiP_BZAVnQZkJP2kDilM-dlCLBYnvncwh6eBfGJvdvt9rYxvghpaztSNHX7kCAGphEUJEQarK_OdaGNU11tAUEACOn1mavJrK-v8W-Jdbdg_367GmcO2CpxLpiDgT8PGtDNHQkPsGrs5kkT?width=660&height=379&cropmode=none" />

```python
mp.set_wavenumber(copy.get_wavenumber()) # set the new wavenumber to the original mp
mp.show(True) # show calibrated data
mp.add_peaks(0.1, 'r') # add peaks (not inline mode)
mp.save_data("", "calibration") # save calibrated data
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4m8GE0Ho0DvmWdXyE0ZN_aqpVjWxdma-c_Ll_QD9R20Ke9B9dEinZR8er0Fjg3HMJRVcv_AYsqHNyWUKevvBeG6nj07EE9vIWDC2zr3uaIpvMcJKhnF_Rcu1zpxmymWqiCnNLlIpeTnxGnXwW734ZVQjb9mCEfniU-aXDgufoLvFEgQgWgTs4w7e3XOG6nWrur?width=660&height=324&cropmode=none" />

#### Processing hyperspectral images from biological tissue

comming soon. For now on, Check the manual.

#### Raman Intensity Calibration

The next lines show how to calibrate intensity axis in Ramam spectroscopy. It is required a standard spectrum of halogen lamp and the experimental measurement of the halogen lamp with the Raman instrument.

```python
from spectramap import spmap as sp # reading spectramap package
reference_trial = sp.hyper_object("reference") # creating reference hyper object
reference_trial.read_single_spc(path + "reference") # reading the referece data spectrum 
reference_trial.show(True) # showing the spectrum in the next plot
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mS7E9jF96MGDDSPRsp_PO7IJGDX_WVsDNkVU1snc2zNsT9mciLmQ331-BiAAR3_tEDd8a9AANrr-liAzAMbCmAWcAcHDuphckkyu6gCQjChHQy4zm4ISreOfS7CWz-MAwREfhfzkOuUAQG6kRtECnD5tG-rOkOYFHeB49J_93eF0uNo_QKW_Pt5HQmfRnqgI3?width=660&height=401&cropmode=none" />

Now the experimental spectrum.

```python
measured_trial = sp.hyper_object("measured") # creating hyper object
measured_trial.read_single_spc(path + "lamp") # reading data
measured_trial.keep(400, 1900) # keeping finger print region
measured_trial.show(True) # showing the plot as the next figures shows
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mgHiVbaq4PTIwV4-OUf0NhA2HVImJLqbgk_vKGOQ_k7afhEgLaPT0eXU3mCM_VlzELEWSoSE81W_OgM39E_F1gggRt-ILiOSH1jpPbCwtNlSCkjXScUzm0b--LubKANx-zqW5iyklz2f7-axSjnwDi5G-hQpc_21ycVoGtrUp7k_ZGpgETY4iCYSx1iQ5P6TT?width=660&height=401&cropmode=none" />

Reading the Raman sample. 

```python
sample = sp.hyper_object("sample") # declareting hyper object
sample.read_single_spc(path + "sample") # reading tissue data
sample.keep(400, 1900) # keeping finger print region
sample.show(True) # showing plot in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mfkYUhxDhwjI0Qel4lqN36GRZpNzyrqBalwxq35lhbz55CJej9k5x5_rtug0DQOEB_lHp7aB5tQfjVlQdw-VfrMUNZgyWSDt-bJq-BxHwB3g2HNtyMBW82iCWFeAW9I4QFAoLNx11gNVQjULOKj9N9EDAONR569qAUCy-qbkTbwyNIQuOk4GSVPD3Tx-IAuVO?width=660&height=401&cropmode=none" />>

Calibration of the Raman sample.

```python
sample.intensity_calibration(reference_trial, measured_trial) # intensity calibration function
sample.show(True) # showing the calibrated data in the next figure
```

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mE8dFFtM-NvQ28s53Md-f9AnhF9rDh0gfn5EBnIin2LRh10eeJJ4cmUZMK4NFTEt7emCIowieDxA2dQ65G4qPtMyeBK0f0kDvtUg7kq7WEibWGL_Z5Wo3FqzSaNWdfnMFNn13dCdzPYSD9Fm17tPsywidPadvWBG4R142LRJ3YEimLDQo_wsPta4-aMh_zm-0?width=660&height=401&cropmode=none" />

## Working Team

<p align="center"><img src="https://bl6pap003files.storage.live.com/y4mHmwP0VTHTFAZZqccQFPVNHS5BTz5fg1mOqqbv_sizMho2majbgupRfZZYl_A1nYzQHXjI5W4T3vgJTKcksjWqe_axT4Ko2-QcEWLgz9YbPn-4qpdbnVFouUPrNza1YS6gV7Kx2_tb_rqxifev3NE-YJIp_vnawgNmEr2eEJcyIQ_Xl-VZNv7qIsh16kl4AKn?width=800&height=250&cropmode=none" />

## License

<p style="text-align: center;">
    MIT

<p align="justify">Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

<p align="justify">The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

<p align="justify">THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

## References

[1] F. Pedregosa, G. Varoquaux, and A. Gramfort, “Scikit-learn: Machine Learning in Python,” Journal of Machine Learning Research, vol. 12, pp. 2825-- 2830, 2011.

[2] J. M. P. Nascimento and J. M. B. Dias, “Vertex component analysis: A fast algorithm to unmix hyperspectral data,” IEEE Transactions on Geoscience and Remote Sensing, vol. 43, no. 4, pp. 898–910, 2005, doi: 10.1109/TGRS.2005.844293.

[3] Z. M. Zhang, S. Chen, and Y. Z. Liang, “Baseline correction using adaptive iteratively reweighted penalized least squares,” Analyst, vol. 135, no. 5, pp. 1138–1146, 2010, doi: 10.1039/b922045c.

[4] L. McInnes, J. Healy, S. Astels, *hdbscan: Hierarchical density based clustering* In: Journal of Open Source Software, The Open Journal, volume 2, number 11. 2017


%prep
%autosetup -n spectramap-0.5.3

%build
%py3_build

%install
%py3_install
install -d -m755 %{buildroot}/%{_pkgdocdir}
if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi
if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi
if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi
if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi
pushd %{buildroot}
if [ -d usr/lib ]; then
	find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/lib64 ]; then
	find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/bin ]; then
	find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst
fi
if [ -d usr/sbin ]; then
	find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst
fi
touch doclist.lst
if [ -d usr/share/man ]; then
	find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst
fi
popd
mv %{buildroot}/filelist.lst .
mv %{buildroot}/doclist.lst .

%files -n python3-spectramap -f filelist.lst
%dir %{python3_sitelib}/*

%files help -f doclist.lst
%{_docdir}/*

%changelog
* Mon May 15 2023 Python_Bot <Python_Bot@openeuler.org> - 0.5.3-1
- Package Spec generated