Open In Colab

Installing requirements¶

The cell below installs every Python package needed to run this notebook, at fully pinned versions, using uv for fast resolution. In Colab the cell is collapsed by default — click the ▶ button to run it.

In [1]:
# install cell skipped during CI (deps preinstalled into system Python)

⚠️ Restart runtime after install

The install may upgrade packages already loaded in the kernel. Go to Runtime → Restart session, then Run all cells below (skip this install cell on re-run).

How to use the data in this dandiset¶

First let's colllect all the nwb assets in this dandiset.

In [2]:
from dandi.dandiapi import DandiAPIClient


client = DandiAPIClient.for_dandi_instance("dandi")

dandiset_id = "000727"
dandiset = client.get_dandiset(dandiset_id)
asset_list = [asset for asset in dandiset.get_assets() if "nwb" in asset.path]
# The paths are:
[asset.path for asset in asset_list]
Out[2]:
['sub-fly-098/sub-fly-098_ses-20200627130208_behavior+image+ophys.nwb',
 'sub-fly-097/sub-fly-097_ses-20200627113329_behavior+image+ophys.nwb',
 'sub-fly-089/sub-fly-089_ses-20200618081653_behavior+image+ophys.nwb',
 'sub-fly-094/sub-fly-094_ses-20200620122048_behavior+image+ophys.nwb',
 'sub-fly-087/sub-fly-087_ses-20200228161226_behavior+image+ophys.nwb',
 'sub-fly-100/sub-fly-100_ses-20200702083849_behavior+image+ophys.nwb',
 'sub-fly-099/sub-fly-099_ses-20200627142647_behavior+image+ophys.nwb',
 'sub-fly-101/sub-fly-101_ses-20200702100612_behavior+image+ophys.nwb',
 'sub-fly-105/sub-fly-105_ses-20200704142706_behavior+image+ophys.nwb']

Now we pick the first of the assets above and stream it

In [3]:
import remfile
from h5py import File
from pynwb import NWBHDF5IO

asset = asset_list[0]
# Here we build the url to download the file
url = f"https://api.dandiarchive.org/api/dandisets/{asset.dandiset_id}/versions/{asset.version_id}/assets/{asset.identifier}/download"


# We stream the file using remfile and open it with h5py and pynwb
file = remfile.File(url)
h5_file = File(file, "r")

io = NWBHDF5IO(file=h5_file)
nwbfile = io.read()
nwbfile
Out[3]:

root (NWBFile)

