INCF Neuroinformatics Assembly, September 26, 2024
Jeremy Magland, Center for Computational Mathematics, Flatiron Institute
Developed in collaboration with CatalystNeuro
The main goal of Neurosift is to provide a user-friendly browser-based interface for exploring DANDI NWB files in a shared and collaborative environment.
Click around to explore this file.
Let’s examine the above Neurosift URL
https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/47be899c-27a8-4864-a1e9-d7a3f92e522e/download/&dandisetId=000552&dandisetVersion=0.230630.2304
The url
query parameter points to the DANDI Archive API. You can point that to the URL of any remote NWB file (not just on DANDI).
You can also view local NWB files. This would be on your local machine – it’s not easy to do this on Dandihub.
# One-time install of neurosift (already installed above)
pip install --upgrade neurosift
# Open the local file (will open a browser window)
neurosift view-nwb /path/to/file.nwb
You can try this out by downloading one of these relatively small NWB files.
The DANDI REST API is open to the public, so Neurosift can also function as an alternative DANDI Archive explorer!
For more information, see the LINDI project.
For example open this 137 GB file. There is a “Using LINDI” indicator on the left panel meaning that it found the pre-indexed .nwb.lindi.json file in the cloud and used that instead of the .nwb. The .json file efficiently stores all the meta information and references the original file for the data chunks.
Here’s the corresponding LINDI JSON file for inspection: https://lindi.neurosift.org/dandi/dandisets/000409/assets/8e55b7ac-a085-43c0-9dc9-c577bcbe1824/nwb.lindi.json
LINDI uses a JSON representation of Zarr with external references to large binary chunks.
You can load NWB objects using Python.
import lindi
url = 'https://lindi.neurosift.org/dandi/dandisets/000552/assets/25b641ae-5a56-49c2-893c-7dd19d039912/nwb.lindi.json'
# Load the remote file
f = lindi.LindiH5pyFile.from_lindi_file(url)
# load the neurodata object
X = f['/processing/behavior/SleepStates']
id = X['id']
label = X['label']
start_time = X['start_time']
stop_time = X['stop_time']
print(f'Shape of id: {id.shape}')
print(f'Shape of start_time: {start_time.shape}')
print(f'Shape of stop_time: {stop_time.shape}')
# This line was added
print(label[()])
# Output:
# Shape of id: (46,)
# Shape of start_time: (46,)
# Shape of stop_time: (46,)
# ['Awake' 'Non-REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'REM' 'Awake'
# 'Non-REM' 'REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM'
# 'REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'REM' 'Awake' 'Non-REM' 'Awake'
# 'Non-REM' 'REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM'
# 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'Awake' 'Non-REM' 'REM' 'Awake'
# 'Non-REM' 'REM' 'Awake' 'Non-REM' 'Awake']
Open a Jupyter notebook. In Dandihub this would be File -> New -> Notebook and select Python 3 kernel. Then paste in this code for the first cell and run the cell.
Then run the following line to see the labels data
print(label[()])
What are the different Neurosift tabs?
The NWB tab gives a hierarchical layout of the Neurodata objects in the NWB file with links to various visualization plugins.
What are the checkboxes for?
The RAW tab shows the raw HDF5 structure: groups, datasets, attributes, etc.
Tip: to inspect the contents of a larger dataset, open the browser developer console and click on the CIRCLE icon. The contents of the dataset will be printed to the console. For example in this example go to the RAW tab and navigate to processing -> behavior -> Blink -> TimeSeries -> data. Open the browser developer console and click the CIRCLE icon.
The WIDGETS tab provides a widget-centric view of the file. For each relevant visualization plugin, you can see the neurodata objects that can be opened with it.
The SPECIFICATIONS tab lets you visualize the HDMF spec that is embedded in the NWB file.
Will discuss elsewhere.
Finally, the ANNOTATIONS tab is an advanced feature that lets you add annotations (notes) to Dandisets, NWB files, and individual Neurodata objects. Other users will be able to see your annotations.
Note: this is an experimental feature and is subject to change / deletion. We are not going to cover it in this tutorial.
Click on “advanced query” in the upper-right corner of the main neurosift page.
You can filter by neurodata types. For example, in this screenshot, I searched for all Dandisets that have an object of type Units AND an object of type ElectricalSeries. This is based on a pre-indexing of public DANDI that includes only the first 100 assets of each Dandiset.
You can then select a subset of these Dandisets and perform a SPECIAL query using JSONPath or JavaScript syntax. For example you could ask it to:
On DANDI Archive: 000458
Here’s a thorough description of the dataset for purpose of reanalysis.
This notebook shows how to use the DANDI API to summarize all of the sessions: 001_summarize_contents.ipynb
Here’s one of the examples in Neurosift: sub-551397/sub-551397_ses-20210211_behavior+ecephys.nwb
As you can see we have EEG, LFP, epochs, trials, running speed, and units.
In the Units section click on “Raster Plot” and then adjust the number of visible units.
Let’s explore the Peri-Stimulus Time Histograms (PSTH)!
is_valid === 1 && is_running === 0 && stimulus_type === "electrical"
. This will restrict the trials to those that are valid, not running, and have an electrical stimulus.To share your view, use the “Share this tab” on the left panel of Neurosift. [Here’s a link with the predefined state intact](https://neurosift.app/?p=/nwb&url=https://api.dandiarchive.org/api/assets/d966b247-2bac-4ef0-8b80-aae010f50c98/download/&dandisetId=000458&dandisetVersion=0.230317.0039&tab=view:PSTH | /intervals/trials^/units&tab-state=H4sIAAAAAAAAA03SvW7bMBSG4VsxOGRSC%2FE3dgAvGYJk7d%2BSFIYiMRIBiTREKkEQ%2BN77SkGLDt%2Bgw8f00Qd9iOxH3xbf%2FYyhPHRZ3Dyag6zMQRFNDLHEkWuyJ4fK1jWRRBFNDLHEkWuyJziJkziJkziJkziJkziJkziFUziFUziFUziFUziFUziN0ziN0ziN0ziN0ziN0ziDMziDMziDMziDMziDMziLsziLsziLsziLsziLsziHcziHcziHc7g953vOD5zTm6U3S2%2BW3iy9WXqz9Oboy9GVoytXm9%2BVaMbQxx%2FpVzOH5nn0a%2FEil2YupxImLxD9nJbz7ftfIW7Esx%2Ba15DmZjz5c2oHUYnC4Zjvwlj8jAj59MrN3e54PO7k7upqx2ReYgyx32b1Osv8xTIu%2BVTez34bP4ntM5hD24xPgntzmsv6SeT%2FF3gUY2qbElJENLldt3wLsUtv35rY%2B%2B%2BFFT4%2B34JdvtRfLc7HjgcpLpU4z%2F4lb2RYf5K3ncu8%2BGqb3Idc%2Fj1PKZXBd5%2BzF96R4eBDP6xXT74Ly8TlcZluQ%2BROXV8ufwD179KNzQIAAA%3D%3D). |