import pandas as pd
from neuprint import Client
def fetch_column_pin_table(client):
q = """\
MATCH (pin:ColumnPin)
RETURN
pin.`ME(L)` as `ME(L)`,
pin.`LO(L)` as `LO(L)`,
pin.`LOP(L)` as `LOP(L)`,
pin.`ME(R)` as `ME(R)`,
pin.`LO(R)` as `LO(R)`,
pin.`LOP(R)` as `LOP(R)`,
pin.olHex1 as hex1,
pin.olHex2 as hex2,
pin.olLayer as layer,
pin.depth as depth,
pin.location.x as x,
pin.location.y as y,
pin.location.z as z
"""
df = client.fetch_custom(q)
roi_names = ['ME(L)', 'LO(L)', 'LOP(L)', 'ME(R)', 'LO(R)', 'LOP(R)']
df['roi'] = df[roi_names].idxmax(axis=1)
df = df.drop(columns=roi_names)
assert df.columns.tolist() == ['hex1', 'hex2', 'layer', 'depth', 'x', 'y', 'z', 'roi']
return df
c = Client('
neuprint-cns.janelia.org', 'male-cns:v0.9')
df = fetch_column_pin_table(c)
df.to_csv('/tmp/malecns-v0.9-optic-column-pins.csv’)