Advanced Query Examples

Codex provides two complementary ways to search neurons: free-form and structured queries.

With free-form search, you can simply type anything into the search bar and Codex will scan across all available annotations/labels, e.g. cell class, cell type, gene, neurotransmitter predictions, and more - much like a Google-style search. Results are ranked by quality of match: exact whole-word matches appear first, while partial or fuzzy matches are shown lower in the list (you can adjust these ranking rules in the settings menu). This makes free-form search especially useful for exploration when you don’t know exactly which field to query.

When you need precision, Codex also supports a structured query language. Here you can build expressions that filter by specific attributes such as cell_type, nt_type, side, or hemilineage, and combine them with logical operators. For example, class == olfactory retrieves neurons annotated with olfactory cell class, while nt_type != GABA excludes neurons predicted as GABAergic. More advanced operators let you ask about connectivity, pathways between cells, or similarity in shape and projection patterns. Each operator can be written in both a long form (e.g. {equal}) and a short form (e.g. ==), so you can choose whichever style you find most intuitive.

Below are some examples for various structured queries (you can click them to see matches).

For a full list of attributes and search operators refer to the FAQ page.

Equality & Inequality

Equal

Selects all neurons whose class is annotated as 'olfactory'

class {equal} olfactory
class == olfactory
Not Equal

Finds all neurons whose neurotransmitter type is not GABA

nt_type {not_equal} GABA
nt_type != GABA
Like / Fuzzy

Matches neurons with type that approximately equals 'Pm2' (fuzzy match)

cell_type {like} Pm2
cell_type ~= Pm2

String Matching

Starts With

Returns all neurons whose cell type name begins with 'T4'

cell_type {starts_with} T4
cell_type ^* T4
Ends With

Returns all neurons whose cell type ends with '4a'

cell_type {ends_with} 4a
cell_type ^$ 4a
Contains

Finds neurons with a gene attribute that contains the substring 'fru'

gene {contains} fru
gene >> fru
Not Contains

Finds neurons with a label that does not contain the substring 'dsx'

label {not_contains} dsx
label !> dsx

Membership

In Set

Matches neurons whose super class is 'sensory' or 'motor'

super_class {in} sensory, motor
super_class << sensory, motor
Not In Set

Excludes neurons whose soma is on the left or right hemisphere

side {not_in} left, right
side !< left, right

Connectivity (Region/Pathways)

Upstream Region

Finds neurons upstream of the given cell with synapses in the GNG region

GNG {upstream_region} 720575940614730914
GNG ^R 720575940614730914
Downstream Region

Finds neurons downstream of the given cell with synapses in the LO_R region

LO_R {downstream_region} 720575940628731140
LO_R !R 720575940628731140
Pathways

Finds all neurons along the shortest pathway from one cell ID to another

720575940625448968 {pathways} 720575940640978048
720575940625448968 => 720575940640978048

Unary Operators

Has

Returns neurons where the 'cell_type' field is not empty

{has} cell_type
$$ cell_type
Missing

Returns neurons that do not have any value for 'hemilineage'

{missing} hemilineage
!$ hemilineage
Upstream

Finds neurons upstream of the given cell ID

{upstream} 720575940640978048
^^ 720575940640978048
Downstream

Finds neurons downstream of the given cell ID

{downstream} 720575940625448968
!^ 720575940625448968
Reciprocal

Finds neurons that are both upstream and downstream of the given cell (reciprocal connections)

{reciprocal} 720575940622872870
^v 720575940622872870
Similar Shape

Finds neurons with morphology similar to the given cell

{similar_shape} 720575940622872870
~~ 720575940622872870
Similar Connectivity Upstream

Finds neurons with similar upstream inputs as the given cell

{similar_connectivity_upstream} 720575940622872870
~u 720575940622872870
Similar Connectivity Downstream

Finds neurons with similar downstream outputs as the given cell

{similar_connectivity_downstream} 720575940622872870
~d 720575940622872870
Similar Connectivity Both

Finds neurons with overall connectivity (inputs and outputs) similar to the given cell

{similar_connectivity} 720575940622872870
~c 720575940622872870
Similar Projection Upstream

Finds neurons with similar input projections to the given cell

{similar_projection_upstream} 720575940622872870
~pu 720575940622872870
Similar Projection Downstream

Finds neurons with similar output projections to the given cell

{similar_projection_downstream} 720575940622872870
~pd 720575940622872870
Similar Projection Both

Finds neurons with overall similar projection patterns (inputs and outputs) to the given cell

{similar_projection} 720575940622872870
~pc 720575940622872870

Advanced Chaining

Grouping And Not

Selects neurons that are olfactory OR visual, and excludes those whose cell_type starts with 'T'

{{class {equal} olfactory || class {equal} visual}} && {not} cell_type {starts_with} T
{{class == olfactory || class == visual}} && !! cell_type ^* T

Additional Examples

Glutamatergic Mbons

This query uses the {and} operator (&&) to combine two conditions. The first condition filters for mushroom body output neurons (class == MBON), and the second condition filters for neurons that are glutamatergic (nt_type == GLUT)

class {equal} MBON {and} nt_type {equal} GLUT
class == MBON && nt_type == GLUT
Visual Projection Neurons To Right Lateral Horn

This query selects visual projection neurons (super_class == visual_projection) and further restricts to those that have the right lateral horn (LH_R) as one of their output regions

super_class {equal} visual_projection {and} output_neuropils {equal} LH_R
super_class == visual_projection && output_neuropils == LH_R
Downstream Cells With Lineage Or Type

The {downstream} operator (!^) finds cells that are post-synaptic to the given cell. The second part of the query restricts results to cells that have either a hemilineage or a cell_type annotation

{downstream} 720575940638757464 {and} {{ {has} hemilineage {or} {has} cell_type }}
!^ 720575940638757464 && {{ $$ hemilineage || $$ cell_type }}
Kenyon Cell Subtypes

This query first selects cells with a cell_type starting with 'kc'. It then further filters to those whose cell_type contains either 'bp-m' or 'bp-ap2'. The double curly braces {{ ... }} ensure the contains checks are evaluated together before the {and}

cell_type {starts_with} kc {and} {{ cell_type {contains} bp-m {or} cell_type {contains} bp-ap2 }}
cell_type ^* kc && {{ cell_type >> bp-m || cell_type >> bp-ap2 }}
Two-Step Downstream T4C

The {downstream} operator (!^) finds immediate downstream partners of the given cell. The {downstream_union} operator (~DU) then expands to neurons downstream of those partners (two steps total). Finally, the filter restricts the result to cells of type T4c

{downstream_union} {downstream} 720575940629180422 {and} cell_type {equal} T4c
~DU !^ 720575940629180422 && cell_type == T4c