-
Notifications
You must be signed in to change notification settings - Fork 6
/
viewPlugins.ts
169 lines (151 loc) · 5.15 KB
/
viewPlugins.ts
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
import { FunctionComponent } from "react"
import ImageSegmentationItemView from "./ImageSegmentation/ImageSegmentationItemView"
import NeurodataElectricalSeriesItemView from "./ElectricalSeries/NeurodataElectricalSeriesItemView"
import NeurodataSpatialSeriesItemView from "./SpatialSeries/SpatialSeriesWidget/NeurodataSpatialSeriesItemView"
import NeurodataTimeIntervalsItemView from "./TimeIntervals/NeurodataTimeIntervalsItemView"
import NeurodataTimeSeriesItemView from "./TimeSeries/NeurodataTimeSeriesItemView"
import { neurodataTypeInheritanceRaw } from "../neurodataSpec"
import TwoPhotonSeriesItemView from "./TwoPhotonSeries/TwoPhotonSeriesItemView"
import HelloWorldView from "./HelloWorld/HelloWorldView"
import ImageSeriesItemView from "./ImageSeries/ImageSeriesItemView"
import DynamicTableView from "./DynamicTable/DynamicTableView"
import ImagesItemView from "./Images/ImagesItemView"
import RasterPlotUnitsItemView from "./Units/RasterPlotUnitsItemView"
import AutocorrelogramsUnitsItemView from "./Units/AutocorrelogramsUnitsItemView"
import DirectRasterPlotUnitsItemView from "./Units/DirectRasterPlotUnitsItemView"
import SpatialSeriesXYView from "./SpatialSeries/SpatialSeriesWidget/SpatialSeriesXYView"
type Props = {
width: number,
height: number,
path: string
condensed?: boolean
}
export type ViewPlugin = {
name: string
neurodataType: string,
defaultForNeurodataType?: boolean,
component: FunctionComponent<Props>
buttonLabel?: string
}
const viewPlugins: ViewPlugin[] = []
///////////////////////////////////////////////////////////////////////////////////////
// REGISTER VIEW PLUGINS HERE
// ImageSegmentation
viewPlugins.push({
name: 'ImageSegmentation',
neurodataType: 'ImageSegmentation',
defaultForNeurodataType: true,
component: ImageSegmentationItemView
})
// SpatialSeries
viewPlugins.push({
name: 'SpatialSeries',
neurodataType: 'SpatialSeries',
defaultForNeurodataType: true,
component: NeurodataSpatialSeriesItemView
})
viewPlugins.push({
name: 'X/Y',
neurodataType: 'SpatialSeries',
defaultForNeurodataType: false,
component: SpatialSeriesXYView,
buttonLabel: 'X/Y'
})
// TwoPhotonSeries
viewPlugins.push({
name: 'TwoPhotonSeries',
neurodataType: 'TwoPhotonSeries',
defaultForNeurodataType: true,
component: TwoPhotonSeriesItemView
})
// TimeSeries
viewPlugins.push({
name: 'TimeSeries',
neurodataType: 'TimeSeries',
defaultForNeurodataType: true,
component: NeurodataTimeSeriesItemView
})
// DynamicTable
viewPlugins.push({
name: 'DynamicTable',
neurodataType: 'DynamicTable',
defaultForNeurodataType: true,
component: DynamicTableView
})
// TimeIntervals
viewPlugins.push({
name: 'TimeIntervals',
neurodataType: 'TimeIntervals',
defaultForNeurodataType: true,
component: NeurodataTimeIntervalsItemView
})
// ElectricalSeries
viewPlugins.push({
name: 'ElectricalSeries',
neurodataType: 'ElectricalSeries',
defaultForNeurodataType: true,
component: NeurodataElectricalSeriesItemView
})
// HelloWorld
viewPlugins.push({
name: 'HelloWorld',
neurodataType: 'LabeledEvents', // hi-jacking this type for now
defaultForNeurodataType: true,
component: HelloWorldView // see ./HelloWorld/HelloWorldView.tsx
})
// See https://flatironinstitute.github.io/neurosift/#/nwb?url=https://dandiarchive.s3.amazonaws.com/blobs/8cf/38e/8cf38e36-6cd8-4c10-9d74-c2e6be70f019
// for an example that has a LabeledEvents object inside processing/behavior
// ImageSeries
viewPlugins.push({
name: 'ImageSeries',
neurodataType: 'ImageSeries',
defaultForNeurodataType: true,
component: ImageSeriesItemView
})
// Units
viewPlugins.push({
name: 'DirectRasterPlot',
neurodataType: 'Units',
defaultForNeurodataType: false,
buttonLabel: 'raster plot',
component: DirectRasterPlotUnitsItemView
})
viewPlugins.push({
name: 'RasterPlot',
neurodataType: 'Units',
defaultForNeurodataType: false,
buttonLabel: 'precomputed raster plot',
component: RasterPlotUnitsItemView
})
viewPlugins.push({
name: 'Autocorrelograms',
neurodataType: 'Units',
defaultForNeurodataType: false,
buttonLabel: 'autocorrelograms',
component: AutocorrelogramsUnitsItemView
})
// Images
viewPlugins.push({
name: 'Images',
neurodataType: 'Images',
defaultForNeurodataType: true,
component: ImagesItemView
})
///////////////////////////////////////////////////////////////////////////////////////
export const findViewPluginsForType = (neurodataType: string): {viewPlugins: ViewPlugin[], defaultViewPlugin: ViewPlugin | undefined} => {
const viewPluginsRet: ViewPlugin[] = []
let defaultViewPlugin: ViewPlugin | undefined
let nt: string | undefined = neurodataType
while (nt) {
const plugins = viewPlugins.filter(p => (p.neurodataType === nt))
viewPluginsRet.push(...plugins)
plugins.forEach(p => {
if (p.defaultForNeurodataType) {
if (!defaultViewPlugin) defaultViewPlugin = p
}
})
nt = neurodataTypeInheritanceRaw[nt]
}
return {viewPlugins: viewPluginsRet, defaultViewPlugin}
}
export default viewPlugins