Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve 1D line broadening filter #3260

Open
wants to merge 26 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3d0ad4f
fix: typo in the type name
jobo322 Oct 7, 2024
7a85c70
fix: add shape to manual peak added
jobo322 Oct 7, 2024
8c3947b
fix: apodization 1D options
jobo322 Oct 7, 2024
16b3b61
chore: correct use of generalized lorentzian
jobo322 Oct 10, 2024
a7617a0
chore: update format apodization
jobo322 Oct 13, 2024
1654dd9
chore: update nmr deps
jobo322 Oct 13, 2024
be5f47c
chore: include gamma
jobo322 Oct 13, 2024
1dac769
fix: split back apodization 2D into dimensions
jobo322 Oct 22, 2024
fce8ae1
chore: force nmr-load-save v13.0.2
jobo322 Oct 22, 2024
8984793
chore: fix prettier
hamed-musallam Oct 23, 2024
235764d
chore: work in progress to new splitted FilterManages
jobo322 Oct 31, 2024
2f0814e
Update package.json
targos Nov 1, 2024
25636bf
chore: use pre release nmr-processing
jobo322 Nov 1, 2024
cb2736e
chore: work in progress refactor
jobo322 Nov 1, 2024
0372969
chore: adapt defaultApodizationOptions but there is a bug in nmr-proc…
jobo322 Nov 4, 2024
5aad9a6
chore: refactor to use both Filters1DManager n Filters2DManager
jobo322 Nov 4, 2024
cb306f8
chore: update dependencies
hamed-musallam Oct 24, 2024
efaaa10
refactor: add auto highlights the entire content functionality to num…
hamed-musallam Oct 25, 2024
ad17bd6
refactor: improve editable input field component
hamed-musallam Oct 28, 2024
9edd5e7
style: specify the space between action buttons (#3280)
hamed-musallam Oct 30, 2024
d5451af
chore: missing typing corrections
jobo322 Nov 4, 2024
5f89adf
chore: refactor FiltersActions
jobo322 Nov 5, 2024
6d69745
refactor: adaptation to Filters with types
jobo322 Nov 5, 2024
f78afeb
chore: pass draft data directly to the filter
jobo322 Nov 5, 2024
0a8d4be
refactor: adapt to typed Filters
jobo322 Nov 5, 2024
dba0fc6
chore: update pre-release nmr-processing
jobo322 Nov 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
107 changes: 39 additions & 68 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
"ml-tree-similarity": "^2.2.0",
"multiplet-analysis": "^2.1.2",
"nmr-correlation": "^2.3.3",
"nmr-load-save": "^1.2.0",
"nmr-processing": "^12.12.3",
"nmr-load-save": "^1.2.2",
"nmr-processing": "^13.0.2",
"nmredata": "^0.9.11",
"numeral": "^2.0.6",
"openchemlib": "^8.16.0",
Expand Down Expand Up @@ -150,4 +150,4 @@
"vite": "^5.4.9",
"vitest": "^2.1.3"
}
}
}
targos marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 6 additions & 6 deletions src/component/1d/ApodizationLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,22 +58,22 @@ function ApodizationLine() {
apply: false,
compose: {
length,
shapes: [
{
shapes: {
lorentzToGauss: {
start: 0,
shape: {
kind: 'lorentzToGauss',
options: {
length,
dw,
exponentialHz:
lineBroadening:
gaussBroadening > 0 ? lineBroadening : -lineBroadening,
gaussianHz: gaussBroadening,
center: lineBroadeningCenter,
gaussBroadening,
lineBroadeningCenter,
},
},
},
],
},
},
},
);
Expand Down
18 changes: 17 additions & 1 deletion src/component/modal/EditPeakShapeModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ function getKindDefaultValues(kind: Kind) {
return {
kind,
fwhm: 500,
...(kind === 'pseudoVoigt' && { mu: 0.5 }),
...(kind === 'pseudoVoigt'
? { mu: 0.5 }
: kind === 'generalizedLorentzian' && { gamma: 0.5 }),
};
}
function getValues(peak: Peak1D, kind: Kind): Shape {
Expand Down Expand Up @@ -61,6 +63,10 @@ const KINDS: Array<{ label: string; value: Kind }> = [
value: 'pseudoVoigt',
label: 'PseudoVoigt',
},
{
value: 'generalizedLorentzian',
label: 'Generalized Lorentzian',
},
];

