Skip to content

Commit

Permalink
Fix EEG Browser strict mode
Browse files Browse the repository at this point in the history
  • Loading branch information
laemtl committed Nov 14, 2023
1 parent 540c4d1 commit 026981b
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const SeriesCursor = (
};

const createIndices = R.memoizeWith(
R.identity,
(s: string) => s,
(array) => array.map((_, i) => i)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import {
DEFAULT_MAX_CHANNELS,
CHANNEL_DISPLAY_OPTIONS,
SIGNAL_UNIT,
Vector2,
DEFAULT_TIME_INTERVAL,
STATIC_SERIES_RANGE,
DEFAULT_VIEWER_HEIGHT,
Expand Down Expand Up @@ -814,7 +813,7 @@ const SeriesRenderer: FunctionComponent<CProps> = ({
*
* @param v
*/
const updateTimeSelectionCallback = useCallback((v: Vector2) => {
const updateTimeSelectionCallback = useCallback((v: vec2) => {
document.addEventListener('mousemove', onMouseMove);
document.addEventListener('mouseup', onMouseUp);
R.compose(dragStart, R.nth(0))(v);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export type Action = BoundsAction | { type: 'UPDATE_VIEWED_CHUNKS' };
export const createDragBoundsEpic = () => (
action$: Observable<any>,
state$: Observable<any>,
): Observable<Action> => {
): Observable<any> => {
const startDrag$ = action$.pipe(
ofType(START_DRAG_INTERVAL),
Rx.map(R.prop('payload'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ export const fetchChunkAt = R.memoizeWith(
);

type State = {bounds: BoundsState, dataset: DatasetState, channels: Channel[]};
type chunkIntervals = {
interval: [ number, number ],
numChunks: number,
downsampling: number,
};

const UPDATE_DEBOUNCE_TIME = 100;

Expand Down Expand Up @@ -118,38 +123,41 @@ export const createFetchChunksEpic = (fromState: (any) => State) => (
const shapeChunks =
shapes.map((shape) => shape[shape.length - 2]);

const chunkIntervals = shapeChunks
const chunkIntervals : chunkIntervals[] = shapeChunks
.map((numChunks, downsampling) => {
const recordingDuration = Math.abs(
timeInterval[1] - timeInterval[0]
);

const i0 =
(numChunks *
Math.floor(bounds.interval[0] - bounds.domain[0])
) / recordingDuration;

const i1 =
(numChunks *
Math.ceil(bounds.interval[1] - bounds.domain[0])
) / recordingDuration;

const interval : [number, number] = [
Math.floor(i0),
Math.min(Math.ceil(i1), numChunks),
];

return {
interval:
[
Math.floor(i0),
Math.min(Math.ceil(i1), numChunks),
],
interval: interval,
numChunks: numChunks,
downsampling,
};
})
.filter(
({interval}) =>
.filter(({interval}) =>
interval[1] - interval[0] < MAX_VIEWED_CHUNKS
)
.reverse();

const finestChunks = R.reduce(
const finestChunks : chunkIntervals = R.reduce(
R.maxBy(({interval}) => interval[1] - interval[0]),
{interval: [0, 0]},
chunkIntervals[0],
chunkIntervals
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const roundTime = (value, decimals = 3) => {
export const createTimeSelectionEpic = (fromState: (_: any) => any) => (
action$: Observable<any>,
state$: Observable<any>
): Observable<Action> => {
): Observable<any> => {
const startDrag$ = action$.pipe(
ofType(START_DRAG_SELECTION),
Rx.map(R.prop('payload')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const datasetReducer = (
return R.assoc('physioFileID', action.payload, state);
}
case SET_DATASET_METADATA: {
return R.merge(state, action.payload);
return R.mergeAll([state, action.payload]);
}
default: {
return state;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
import {vec2, glMatrix} from 'gl-matrix';

export type Vector2 = typeof glMatrix.ARRAY_TYPE;

/**
* Apply transformation f on point p
*
* @param {Function[]} f - an array of functions
* @param {Vector2} p - a point
* @returns {Vector2} - a vector
* @param {vec2} p - a point
* @returns {vec2} - a vector
*/
export const ap = (
f: [(_: any) => any, (_: any) => any],
p: Vector2
): Vector2 => vec2.fromValues(f[0](p[0]), f[1](p[1]));
f: [(_: number) => number, (_: number) => number],
p: vec2
): vec2 => vec2.fromValues(f[0](p[0]), f[1](p[1]));

export const MIN_INTERVAL = 0.001;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../../tsconfig",
"compilerOptions": {
"strict": false
}
}
4 changes: 0 additions & 4 deletions modules/electrophysiology_browser/tsconfig.json

This file was deleted.

0 comments on commit 026981b

Please sign in to comment.