Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

H01 interface #162

Merged
merged 4 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
115 changes: 115 additions & 0 deletions docs/examples/4_remote/plot_04_remote_h01.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
"""
H01 Dataset
============

In this notebook, you can learn how to work with the H01 dataset using Navis.

The [H01 dataset](https://www.science.org/doi/10.1126/science.adk4858) contains 57,000 cells and 150 million synapses from a cubic millimeter of the human temporal cortex, which is [proofreading](https://h01-release.storage.googleapis.com/proofreading.html) in the CAVE.
With this interface, you can access both a snapshot of the proofread dataset and the latest dataset using CAVEclient.
"""


# %%
import navis
import navis.interfaces.h01 as h01

# %%
## Examples in using Navis interface for H01 dataset

# %%
client = h01.get_cave_client()

# %%
## Query Tables

# %%
client.materialize.get_versions()

# %%
client.materialize.get_tables()

# %%
### Query Materialized Synapse Table

# %%
client.materialize.synapse_query(limit=10)

# %%
syn = client.materialize.synapse_query(
post_ids=[864691131861340864],
# pre_ids=[ADD YOUR ROOT ID],
)
syn.head()

# %%
print(len(syn))

# %%
### Live Synapse Queries

# %%
import datetime
# check if root ID is the most recent root ID
root_id = 864691131861340864
now = datetime.datetime.now(datetime.timezone.utc)
is_latest = client.chunkedgraph.is_latest_roots([root_id], timestamp=now)
latest_id = client.chunkedgraph.get_latest_roots(root_id, timestamp=now)
print(is_latest)
print(latest_id)

# %%
synapse_table = client.info.get_datastack_info()['synapse_table']
df=client.materialize.query_table(synapse_table,
timestamp = datetime.datetime.now(datetime.timezone.utc),
filter_equal_dict = {'post_pt_root_id': latest_id[0]})
print(len(df))
df.head()

# %%
### Query Cells Table

# %%
ct = client.materialize.query_table(table="cells")
ct.head()

# %%
ct.cell_type.unique()

# %%
### Filter by cell type

# %%
interneuron_ids = ct[ct.cell_type == "INTERNEURON"].pt_root_id.values[:50]

# %%
interneuron_ids = interneuron_ids[interneuron_ids != 0 ]
interneuron_ids

# %%
len(interneuron_ids)

# %%
interneurons = h01.fetch_neurons(interneuron_ids, lod=2, with_synapses=False)

# %%
interneurons_ds = navis.simplify_mesh(interneurons, F=1/3)

# %%
interneurons_ds

# %%
import seaborn as sns
colors = {n.id: sns.color_palette('Reds', 7)[i] for i, n in enumerate(interneurons_ds)}
fig = navis.plot3d([interneurons_ds], color=colors)

# %%
## Get Skeletons

# %%
interneurons_sk = navis.skeletonize(interneurons, parallel=True)

# %%
interneurons_sk

# %%
fig = navis.plot3d([interneurons_sk[0], interneurons[0]], color=[(1, 0, 0), (1, 1, 1, .5)])
Loading