Skip to content

Commit

Permalink
feat(app): Add Neurosift viewer for EDF and NWB files
Browse files Browse the repository at this point in the history
  • Loading branch information
nellh committed Oct 31, 2024
1 parent 1c1e0d3 commit b401010
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import FileViewerJson from "./viewers/file-viewer-json.jsx"
import FileViewerTsv from "./viewers/file-viewer-tsv.jsx"
import FileViewerCsv from "./viewers/file-viewer-csv.jsx"
import FileViewerHtml from "./viewers/file-viewer-html.jsx"
import { FileViewerEdf } from "./viewers/file-viewer-edf"

/**
* Choose the right viewer for each file type
Expand Down Expand Up @@ -34,6 +35,8 @@ const FileViewerType = ({ path, url, data }) => {
return <FileViewerCsv data={data} />
} else if (path.endsWith(".html")) {
return <FileViewerHtml data={data} />
} else if (path.endsWith(".edf") || path.endsWith(".nwb")) {
return <FileViewerEdf url={url} />

Check warning on line 39 in packages/openneuro-app/src/scripts/dataset/files/file-viewer-type.jsx

View check run for this annotation

Codecov / codecov/patch

packages/openneuro-app/src/scripts/dataset/files/file-viewer-type.jsx#L39

Added line #L39 was not covered by tests
} else {
return (
<div className="file-viewer-fallback">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from "react"
import { render, screen } from "@testing-library/react"
import { FileViewerEdf } from "../file-viewer-edf"

describe("File Viewer - EDF", () => {
it("renders an iframe with a src value", () => {
render(<FileViewerEdf url="https://example.com/example.edf" />)
expect(screen.getByTitle("Neurosift viewer")).toBeInTheDocument()
})
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from "react"
import styled from "@emotion/styled"

const ScaledIframe = styled.iframe`
width: 100%;
height: 50vh;
border: none;
`

interface FileViewerEdfProps {
url: string
}

/**
* Viewer embedding Neurosift for EDF and NWB data
*/
export const FileViewerEdf = ({ url }: FileViewerEdfProps) => {
const viewerUrl = `https://neurosift.app/?p=/edf&embedded=1&url=${url}`
return <ScaledIframe src={viewerUrl} title="Neurosift viewer" />
}

export default FileViewerEdf

0 comments on commit b401010

Please sign in to comment.