Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 Visualisation parameters
chunksURLs:
dbEntry
&& dbEntry.file.chunks_urls.map(
Expand All @@ -222,6 +222,9 @@ class ElectrophysiologySessionView extends Component {
+ '/electrophysiology_browser/file_reader/?file='
+ group.links[1].file
),
annotations:
dbEntry
&& dbEntry.file.annotations,
}));

this.setState({
Expand Down Expand Up @@ -321,6 +324,7 @@ class ElectrophysiologySessionView extends Component {
chunksURLs,
epochsURL,
electrodesURL,
annotations,
} = this.state.database[i];
const file = this.state.database[i].file;
const splitPagination = [];
Expand Down Expand Up @@ -349,7 +353,8 @@ class ElectrophysiologySessionView extends Component {
chunksURLs?.[file.splitData?.splitIndex] || chunksURLs
}
epochsURL={epochsURL}
electrodesURL={electrodesURL}
electrodesURL={electrodesURL}
annotations={annotations}
>
<Panel
id='channel-viewer'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {setDomain, setInterval} from '../series/store/state/bounds';
import {updateFilteredEpochs} from '../series/store/logic/filterEpochs';
import {setElectrodes} from '../series/store/state/montage';
import {Channel} from '../series/store/types';
import {AnnotationMetadata} from '../series/store/types';

declare global {
interface Window {
Expand All @@ -28,6 +29,7 @@ type CProps = {
chunksURL: string,
epochsURL: string,
electrodesURL: string,
annotations: AnnotationMetadata,
limit: number,
};

Expand Down Expand Up @@ -67,6 +69,7 @@ class EEGLabSeriesProvider extends Component<CProps> {
chunksURL,
epochsURL,
electrodesURL,
annotations,
limit,
} = props;

Expand Down Expand Up @@ -106,20 +109,45 @@ class EEGLabSeriesProvider extends Component<CProps> {
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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
20 changes: 4 additions & 16 deletions modules/electrophysiology_browser/php/sessions.class.inc
Original file line number Diff line number Diff line change
Expand Up @@ -461,24 +461,12 @@ class Sessions extends \NDB_Page
$fileSummary['downloads'] = $this->getDownloadLinks($physioFileObj);
$fileSummary['chunks_urls'] = $physioFileObj->getChunksURLs();

$fileOutput = $db->pselectone(
'SELECT pot.OutputTypeName
FROM physiological_output_type pot
INNER JOIN physiological_file AS pf
ON pf.PhysiologicalFileID=:PFID
AND pf.PhysiologicalOutputTypeID=pot.PhysiologicalOutputTypeID',
['PFID' => $physioFileID]
//Get the annotation data
$annotations = new ElectrophysioAnnotations(
intval($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();
}

$fileSummary['annotations'] = $annotations->getData();
$fileSummary['output_type'] = $fileOutput;
$fileSummary['splitData'] = $physioFileObj->getSplitData(0);

Expand Down