session_description: We use volumetric two-photon imaging to map neural activity associated with walking across the entire brain of Drosophila. We detect locomotor signals in approximately 40% of the brain, identify a global signal associated with the transition from rest to walking, and define clustered neural signals selectively associated with changes in forward or angular velocity.
identifier: c93466b0-17dd-4aee-bfe0-2d501a46ec5e
session_start_time2020-06-27 13:02:18.301376-07:00
timestamps_reference_time2020-06-27 13:02:18.301376-07:00
file_create_date
02023-12-10 09:34:05.642255+01:00
experimenter('Brezovec, Luke', 'Berger, Andrew', 'Druckmann, Saul', 'Clandinin, Thomas')
related_publications('https://doi.org/10.1101/2022.03.20.485047',)
acquisition
TwoPhotonSeriesAnatomicalGreen (TwoPhotonSeries)
starting_time: 1884.4038589000702
rate: 0.12443416227596198
resolution: 6.68746528085232e-07
comments: no comments
description: Anatomical imaging data (GCaMP6f)
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typeuint16
Shape(100, 1024, 512, 241)
Array size23.54 GiB
Chunk shape(9, 1024, 512, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)25270681600
Compressed size (bytes)18928061030
Compression ratio1.3350908769761083
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[ 512 1024 241]
field_of_view
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0.0006526 0.0003424 0.000241 ]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 0.1244341622759608
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[6.37300558e-07 6.68746528e-07 1.00000000e-06]
grid_spacing_unit: meters
scan_line_rate: 15831.552283701418
TwoPhotonSeriesAnatomicalRed (TwoPhotonSeries)
starting_time: 1884.4038589000702
rate: 0.12443416227596198
resolution: 6.68746528085232e-07
comments: no comments
description: Anatomical imaging data (tdTomato)
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typeuint16
Shape(100, 1024, 512, 241)
Array size23.54 GiB
Chunk shape(9, 1024, 512, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)25270681600
Compressed size (bytes)17578556868
Compression ratio1.4375856783785672
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[ 512 1024 241]
field_of_view
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0.0006526 0.0003424 0.000241 ]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Red channel of the microscope, 550/50 nm filter.
emission_lambda: 581.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 0.1244341622759608
indicator: tdTomato
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[6.37300558e-07 6.68746528e-07 1.00000000e-06]
grid_spacing_unit: meters
scan_line_rate: 15831.552283701418
TwoPhotonSeriesFunctionalGreen (TwoPhotonSeries)
starting_time: 0.0
rate: 1.8797144377676087
resolution: 2.67498611234093e-06
comments: no comments
description: Functional imaging data (GCaMP6f)
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typeuint16
Shape(3384, 256, 128, 49)
Array size10.12 GiB
Chunk shape(152, 256, 128, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)10866917376
Compressed size (bytes)6641375024
Compression ratio1.6362451053780456
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[128 256 49]
field_of_view
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0.0006526 0.0003424 0.000245 ]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 1.8797144377676087
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[2.54920223e-06 2.67498611e-06 5.00000000e-06]
grid_spacing_unit: meters
scan_line_rate: 15830.80040526849
TwoPhotonSeriesFunctionalRed (TwoPhotonSeries)
starting_time: 0.0
rate: 1.8797144377676087
resolution: 2.67498611234093e-06
comments: no comments
description: Functional imaging data (tdTomato)
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typeuint16
Shape(3384, 256, 128, 49)
Array size10.12 GiB
Chunk shape(152, 256, 128, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)10866917376
Compressed size (bytes)7491916183
Compression ratio1.4504857116071663
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[128 256 49]
field_of_view
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0.0006526 0.0003424 0.000245 ]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Red channel of the microscope, 550/50 nm filter.
emission_lambda: 581.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 1.8797144377676087
indicator: tdTomato
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[2.54920223e-06 2.67498611e-06 5.00000000e-06]
grid_spacing_unit: meters
scan_line_rate: 15830.80040526849
Video: fictrac-20200627_130208-raw (ImageSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Video recorded by camera.
conversion: 1.0
offset: 0.0
unit: Frames
data
HDF5 dataset
Data typeuint8
Shape(0, 0, 0)
Array size0.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)0
Compressed size (bytes)0
Compression ratioundefined

[]
starting_time_unit: seconds
external_file
HDF5 dataset
Data typeobject
Shape(1,)
Array size8.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)8
Compressed size (bytes)16
Compression ratio0.5

['sub-fly-098_ses-20200627130208_behavior+image+ophys/0fd93d4a-c7d9-4157-99aa-973815d2a707_external_file_0.avi']
starting_frame
NumPy array
Data typeint64
Shape(1,)
Array size8.00 bytes

[0]
format: external
keywords
HDF5 dataset
Data typeobject
Shape(7,)
Array size56.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)56
Compressed size (bytes)112
Compression ratio0.5

