diff --git a/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js b/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js index 6bffcb9f60f..d3f7bd41155 100644 --- a/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js +++ b/modules/electrophysiology_browser/jsx/electrophysiologySessionView.js @@ -192,10 +192,10 @@ class ElectrophysiologySessionView extends Component { } return resp.json(); }) - .then((data) => { + .then((data) => { const database = data.database.map((dbEntry) => ({ ...dbEntry, - // EEG Visualisation urls + // EEG Visualization parameters chunksURLs: dbEntry && dbEntry.file.chunks_urls.map( @@ -219,6 +219,9 @@ class ElectrophysiologySessionView extends Component { + '/electrophysiology_browser/file_reader/?file=' + group.links[1].file ), + annotations: + dbEntry + && dbEntry.file.annotations, })); this.setState({ @@ -318,6 +321,7 @@ class ElectrophysiologySessionView extends Component { chunksURLs, epochsURL, electrodesURL, + annotations, } = this.state.database[i]; const file = this.state.database[i].file; const splitPagination = []; @@ -346,7 +350,8 @@ class ElectrophysiologySessionView extends Component { chunksURLs?.[file.splitData?.splitIndex] || chunksURLs } epochsURL={epochsURL} - electrodesURL={electrodesURL} + electrodesURL={electrodesURL} + annotations={annotations} > { chunksURL, epochsURL, electrodesURL, + annotations, limit, } = props; @@ -106,20 +109,45 @@ class EEGLabSeriesProvider extends Component { this.store.dispatch(setInterval(timeInterval)); } } - ).then(() => Promise.race(racers(fetchText, epochsURL)).then((text) => { + ).then(() => Promise.race(racers(fetchText, epochsURL)) + .then((text) => { if (!(typeof text.json === 'string' || text.json instanceof String)) return; + return tsvParse( + text.json.replace('trial_type', 'label')) + .map(({onset, duration, label}, i) => ({ + onset: parseFloat(onset), + duration: parseFloat(duration), + type: 'Event', + label: label, + comment: null, + channels: 'all', + })); + }).then(events => { + let epochs = events; + annotations.instances.map(instance => { + const label = annotations.labels + .find(label => + label.AnnotationLabelID == instance.AnnotationLabelID + ).LabelDescription; + epochs.push({ + onset: parseFloat(instance.Onset), + duration: parseFloat(instance.Duration), + type: 'Annotation', + label: label, + comment: null, + channels: 'all', + }); + }); + return epochs; + }).then(epochs => { this.store.dispatch( - setEpochs(tsvParse( - text.json.replace('trial_type', 'label')) - .map(({onset, duration, label}, i) => ({ - onset: parseFloat(onset), - duration: parseFloat(duration), - type: 'Event', - label: label, - comment: null, - channels: 'all', - })) + setEpochs( + epochs + .flat() + .sort(function(a, b) { + return a.onset - b.onset; + }) ) ); this.store.dispatch(updateFilteredEpochs()); diff --git a/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/store/types.tsx b/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/store/types.tsx index 2c378859f57..2559c96bccf 100644 --- a/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/store/types.tsx +++ b/modules/electrophysiology_browser/jsx/react-series-data-viewer/src/series/store/types.tsx @@ -32,6 +32,12 @@ export type Epoch = { channels: number[] | "all", }; +export type AnnotationMetadata = { + instances: any[], + labels: any[], + metadata: any[] +} + export type RightPanel = 'annotationForm' | 'epochList' | null; export type Electrode = { diff --git a/modules/electrophysiology_browser/php/models/electrophysioannotations.class.inc b/modules/electrophysiology_browser/php/models/electrophysioannotations.class.inc index 551fa1a6616..c405687aafe 100644 --- a/modules/electrophysiology_browser/php/models/electrophysioannotations.class.inc +++ b/modules/electrophysiology_browser/php/models/electrophysioannotations.class.inc @@ -48,7 +48,7 @@ class ElectrophysioAnnotations $annotationLabels = $db->pselect( 'SELECT * FROM physiological_annotation_label', - ['PFID' => $this->_physioFileID] + [] ); $this->_data = [ diff --git a/modules/electrophysiology_browser/php/sessions.class.inc b/modules/electrophysiology_browser/php/sessions.class.inc index 24f4595be41..7af498a0106 100644 --- a/modules/electrophysiology_browser/php/sessions.class.inc +++ b/modules/electrophysiology_browser/php/sessions.class.inc @@ -477,15 +477,12 @@ class Sessions extends \NDB_Page ['PFID' => $physioFileID] ); - //Get the annotation data if the output type is derivative - //Get the annotation data if the output type is derivative - if (strcmp($fileOutput, 'derivative') == 0) { - $annotations = new ElectrophysioAnnotations( - intval($physioFileID) - ); - $fileSummary['annotations'] = $annotations->getData(); - } + //Get the annotation data + $annotations = new ElectrophysioAnnotations( + intval($physioFileID) + ); + $fileSummary['annotations'] = $annotations->getData(); $fileSummary['output_type'] = $fileOutput; $fileSummary['splitData'] = $physioFileObj->getSplitData(0); diff --git a/modules/electrophysiology_browser/test/electrophysiologyBrowserTest.php b/modules/electrophysiology_browser/test/electrophysiologyBrowserTest.php index 6c7364443d1..07a3c64a9a9 100644 --- a/modules/electrophysiology_browser/test/electrophysiologyBrowserTest.php +++ b/modules/electrophysiology_browser/test/electrophysiologyBrowserTest.php @@ -120,6 +120,8 @@ function setUp(): void [ 'SessionID' => '999999', 'PhysiologicalOutputTypeID' => 22, + 'InsertedByUser' => 'Unit Tester', + 'FilePath' => '/path/to/test/file', 'FileType' => 'testType' ] ); @@ -128,6 +130,8 @@ function setUp(): void [ 'SessionID' => '999997', 'PhysiologicalOutputTypeID' => 23, + 'InsertedByUser' => 'Unit Tester', + 'FilePath' => '/path/to/test/file2', 'FileType' => 'testType2' ] );