Skip to content

Commit

Permalink
fix: apodization 1D options
Browse files Browse the repository at this point in the history
  • Loading branch information
jobo322 committed Oct 13, 2024
1 parent bf15dfe commit 5e6622b
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
6 changes: 3 additions & 3 deletions src/component/1d/ApodizationLine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ function ApodizationLine() {
options: {
length,
dw,
exponentialHz:
lineBroadening:
gaussBroadening > 0 ? lineBroadening : -lineBroadening,
gaussianHz: gaussBroadening,
center: lineBroadeningCenter,
gaussBroadening,
lineBroadeningCenter,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { yupResolver } from '@hookform/resolvers/yup';
import {
ApodizationOptions as BaseApodizationOptions,
Filter,
} from 'nmr-processing';
import { Filter } from 'nmr-processing';
import { useCallback, useEffect, useRef } from 'react';
import { useForm } from 'react-hook-form';
import * as Yup from 'yup';

import { defaultApodizationOptions } from '../../../../../data/constants/DefaultApodizationOptions';
import {
defaultApodizationOptions,
Apodization1DOptions as BaseApodizationOptions,
} from '../../../../../data/constants/DefaultApodizationOptions';
import { useDispatch } from '../../../../context/DispatchContext';
import { useSyncedFilterOptions } from '../../../../context/FilterSyncOptionsContext';

Expand Down
7 changes: 4 additions & 3 deletions src/component/reducer/Reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import { WebSource as Source } from 'filelist-utils';
import { Draft, produce, original } from 'immer';
import { buildCorrelationData, CorrelationData } from 'nmr-correlation';
import { Spectrum, ViewState } from 'nmr-load-save';
import { ApodizationOptions, BaselineCorrectionZone } from 'nmr-processing';
import { BaselineCorrectionZone } from 'nmr-processing';
import { Reducer } from 'react';

import { Apodization1DOptions } from '../../data/constants/DefaultApodizationOptions';
import { StateMoleculeExtended } from '../../data/molecules/Molecule';
import { UsedColors } from '../../types/UsedColors';
import { Action } from '../context/DispatchContext';
Expand Down Expand Up @@ -165,7 +166,7 @@ export const getInitialState = (): State => ({
zones: [],
livePreview: true,
},
apodizationOptions: {} as ApodizationOptions,
apodizationOptions: {} as Apodization1DOptions,
twoDimensionPhaseCorrection: {
activeTraceDirection: 'horizontal',
addTracesToBothDirections: true,
Expand Down Expand Up @@ -343,7 +344,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: 6 additions & 4 deletions src/component/reducer/actions/FiltersActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import {
Filters,
FiltersManager,
BaselineCorrectionOptions,
ApodizationOptions,
getBaselineZonesByDietrich,
} from 'nmr-processing';

import { defaultApodizationOptions } from '../../../data/constants/DefaultApodizationOptions';
import {
Apodization1DOptions,
defaultApodizationOptions,
} from '../../../data/constants/DefaultApodizationOptions';
import { isSpectrum1D } from '../../../data/data1d/Spectrum1D';
import { isSpectrum2D } from '../../../data/data2d/Spectrum2D';
import { getProjection } from '../../../data/data2d/Spectrum2D/getMissingProjection';
Expand Down Expand Up @@ -78,11 +80,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
8 changes: 6 additions & 2 deletions src/data/constants/DefaultApodizationOptions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { ApodizationOptions } from 'nmr-processing';
export interface Apodization1DOptions {
lineBroadening: number;
gaussBroadening: number;
lineBroadeningCenter: number;
}

export const defaultApodizationOptions: ApodizationOptions = {
export const defaultApodizationOptions: Apodization1DOptions = {
lineBroadening: 1,
gaussBroadening: 0,
lineBroadeningCenter: 0,
Expand Down

0 comments on commit 5e6622b

Please sign in to comment.