# Can't find NWB\_adapter from swdb\_2018\_neuropixels.ephys\_nwb\_adapter

**URL:** <https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506>\
**Category:** Technical\
**Created:** [July 18, 2023, 6:59pm UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506 "2023-07-18T18:59:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacobc](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jacobc](https://community.brain-map.org/u/jacobc)\
**Post date:** [July 18, 2023, 6:59pm UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/1 "2023-07-18T18:59:30Z")

</div>

I have been trying to find this module that is used in several of the swdb notebooks, to no avail.  
For example, referenced [here:](https://github.com/AllenInstitute/SWDB_2018/blob/master/DynamicBrain/EphysObservatory.ipynb)  
from swdb\_2018\_neuropixels.ephys\_nwb\_adapter import NWB\_adapter

Does anyone know where I can get the swdb\_2018\_neuropixels library?

---

<div class="post-metadata">

**Author:** ![joshs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/joshs/32/8_2.png) [@joshs](https://community.brain-map.org/u/joshs)\
**Post date:** [July 25, 2023, 11:26pm UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/2 "2023-07-25T23:26:23Z")

</div>

Hi Jacob – What are the files you’re trying to load with this adapter? This was created for some pilot sessions packaged in NWB 1.0 format for use in this summer course. All of the publicly released Neuropixels data is in NWB 2.0 format, and can be loaded with standard AllenSDK functions.

---

<div class="post-metadata">

**Author:** ![jacobc](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jacobc](https://community.brain-map.org/u/jacobc)\
**Post date:** [July 26, 2023, 12:08am UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/3 "2023-07-26T00:08:05Z")

</div>

Hi Josh,

I am using the NWB 2.0 format and AllenSDK functions to load it.  
I’ve been trying to convert an old script to use the new functions/format, but the dataframe created is a black box so I was looking for the source code.

---

<div class="post-metadata">

**Author:** ![joshs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/joshs/32/8_2.png) [@joshs](https://community.brain-map.org/u/joshs)\
**Post date:** [July 26, 2023, 12:22am UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/4 "2023-07-26T00:22:45Z")

</div>

If you can provide some more details about the script and DataFrame, I can help point you to the relevant code.

---

<div class="post-metadata">

**Author:** ![jacobc](https://avatars.discourse-cdn.com/v4/letter/j/9e8a1a/32.png) [@jacobc](https://community.brain-map.org/u/jacobc)\
**Post date:** [July 26, 2023, 1:32am UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/5 "2023-07-26T01:32:59Z")

</div>

The script assigns the output of NWB\_adapter to a dataframe  
ds = NWB\_adapter(os.path.join(dpath, exp\_name + “.nwb”))

and then gets the table for natural scenes  
stim\_df = ds.stim\_tables[‘natural\_scenes’].copy()

this is then later merged on and uses several column names I have never seen before (probably due to different nomenclature):  
on=[‘frame’, ‘occur’, ‘orientation’, ‘phase’, ‘trial’,  
‘spatial\_frequency’, ‘stim\_type’, ‘wnd\_start’]

and finally after this merge it accesses a property ‘fr’, which I think is firing rate, but I don’t know how it gets this (it doesn’t come from the other merged dataframe).  
tu\_df[‘fr’]

---

<div class="post-metadata">

**Author:** ![joshs](https://yyz1.discourse-cdn.com/flex027/user_avatar/community.brain-map.org/joshs/32/8_2.png) [@joshs](https://community.brain-map.org/u/joshs)\
**Post date:** [July 26, 2023, 11:53pm UTC](https://community.brain-map.org/t/cant-find-nwb-adapter-from-swdb-2018-neuropixels-ephys-nwb-adapter/2506/6 "2023-07-26T23:53:22Z")

</div>

The NWB adapter serves the same purpose as the `EcephysSession` object in the AllenSDK…it provides a convenient interface for retrieving data from an NWB file. To get the natural scenes table, you can just call `session.get_stimulus_table("natural_scenes")`.

I’m not sure where those column names are coming from…`frame` is the only one that would apply to the natural scenes stimulus.

What is the next step after accessing the `fr` property? Without more context, I’m not sure how firing rate could be computed from the stimulus table.
