def test_list_nexus(self, kg_client): cells = PatchedCell.list(kg_client, api="nexus", size=50) assert len(cells) == 30 assert cells[0].brain_location == BrainRegion("hippocampus CA1") assert isinstance(cells[0].collection, KGQuery) assert cells[0].cell_type == CellType("hippocampus CA1 pyramidal cell") assert isinstance(cells[0].experiments, KGQuery) assert cells[0].pipette_id is None assert cells[0].seal_resistance is None assert cells[0].pipette_resistance is None assert cells[0].liquid_junction_potential is None assert cells[0].labeling_compound is None assert cells[0].reversal_potential_cl == QuantitativeValue(-16.0, unit_text="mV")
def test_list_with_filter(self, kg_client): cells = PatchedCell.list(kg_client, api="nexus", brain_region=BrainRegion("hippocampus CA1"), size=50) assert len(cells) == 26
def test_all(): ## Search based on brain region cells_in_ca1 = PatchedCell.list( client, brain_region=BrainRegion("hippocampus CA1")) pprint([cell.brain_location for cell in cells_in_ca1]) ### Download the recorded data for one of these cells example_cell = cells_in_ca1[3] experiment = example_cell.experiments.resolve(client) trace = experiment.traces.resolve(client) print(trace.time_step) print(trace.data_unit) download_url = trace.data_location.location print(download_url) data = np.genfromtxt(BytesIO(requests.get(download_url).content)) ### Plot the data times = data[:, 0] signals = data[:, 1:] # plot the first 100 signals plt.figure(figsize=(18, 16), dpi=80, facecolor='w', edgecolor='k') xlim = (times.min(), times.max()) for i in range(1, 101): plt.subplot(10, 10, i) plt.plot(times, data[:, i], 'grey') plt.xlim(*xlim) plt.axis('off') ## Search based on species cells_from_mouse = PatchedCell.list(client, species=Species("Mus musculus")) for cell in cells_from_mouse[:10]: pprint( cell.collection.resolve(client).slice.resolve( client).slice.resolve(client).subject.resolve(client).species) ## Search based on cell type pyramidal_neurons = PatchedCell.list( client, cell_type=CellType("hippocampus CA1 pyramidal cell")) pprint([pn.cell_type for pn in pyramidal_neurons[:10]]) # An activity dataset with minimal metadata Dataset.set_strict_mode(False) query = { "path": "minds:specimen_group / minds:subjects / minds:samples / minds:methods / schema:name", "op": "in", "value": [ "Electrophysiology recording", "Voltage clamp recording", "Single electrode recording", "functional magnetic resonance imaging" ] } context = { "schema": "http://schema.org/", "minds": "https://schema.hbp.eu/minds/" } activity_datasets = KGQuery(Dataset, query, context).resolve(client) for dataset in activity_datasets: print("* " + getattr(dataset, "name", "unknown")) dataset = activity_datasets[-1] #dataset.owners[0].resolve(client) #dataset.license.resolve(client) ## An activity dataset with extended metadata dataset = client.by_name( Dataset, "sIPSCs from juvenile (P21-30) C57Bl6/J male mice from CA1 pyramidal neurons receiving input from PV+ interneurons" ) query = {"path": "nsg:partOf", "op": "eq", "value": dataset.id} context = { "nsg": "https://bbp-nexus.epfl.ch/vocabs/bbp/neurosciencegraph/core/v0.1.0/" } traces = KGQuery(Trace, query, context).resolve(client) print(traces) tr0 = traces[0] print(tr0.name) print(tr0.channel) print(tr0.time_step) print(tr0.data_unit) print(tr0.data_location) experiment = tr0.generated_by.resolve(client) print(experiment.name) cell = experiment.recorded_cell.resolve(client) print(cell.brain_location) print(cell.cell_type) print(cell.reversal_potential_cl)