const labelStyle: LabelStyle = {
Expand Down Expand Up @@ -148,6 +154,16 @@ function InnerEditPeakShapeModal(props: Required<EditPeakShapeModalProps>) {
<NumberInput2Controller min={0} control={control} name="mu" />
</Label>
)}
{kind === 'generalizedLorentzian' && (
<Label title="Gamma:" style={labelStyle}>
<NumberInput2Controller
min={-1}
max={2}
control={control}
name="gamma"
/>
</Label>
)}
</>
</DialogBody>
<DialogFooter>
Expand Down
6 changes: 6 additions & 0 deletions src/component/panels/PeaksPanel/PeaksPreferences.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ const formatFields: NucleusPreferenceField[] = [
checkFieldName: 'mu.show',
formatFieldName: 'mu.format',
},
{
id: 11,
label: 'gamma :',
checkFieldName: 'gamma.show',
formatFieldName: 'gamma.format',
},
{
id: 9,
label: 'Delete action :',
Expand Down
17 changes: 17 additions & 0 deletions src/component/panels/PeaksPanel/PeaksTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,23 @@ function PeaksTable({ activeTab, data, info }: PeaksTableProps) {
return '';
},
},
{
showWhen: 'gamma.show',
index: 9,
Header: 'gamma',
accessor: (row) =>
(row?.shape?.kind === 'generalizedLorentzian' && row?.shape?.gamma) ||
'',
Cell: ({ row }) => {
const gamma =
row.original?.shape?.kind === 'generalizedLorentzian' &&
row.original?.shape?.gamma;
if (gamma) {
return formatNumber(gamma, peaksPreferences.gamma.format);
}
return '';
},
},
{
showWhen: 'showEditPeakShapeAction',
...createActionColumn<PeakRecord>({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { yupResolver } from '@hookform/resolvers/yup';
import type {
ApodizationOptions as BaseApodizationOptions,
Filter,
} from 'nmr-processing';
import type { Filter } from 'nmr-processing';
import { useCallback, useEffect, useRef } from 'react';
import { useForm } from 'react-hook-form';
import * as Yup from 'yup';

import type { Apodization1DOptions as BaseApodizationOptions } from '../../../../../data/constants/DefaultApodizationOptions.js';
import { defaultApodizationOptions } from '../../../../../data/constants/DefaultApodizationOptions.js';
import { useDispatch } from '../../../../context/DispatchContext.js';
import { useSyncedFilterOptions } from '../../../../context/FilterSyncOptionsContext.js';
Expand Down
10 changes: 4 additions & 6 deletions src/component/reducer/Reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import { produce, original } from 'immer';
import type { CorrelationData } from 'nmr-correlation';
import { buildCorrelationData } from 'nmr-correlation';
import type { Spectrum, ViewState } from 'nmr-load-save';
import type {
ApodizationOptions,
BaselineCorrectionZone,
} from 'nmr-processing';
import type { BaselineCorrectionZone } from 'nmr-processing';
import type { Reducer } from 'react';

import type { Apodization1DOptions } from '../../data/constants/DefaultApodizationOptions.js';
import type { StateMoleculeExtended } from '../../data/molecules/Molecule.js';
import type { UsedColors } from '../../types/UsedColors.js';
import type { Action } from '../context/DispatchContext.js';
Expand Down Expand Up @@ -169,7 +167,7 @@ export const getInitialState = (): State => ({
zones: [],
livePreview: true,
},
apodizationOptions: {} as ApodizationOptions,
apodizationOptions: {} as Apodization1DOptions,
twoDimensionPhaseCorrection: {
activeTraceDirection: 'horizontal',
addTracesToBothDirections: true,
Expand Down Expand Up @@ -347,7 +345,7 @@ export interface State {
options: any;
livePreview: boolean;
};
apodizationOptions: ApodizationOptions;
apodizationOptions: Apodization1DOptions;
/**
* pivot point for manual phase correction
* @default {value:0,index:0}
Expand Down
10 changes: 4 additions & 6 deletions src/component/reducer/actions/FiltersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ import type {
Spectrum1D,
Spectrum2D,
} from 'nmr-load-save';
import type {
ApodizationOptions,
BaselineCorrectionOptions,
} from 'nmr-processing';
import type { BaselineCorrectionOptions } from 'nmr-processing';
import {
Filters,
FiltersManager,
getBaselineZonesByDietrich,
} from 'nmr-processing';

import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions.js';
import type { Apodization1DOptions } from '../../../data/constants/DefaultApodizationOptions.js';
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D/index.js';
import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection.js';
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D/index.js';
Expand Down Expand Up @@ -84,11 +82,11 @@ type ShiftSpectrumOptions = ShiftOneDimension | ShiftTwoDimensions;
type ShiftSpectrumAction = ActionType<'SHIFT_SPECTRUM', ShiftSpectrumOptions>;
type ApodizationFilterAction = ActionType<
'APPLY_APODIZATION_FILTER',
{ options: ApodizationOptions }
{ options: Apodization1DOptions }
>;
type ApodizationFilterLiveAction = ActionType<
'CALCULATE_APODIZATION_FILTER',
{ options: ApodizationOptions; livePreview: boolean }
{ options: Apodization1DOptions; livePreview: boolean }
>;
type ZeroFillingFilterAction = ActionType<
'APPLY_ZERO_FILLING_FILTER',
Expand Down
Loading
Loading