['walking' 'neural Correlates' 'brain-wide Scale' 'drosophila' 'volumetric two-photon imaging' 'neural activity mapping' 'locomotor signals']
processing
behavior (ProcessingModule)
description: No description.
FicTrac (Position)
SpatialSeriesAnimalHeading (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Animal's heading direction in radians from the lab's perspective.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)667948
Compression ratio1.0779282219573978
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesIntegratedMotion (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Integrated x/y position of the sphere in laboratory coordinates, neglecting heading.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 2)
Array size1.37 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)1440000
Compressed size (bytes)1200750
Compression ratio1.1992504684572143
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesMovementDirection (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Instantaneous running direction of the animal in the lab coordinates. Direction inferred by the ball's rotation (roll and pitch)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)687896
Compression ratio1.046669845441753
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesMovementSpeed (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Instantaneous running speed of the animal in radians per frame.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)680352
Compression ratio1.0582757160999012
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesPosition (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: x and y positions in the lab frame in radians, inferred by integrating the rotation over time.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 2)
Array size1.37 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)1440000
Compressed size (bytes)1299013
Compression ratio1.1085339407688761
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationCameraFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Orientation in radians from the camera's perspective. x: rotation to the sphere's right (pitch), y: rotation under the sphere (yaw), z: rotation behind the sphere (roll)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2039806
Compression ratio1.0589242310298137
starting_time_unit: seconds
reference_frame: camera
SpatialSeriesRotationDeltaCameraFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Change in orientation since last frame from the camera's perspective. x: rotation to the sphere's right (pitch), y: rotation under the sphere (yaw), z: rotation behind the sphere (roll)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2070020
Compression ratio1.0434681790514102
starting_time_unit: seconds
reference_frame: camera
SpatialSeriesRotationDeltaError (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Error in rotation delta in radians from the lab's perspective.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)269799
Compression ratio2.6686533308129383
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationDeltaLabFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Change in orientation since last frame from the lab's perspective. x: rotation in front of subject (roll), y: rotation to subject's right (pitch), z: rotation under the subject (yaw)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2070102
Compression ratio1.0434268456336935
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationLabFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Orientation in radians from the lab's perspective. x: rotation in front of subject (roll), y: rotation to subject's right (pitch), z: rotation under the subject (yaw)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2036058
Compression ratio1.0608735114618542
starting_time_unit: seconds
reference_frame: lab
ophys (ProcessingModule)
description: No description.
TwoPhotonSeriesFunctionalGreenProcessed (TwoPhotonSeries)
starting_time: 0.0
rate: 1.8797144377676087
resolution: -1.0
comments: no comments
description: motion corrected high-pass temporal filtered z-scored and registered into a common space, the Functional Drosophila Atlas
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typefloat32
Shape(3384, 314, 146, 91)
Array size52.59 GiB
Chunk shape(54, 314, 146, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)56469538944
Compressed size (bytes)16556548743
Compression ratio3.4107071359225727
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[146 314 91]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0. 0. 0.]
origin_coords_unit: unknown
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[1. 1. 1.]
grid_spacing_unit: unknown
devices
BrukerFluorescenceMicroscope (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
Flea FL3-U3-13E4M-C (Device)
description: Sensor used for imaging with FicTrac at 50 Hz with Edmund Optics 100 mm C Series Fixed Focal Length Lens
manufacturer: Teledyne FLIR Systems, Inc.
imaging_planes
ImagingPlaneFunctionalGreenProcessed (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0. 0. 0.]
origin_coords_unit: unknown
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[1. 1. 1.]
grid_spacing_unit: unknown
ImagingPlaneGCaMP6fAnatomical (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 0.1244341622759608
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[6.37300558e-07 6.68746528e-07 1.00000000e-06]
grid_spacing_unit: meters
ImagingPlaneGCaMP6fFunctional (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Green channel of the microscope, 525/50 nm filter.
emission_lambda: 513.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 1.8797144377676087
indicator: GCaMP6f
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[2.54920223e-06 2.67498611e-06 5.00000000e-06]
grid_spacing_unit: meters
ImagingPlanetdTomatoAnatomical (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Red channel of the microscope, 550/50 nm filter.
emission_lambda: 581.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 0.1244341622759608
indicator: tdTomato
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[6.37300558e-07 6.68746528e-07 1.00000000e-06]
grid_spacing_unit: meters
ImagingPlanetdTomatoFunctional (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Red channel of the microscope, 550/50 nm filter.
emission_lambda: 581.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 1.8797144377676087
indicator: tdTomato
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[2.54920223e-06 2.67498611e-06 5.00000000e-06]
grid_spacing_unit: meters
subject (Subject)
age: P3D/P4D
age__reference: birth
description: Flies were raised on molasses medium at 25 °C with a 12/12-h light/dark cycle. Flies were housed in mixed male/female vials of 10-20 individuals. 3-4 days post-eclosion females were used for imaging.
genotype: w+/w+;UAS-myr::tdTomato/UAS-GCaMP6f;nSyb-Gal4/+
sex: F
species: Drosophila melanogaster
subject_id: fly_098
experiment_description: We use volumetric two-photon imaging to map neural activity associated with walking across the entire brain of Drosophila. We detect locomotor signals in approximately 40% of the brain, identify a global signal associated with the transition from rest to walking, and define clustered neural signals selectively associated with changes in forward or angular velocity.
session_id: 20200627130208
lab: Clandinin
institution: Stanford
surgery: Each fly was anesthetized on a chilled Peltier plate with a thermally coupled custom holder. Each immobilized fly was carefully fitted into a custom mount consisting of 3D-printed plastic and a custom cut steel shim to tightly nestle the head and thorax. To fix the fly to the mount, UV-curable glue was placed and cured on the dorsal region of the face between the eyes, and on the thorax. A saline solution was added to the dish for dissection (103 mM NaCl, 3 mM KCl, 5 mM TES, 1 mM NaH2PO4, 4 mM MgCl2, 1.5 mM CaCl2, 10 mM trehalose, 10 mM glucose, 7 mM sucrose, and 26 mM NaHCO3). Using a tungsten needle the posterior head cuticle was carefully cut and removed to reveal the whole brain (Figure S1). Dissection forceps were used to remove fat and trachea.

Looking at the anatomical data¶

In [4]:
two_photon_series_anatomical_red = nwbfile.acquisition["TwoPhotonSeriesAnatomicalRed"]
two_photon_series_anatomical_red
Out[4]:

TwoPhotonSeriesAnatomicalRed (TwoPhotonSeries)

starting_time: 1884.4038589000702
rate: 0.12443416227596198
resolution: 6.68746528085232e-07
comments: no comments
description: Anatomical imaging data (tdTomato)
conversion: 1.0
offset: 0.0
unit: n.a.
data
HDF5 dataset
Data typeuint16
Shape(100, 1024, 512, 241)
Array size23.54 GiB
Chunk shape(9, 1024, 512, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)25270681600
Compressed size (bytes)17578556868
Compression ratio1.4375856783785672
starting_time_unit: seconds
dimension
HDF5 dataset
Data typeint64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[ 512 1024 241]
field_of_view
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[0.0006526 0.0003424 0.000241 ]
imaging_plane (ImagingPlane)
optical_channel
0 (OpticalChannel)
description: Red channel of the microscope, 550/50 nm filter.
emission_lambda: 581.0
description: The plane or volume being imaged by the microscope.
device (Device)
description: Bruker Ultima IV, Version 5.5.64.100
manufacturer: Bruker
excitation_lambda: 920.0
imaging_rate: 0.1244341622759608
indicator: tdTomato
location: whole brain
conversion: 1.0
unit: meters
origin_coords_unit: meters
grid_spacing
HDF5 dataset
Data typefloat64
Shape(3,)
Array size24.00 bytes
Chunk shapeNone
CompressionNone
Compression optsNone
Uncompressed size (bytes)24
Compressed size (bytes)24
Compression ratio1.0

[6.37300558e-07 6.68746528e-07 1.00000000e-06]
grid_spacing_unit: meters
scan_line_rate: 15831.552283701418
In [5]:
two_photon_series_anatomical_red.data.shape
Out[5]:
(100, 1024, 512, 241)

We have 100 samples of voxels (first dimension).

The voxel shape 1024 x 512 x 241 where the last dimension is the number of slices / planes.

In [6]:
# Let's visualize the average value of one of the planes
plane_index = 100

mean_plane = two_photon_series_anatomical_red.data[..., plane_index].mean(axis=0)
# Note that taking the mean across the axis=0 is the time average
mean_plane.shape
Out[6]:
(1024, 512)
In [7]:
import matplotlib.pyplot as plt


fig, ax = plt.subplots(figsize=(8, 6))

# The sizes of the image are stored in the imaging_plane of the TwoPhotonSeriesAnatomicalRed
imaging_plane = two_photon_series_anatomical_red.imaging_plane
grid_spacing_data = imaging_plane.grid_spacing[:]

height, width = mean_plane.shape
x, y = grid_spacing_data[:2]
extent = [0,  height * y, width * x, 0]



img = ax.imshow(mean_plane.T, cmap='gist_heat', extent=extent)

two_photon_series_description = two_photon_series_anatomical_red.description
title = f'{two_photon_series_description} - Mean Fluoresence at plane {plane_index}'
ax.set_title(title)

unit = imaging_plane.origin_coords_unit
ax.set_xlabel(f'X ({unit})')
ax.set_ylabel(f'Y ({unit})')

plt.show()
No description has been provided for this image

Looking at the FicTrac SpatialSeries data¶

In [8]:
fictrac_container = nwbfile.processing["behavior"]["FicTrac"]
fictrac_container
Out[8]:

FicTrac (Position)

SpatialSeriesAnimalHeading (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Animal's heading direction in radians from the lab's perspective.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)667948
Compression ratio1.0779282219573978
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesIntegratedMotion (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Integrated x/y position of the sphere in laboratory coordinates, neglecting heading.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 2)
Array size1.37 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)1440000
Compressed size (bytes)1200750
Compression ratio1.1992504684572143
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesMovementDirection (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Instantaneous running direction of the animal in the lab coordinates. Direction inferred by the ball's rotation (roll and pitch)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)687896
Compression ratio1.046669845441753
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesMovementSpeed (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Instantaneous running speed of the animal in radians per frame.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)680352
Compression ratio1.0582757160999012
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesPosition (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: x and y positions in the lab frame in radians, inferred by integrating the rotation over time.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 2)
Array size1.37 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)1440000
Compressed size (bytes)1299013
Compression ratio1.1085339407688761
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationCameraFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Orientation in radians from the camera's perspective. x: rotation to the sphere's right (pitch), y: rotation under the sphere (yaw), z: rotation behind the sphere (roll)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2039806
Compression ratio1.0589242310298137
starting_time_unit: seconds
reference_frame: camera
SpatialSeriesRotationDeltaCameraFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Change in orientation since last frame from the camera's perspective. x: rotation to the sphere's right (pitch), y: rotation under the sphere (yaw), z: rotation behind the sphere (roll)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2070020
Compression ratio1.0434681790514102
starting_time_unit: seconds
reference_frame: camera
SpatialSeriesRotationDeltaError (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Error in rotation delta in radians from the lab's perspective.
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 1)
Array size703.12 KiB
Chunk shape(1407, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)720000
Compressed size (bytes)269799
Compression ratio2.6686533308129383
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationDeltaLabFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Change in orientation since last frame from the lab's perspective. x: rotation in front of subject (roll), y: rotation to subject's right (pitch), z: rotation under the subject (yaw)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2070102
Compression ratio1.0434268456336935
starting_time_unit: seconds
reference_frame: lab
SpatialSeriesRotationLabFrame (SpatialSeries)
starting_time: 0.0
rate: 50.0
resolution: -1.0
comments: no comments
description: Orientation in radians from the lab's perspective. x: rotation in front of subject (roll), y: rotation to subject's right (pitch), z: rotation under the subject (yaw)
conversion: 0.0045
offset: 0.0
unit: meters
data
HDF5 dataset
Data typefloat64
Shape(90000, 3)
Array size2.06 MiB
Chunk shape(2813, 1)
Compressiongzip
Compression opts4
Uncompressed size (bytes)2160000
Compressed size (bytes)2036058
Compression ratio1.0608735114618542
starting_time_unit: seconds
reference_frame: lab
In [9]:
import matplotlib.pyplot as plt


spatial_series = fictrac_container["SpatialSeriesPosition"]
data_in_units = spatial_series.get_data_in_units()
unit = spatial_series.unit
timestamps = spatial_series.get_timestamps()

fig, ax = plt.subplots(figsize=(12, 10))
sc = ax.scatter(data_in_units[:, 0], data_in_units[:, 1], c=timestamps, cmap='Blues')
ax.set_xlabel(f"X ({unit})")  
ax.set_ylabel(f"Y ({unit})") 

plt.colorbar(mappable=sc, ax=ax, label='Time (seconds)')

description = spatial_series.description 
ax.set_title(description)

# Add a annotation at 0, 0 that says start
# Adding a red point at (0, 0)
ax.plot(0, 0, 'ro')  # 'ro' specifies red color and circle marker

# Adding the text annotation "start" near the red point
# You can adjust the 'x' and 'y' arguments in ax.text() to move the text to the desired position
ax.text(-0.001, -0.001, 'Start', color='red', ha='right', va="bottom")
        
plt.show()
No description has been provided for this image