# CSD: session.get\_current\_source\_density() hanging

**URL:** <https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501>\
**Category:** Technical\
**Tags:** software, brain-observatory-visual-coding, analysis, allensdk\
**Created:** [April 2, 2020, 12:11pm UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501 "2020-04-02T12:11:03Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![eabhorrocks](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eabhorrocks](https://community.brain-map.org/u/eabhorrocks)\
**Post date:** [April 2, 2020, 12:11pm UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/1 "2020-04-02T12:11:03Z")

</div>

Hi, I’m trying to access the current source density data from the visual coding neuropixels datasets. The session.get\_current\_source\_density() is consistently hanging on me, eventually resulting in time out errors. I’m using the following code to run it:

```
df = session.probes
df = df.loc[df['has_lfp_data'] == True]
probe_id = np.array(df.index)

csd = session.get_current_source_density(probe_id[0])

```

I have the .nwb file stored locally and don’t have any issues accessing other data from the files.

Any ideas how to get this to work?

Thanks

---

<div class="post-metadata">

**Author:** ![njmei](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@njmei](https://community.brain-map.org/u/njmei)\
**Post date:** [April 2, 2020, 9:29pm UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/2 "2020-04-02T21:29:26Z")

</div>

Hi @eabhorrocks,

Thanks for your question! To get started, could you let me know:

- Is it a particular visual coding neuropixels session where calling `get_current_source_density` results in hanging or all sessions?
- What version of AllenSDK you’re using
- Python version

That should be enough info for initial troubleshooting!

Best,  
Nick

---

<div class="post-metadata">

**Author:** ![eabhorrocks](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eabhorrocks](https://community.brain-map.org/u/eabhorrocks)\
**Post date:** [April 3, 2020, 9:24am UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/3 "2020-04-03T09:24:12Z")

</div>

Thanks for your reply.

- It seems to happen with all sessions I test (all functional connectivity, all locally stored)
- Allensdk version: 1.5.1
- Python 3.6.6

Let me know if there’s anything I can try on my side.

Best  
Edd

---

<div class="post-metadata">

**Author:** ![njmei](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@njmei](https://community.brain-map.org/u/njmei)\
**Post date:** [April 7, 2020, 1:35am UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/4 "2020-04-07T01:35:21Z")

</div>

@eabhorrocks

Thanks for your patience!

I tried `session.get_current_source_density()` with session `719161530` and for probe id `729445648` using AllenSDK 1.6.0 and Python 3.7.7 and was able to get CSD data from the NWB file from my home computer. What follows is a guess as to what may have gone wrong as well as some additional troubleshooting tips:

1. The CSD data is stored on a NWB file (which are typically multiple gigabytes) that is separate from the session NWB data. So the ‘hanging’ you experience, may be the AllenSDK trying to download a separate `probe` NWB file.

2. If your download speed is not great, you may also want to set a longer duration for the NWB download timeout (which defaults to 10 minutes before giving up on a download). You can find an example code snippet for setting a custom download timeout here: [Failed to get session data](https://community.brain-map.org/t/failed-to-get-session-data/503/4)

3. You can add the following snippet at the start of a script or notebook to get more information about what the AllenSDK is doing in the background. As mentioned in 1. I suspect when you call `get_current_source_density()` the logging will show the AllenSDK taking a while to download the separate probe NWB file that I mentioned.

```auto
import logging
logging.getLogger().setLevel(logging.DEBUG)

```

Let me know though if you are still encountering issues!

---

<div class="post-metadata">

**Author:** ![eabhorrocks](https://avatars.discourse-cdn.com/v4/letter/e/67e7ee/32.png) [@eabhorrocks](https://community.brain-map.org/u/eabhorrocks)\
**Post date:** [April 9, 2020, 9:31am UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/5 "2020-04-09T09:31:04Z")

</div>

Thanks for your help. I thought the CSD data was stored in the .session nwb rather than the probe files. The issue will almost certainly be downloads taking too long - the d/l speed for these files seems to be capped at 500 kb/s for me. I’ll manually download the required probe files and go from there.

One more thing, what is the directory structure I should use for the probe files to access the CSD data with session.get\_current\_source\_density()? Should they be stored in the relevant session folders, in their own individual probe folders, or in some other structure?

Thanks for your help!

---

<div class="post-metadata">

**Author:** ![njmei](https://avatars.discourse-cdn.com/v4/letter/n/c37758/32.png) [@njmei](https://community.brain-map.org/u/njmei)\
**Post date:** [April 9, 2020, 6:01pm UTC](https://community.brain-map.org/t/csd-session-get-current-source-density-hanging/501/6 "2020-04-09T18:01:14Z")

</div>

Hi @eabhorrocks,

The directory structure looks like the following for the example session I tried:

```auto
Data Directory
| - channels.csv
| - manifest.json
| - probes.csv
| - sessions.csv
| - units.csv
| - session_719161530
| | - probe_729445648_lfp.nwb
| | - session_719161530.nwb

```

So the manually downloaded probe nwb file should be stored in the relevant session folder.
