Interactive NWB Data Exploration

Interactive NWB Data Exploration#

As we saw in the last section, the NWB file contains a ton of information about the experiment, as well as the actual data. We can look through each of the groups in the NWB file to pull out this information programmatically, or we can use Neurosift, a browser-based visualization tool for NWB and DANDI data maintained by the Flatiron Institute.

Neurosift lets us take a peek at the behavioral and neural data without writing any code. As a first pass, it can be very useful to explore a dataset this way – it lets you inspect the data for quality and look for interesting trends, right from the DANDI Archive.

First, let’s set up our notebook and read the NWB file that we previously downloaded, so we have a code-based view to compare against what Neurosift shows us.

import os
from pynwb import NWBHDF5IO

# Set the filename
filename = '000006/sub-anm369962/sub-anm369962_ses-20170310.nwb'

# Check for alternative file locations
if not os.path.exists(filename):
    alt_filename = '../' + filename
    if os.path.exists(alt_filename):
        filename = alt_filename
    else:
        alt_filename2 = os.path.join('Lesson_1', filename)
        if os.path.exists(alt_filename2):
            filename = alt_filename2

# Read the NWB file
if os.path.exists(filename):
    io = NWBHDF5IO(filename, 'r')
    nwb_file = io.read()
    print('NWB file found and read.')
    print(type(nwb_file))
else:
    print(f"NWB file not found at {filename}")
    print("Download the dataset using the previous notebooks to use this feature.")
NWB file found and read.
<class 'pynwb.file.NWBFile'>

Now, let’s look at this same file in Neurosift:

  1. Go to this dataset’s page on DANDI: dandiset 000006

  2. Browse to the file sub-anm369962/sub-anm369962_ses-20170310.nwb (the same one we just read above)

  3. Click the Open with Neurosift link next to the file

This opens an interactive, browser-based view of the file – no code, no download, no environment setup required. Take a look under the Units section to see the neural data.

Note: Neurosift runs entirely in your browser, so it works the same way whether you’re on Colab, Binder, your own computer, or just reading this page.

Questions for consideration

  1. What is the raw data being used to plot the visualizations in “units”? What is this data showing us?

  2. What kinds of visualizations do you see under “units”? Which of these are summary visualizations, versus more raw visualizations?

  3. Do you see any interesting trends in the data?


Lesson 1 Wrap Up#

In this first lesson, we showed you how to explore an NWB file. We discussed common elements in the structure, and how you can use Neurosift to explore the data at a high level.

Hopefully now you can:

✔️ Explain the three common features of datasets: metadata, raw data, and processed data

✔️ Identify and implement multiple ways to obtain a NWB dataset via DANDI

✔️ Explore the metadata contained in a typical Dandiset

✔️ Use Neurosift for a code-free, big-picture view of a Dandiset

In the following lesson, we’ll demonstrate different kinds of visualizations and analyses that you might do with the data.

Before moving on, try the Lesson #1 problem set to test your understanding and to put some of these new skills to work. 💪

Additional Resources#