Quick start¶
Read NWB data¶
Use cicada-nwb submodules to access NWB data and use it for custom-made analysis.
from cicada_nwb import NWBSession
with NWBSession("/path/to/file.nwb") as session:
# Calcium imaging: a series is addressed by [module, interface, series name]
rrs = session.calcium_imaging.get_roi_response_series() # {module: {interface: [names]}}
module = next(iter(rrs))
interface = next(iter(rrs[module]))
keys = [module, interface, rrs[module][interface][0]]
traces = session.calcium_imaging.get_roi_response_serie_data(keys) # (n_cells, n_frames)
ts = session.calcium_imaging.get_roi_response_serie_timestamps(keys) # (n_frames,) seconds
# Behavior
trial_table = session.behavior.get_trial_table() # DataFrame, or None without trials
epochs = session.behavior.get_behavioral_epochs_names()
events = session.behavior.get_behavioral_events_names()
event_times = session.behavior.get_behavioral_events_times(event_name=events[0])
# Widefield: an acquisition is addressed by [module, name]
wf = session.widefield.get_wf_acquisition_dict() # {module: [names]}
wf_module = next(iter(wf))
wf_ts = session.widefield.get_widefield_timestamps(keys=[wf_module, wf[wf_module][0]])
# Metadata
info = session.metadata.get_sessions_info()
print(session.subject_id, session.age, session.genotype)
# Custom-made analysis below
Template¶
For an example on how to use cicada-nwb in a custom-made script for NWB based analysis.
See : custom script template.
Tip¶
To facilitate analysis development it is possible to build custom-made scripts using the cicada-tools
provided by cicada-analysis.
This requires to install cicada-analysis and import functions from cicada-tools into your script.
See the cicada-tools quick start for example.
The submodules¶
cicada-nwb is organized into six generic submodules and any number of lab-specific submodules.
| Submodule | Accessed via | Key methods |
|---|---|---|
| 2P calcium imaging | session.calcium_imaging |
get_roi_response_serie_data(), get_roi_response_serie_timestamps(), get_cell_indices_by_cell_type() |
| Electrophysiology | session.electrophysiology |
get_units_table, get_electrode_info, get_units_location |
| Behavior | session.behavior |
get_trial_table(), get_behavioral_epochs_times(), get_behavioral_events_times() |
| Widefield calcium imaging | session.widefield |
get_widefield_timestamps(), get_widefield_dff0() |
| Metadata | session.metadata |
get_sessions_info() |
| Subject | session (properties) |
subject_id, age, genotype, sex, species |
The main getters with examples: User guide. Every method of each submodule: API reference.
Lab-specific submodules¶
cicada-nwb supports lab-specific NWB conventions through lab submodules, provided by installed packages that
declare them under the entry-point group cicada_nwb.lab_submodules. For example session.petersen from
cicada-petersen and session.cossart from
cicada-cossart.
See new_lab_submodule_template.py for example implementation.