{"id":19267111,"url":"https://github.com/mljs/global-spectral-deconvolution","last_synced_at":"2025-10-19T22:51:07.014Z","repository":{"id":3493064,"uuid":"41678509","full_name":"mljs/global-spectral-deconvolution","owner":"mljs","description":"Global Spectra Deconvolution + Peak optimizer","archived":false,"fork":false,"pushed_at":"2024-10-02T10:21:06.000Z","size":19217,"stargazers_count":11,"open_issues_count":2,"forks_count":8,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-12T00:47:58.702Z","etag":null,"topics":["hacktoberfest"],"latest_commit_sha":null,"homepage":"http://mljs.github.io/global-spectral-deconvolution/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mljs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-08-31T14:00:13.000Z","updated_at":"2025-04-08T08:37:44.000Z","dependencies_parsed_at":"2024-03-15T07:01:32.772Z","dependency_job_id":null,"html_url":"https://github.com/mljs/global-spectral-deconvolution","commit_stats":{"total_commits":276,"total_committers":12,"mean_commits":23.0,"dds":0.5760869565217391,"last_synced_commit":"33e05192c1b8cb18918290bb45e28e4ba272fe1e"},"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fglobal-spectral-deconvolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fglobal-spectral-deconvolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fglobal-spectral-deconvolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mljs%2Fglobal-spectral-deconvolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mljs","download_url":"https://codeload.github.com/mljs/global-spectral-deconvolution/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250120101,"owners_count":21378136,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["hacktoberfest"],"created_at":"2024-11-09T20:10:30.018Z","updated_at":"2025-10-19T22:51:07.007Z","avatar_url":"https://github.com/mljs.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ml-gsd\n\n[![NPM version](https://img.shields.io/npm/v/ml-gsd.svg)](https://www.npmjs.com/package/ml-gsd)\n[![npm download](https://img.shields.io/npm/dm/ml-gsd.svg)](https://www.npmjs.com/package/ml-gsd)\n[![test coverage](https://img.shields.io/codecov/c/github/mljs/global-spectral-deconvolution.svg)](https://codecov.io/gh/mljs/global-spectral-deconvolution)\n[![license](https://img.shields.io/npm/l/ml-gsd.svg)](https://github.com/mljs/global-spectral-deconvolution/blob/main/LICENSE)\n\nGlobal spectral deconvolution and peak optimizer.\n\n## [API documentation](http://mljs.github.io/global-spectral-deconvolution/)\n\n`gsd`is using an algorithm that is searching for inflection points to determine the position and width of peaks. The width is defined as the distance between the 2 inflection points. Depending the shape of the peak this width may differ from 'fwhm' (Full Width Half Maximum).\n\nPreprocessing of the data involves the following parameters\n\n- `maxCriteria`: search either for maxima or minima. We will invert the data and the results if searching for a minima\n- `noiseLevel`: specifies the noise level. All the peaks bellow this value (or above in case of maxCriteria=false) are ignored. By default the noiseLevel will be set to the median + 3 x sd. This is a good value when not too many peaks are present in the spectrum.\n- `sgOptions`: Savitzky-Golay filter that is used to smooth the data for the calculation of the derivatives\n- `smoothY`: If this value is true the SG filter is not only applied during the calculation of the derivatives but also on the original data\n\n### gsd({x:[], y:[]}, options)\n\nThe result of GSD is an array of GSDPeak:\n\n- x: position of the peak on the x axis\n- y: the height of the peak\n- width: width at the level of the inflection points\n- index: index in the 'x' and 'y' array of the peak\n- ddY: second derivative value at the level of the peak. Allows to identify 'large' peaks\n- inflectionPoints: an object with the position of the inflection points\n  - from: { x, index }\n  - to: { x, index }\n\n### Parameters\n\n#### minMaxRatio=0.00025 (0-1)\n\nThreshold to determine if a given peak should be considered as a noise, bases on its relative height compared to the highest peak.\n\n#### maxCriteria=true [true||false]\n\nPeaks are local maximum(true) or minimum(false)\n\n#### smoothY=true [true||false]\n\nSelect the peak intensities from a smoothed version of the independent variables?\n\n#### realTopDetection=false [true||false]\n\nUse a quadratic optimizations with the peak and its 3 closest neighbors to determine the true x,y values of the peak?\n\n#### sgOptions={windowSize: 5, polynomial: 3}\n\nSavitzky-Golay parameters. windowSize should be odd; polynomial is the degree of the polynomial to use in the approximations. It should be bigger than 2.\n\n### Post methods\n\n#### GSD.broadenPeaks(peakList, {factor=2, overlap=false})\n\nWe enlarge the peaks and add the properties from and to.\nBy default we enlarge of a factor 2 and we don't allow overlap.\n\n#### GSD.optimizePeaks(data, peakList, options)\n\nOptimize the position (x), max intensity (y), full width at half maximum (fwhm) and the ratio of gaussian contribution (mu) if it's required. It currently supports three kind of shapes: gaussian, lorentzian and pseudovoigt\n\n## Example\n\n```js\nimport { IsotopicDistribution } from 'mf-global';\nimport { gsd, optimizePeaks } from 'ml-gsd';\n\n// generate a sample spectrum of the form {x:[], y:[]}\nconst data = new IsotopicDistribution('C').getGaussian();\n\nlet peaks = gsd(data, {\n  minMaxRatio: 0.00025, // Threshold to determine if a given peak should be considered as a noise\n  realTopDetection: true, // Correction of the x and y coordinates using a quadratic optimizations\n  maxCriteria: true, // Are we looking for maxima or minima\n  smoothY: false, // should we smooth the spectra and return smoothed peaks ? Default false.\n  sgOptions: { windowSize: 7, polynomial: 3 }, // Savitzky-Golay smoothing parameters for first and second derivative calculation\n});\nconsole.log(peaks);\n/*\n  array of peaks containing {x, y, width, ddY, inflectionPoints}\n  - width = distance between inflection points\n  - ddY = second derivative on the top of the peak\n */\n\nlet optimized = optimizePeaks(data, peaks);\nconsole.log(optimized);\n/*\n[\n  {\n    x: 11.99999999960885,\n    y: 0.9892695646808637,\n    shape: { kind: 'gaussian' },\n    fwhm: 0.010000209455943584,\n    width: 0.008493395898379276\n  },\n  {\n    x: 13.003354834590702,\n    y: 0.010699637653261198,\n    shape: { kind: 'gaussian' },\n    fwhm: 0.010000226962299321,\n    width: 0.008493410766908847\n  }\n]\n*/\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fglobal-spectral-deconvolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmljs%2Fglobal-spectral-deconvolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmljs%2Fglobal-spectral-deconvolution/lists"}