fairgraph: a Python API for the EBRAINS Knowledge Graph¶
fairgraph is an experimental Python library for working with metadata in the HBP/EBRAINS Knowledge Graph, with a particular focus on data reuse, although it is also useful in metadata registration/curation. The API is not stable, and is subject to change.
Installation¶
To get the latest release:
pip install fairgraph
To get the development version:
git clone https://github.com/HumanBrainProject/fairgraph.git
pip install -r ./fairgraph/requirements.txt
pip install -U ./fairgraph
About the Knowledge Graph¶
The Human Brain Project/EBRAINS Knowledge Graph is a metadata store for neuroscience.
When sharing neuroscience data, it is essential to also share all of the context and background information needed to interpret and understand the data: the age of the subject, the sampling rate of the recording system, etc. For the HBP/EBRAINS data sharing platform, the actual data files are stored at the Swiss National Supercomputing Center, CSCS. All of the metadata associated with these files (including the precise file locations) is stored in the Knowledge Graph.
There are many ways to access the contents of the Knowledge Graph: through a graphical search interface, with an anatomical search through the EBRAINS brain atlases, through web services, and through Python clients.
fairgraph is an experimental, high-level Python client for the Knowledge Graph, which aims to be convenient, powerful and easy-to-use. Alternative ways to access the Knowledge Graph programmatically are summarized in the section “Alternatives” below.
Structure¶
The HBP/EBRAINS Knowledge Graph is a semantic graph database (in the sense of graph theory). It consists of “nodes”, each of which contains metadata about a specific aspect of a neuroscience experiment. These nodes are connected to each other, and the connections represent the relationships between the different pieces of metadata (for example, a node representing a slice of rat hippocampus will be connected to other nodes representing each of the neurons in that slice that was recorded from with an electrode, or reconstructed from microscopy images. The connections between nodes are of many different types, so that we can represent precisely the meaning of the connection, the type of the relationship (this is why we call it a _semantic_ graph). This graph structure gives great flexibility and ease of evolution compared to a traditional database.
Todo
insert a figure here showing a part of the graph
fairgraph maps the Knowledge Graph onto connected Python objects.
For example, a node in the graph containing metadata about a neuron whose activity was
recorded using patch-clamp electrophysiology is represented by a Python object
PatchedCell
whose attributes correspond to the metadata stored in that node
_and_ to the semantic connections to other nodes.
Alternatives¶
Todo
write about KG Query API, pyxus, KG Query Python pip
Querying the Knowledge Graph¶
Setting up a connection¶
Communication between fairgraph metadata objects and the Knowledge Graph web service is through a client object, for which an access token associated with an HBP Identity account is needed. To obtain an HBP Identity account, please see https://services.humanbrainproject.eu/oidc/account/request.
If you are working in an HBP Collaboratory Jupyter notebook, you have already logged in with your user name and password, so you can get an access token as follows:
from jupyter_collab_storage import oauth_token_handler
token = oauth_token_handler.get_token()
If working outside the Collaboratory, you can obtain a token from https://nexus-iam.humanbrainproject.org/v0/oauth2/authorize We suggest you then save it as an environment variable, e.g. at a shell prompt:
export HBP_AUTH_TOKEN=eyJhbGci...nPq
and then in Python:
token = os.environ['HBP_AUTH_TOKEN']
Once you have a token:
from fairgraph import KGClient
client = KGClient(token)
Listing the available metadata types¶
Each type of metadata node in the Knowledge Graph is represented by a Python class. These classes are organized into modules according to the domain, e.g. “electrophysiology” or “brainsimulation”. For a full list of domains, see Metadata domains.
To get a list of classes in a given module, import the module and then run
list_kg_classes()
, e.g.:
>>> from fairgraph import electrophysiology
>>> electrophysiology.list_kg_classes()
[fairgraph.electrophysiology.BrainSlicingActivity,
fairgraph.electrophysiology.IntraCellularSharpElectrodeExperiment,
fairgraph.electrophysiology.IntraCellularSharpElectrodeRecordedCell,
fairgraph.electrophysiology.IntraCellularSharpElectrodeRecordedCellCollection,
fairgraph.electrophysiology.IntraCellularSharpElectrodeRecordedSlice,
fairgraph.electrophysiology.IntraCellularSharpElectrodeRecording,
fairgraph.electrophysiology.MultiChannelMultiTrialRecording,
fairgraph.electrophysiology.PatchClampActivity,
fairgraph.electrophysiology.PatchClampExperiment,
fairgraph.electrophysiology.PatchedCell,
fairgraph.electrophysiology.PatchedCellCollection,
fairgraph.electrophysiology.PatchedSlice,
fairgraph.electrophysiology.QualifiedMultiTraceGeneration,
fairgraph.electrophysiology.QualifiedTraceGeneration,
fairgraph.electrophysiology.Slice,
fairgraph.electrophysiology.StepCurrentStimulus,
fairgraph.electrophysiology.Trace]
Listing all metadata nodes of a given type¶
To obtain a list of all the metadata nodes of a given type, import the associated class and use
the list()
method, passing the client object you created previously,
e.g. to get a list of patched cells:
from fairgraph.electrophysiology import PatchedCell
cells = PatchedCell.list(client)
By default, this gives you the first 100 results. You can change the number of results retrieved and the starting point, e.g.
cells = PatchedCell.list(client, from_index=50, size=50)
This returns 50 nodes starting with the 50th. To see how many nodes there are in total:
PatchedCell.count(client)
Note
if you consistently retrieve an empty list, it is probably because you do not yet have the necessary permissions. See Access permissions for more information.
Filtering/searching¶
To obtain only metadata nodes that have certain properties, you can filter the list of nodes. For example, to see only patched cells from the CA1 region of the hippocampus in the mouse:
from fairgraph.commons import BrainRegion, Species
hippocampus_cells = PatchedCell.list(client,
brain_region=BrainRegion("hippocampus CA1"),
species=Species("Mus musculus"))
Warning
the filtering system is currently primitive, and unaware of hierarchies, e.g.
filtering by “hippocampus” will not return cells with the brain region set to
“hippocampus CA1”. This is on our list of things to fix soon!
To see a list of possible search terms, use the terms()
method,
e.g. BrainRegion.terms()
, Species.terms()
Retrieving a specific node based on its name or id¶
If you know the name or unique id of a node in the KnowledgeGraph, you can retrieve it directly:
cell_of_interest = PatchedCell.by_name('hbp00011_Sub3_Samp2__ExpE10', client)
cell_of_interest = PatchedCell.from_id("8512c3a3-eee3-4c64-acbf-850ab0bd42ee", client)
Viewing metadata and connections¶
Once you have retrieved a node of interest, the associated metadata are available as attributes of the Python object, e.g.:
>>> cell_of_interest.id
'https://nexus.humanbrainproject.org/v0/data/neuralactivity/experiment/patchedcell/v0.1.0/8512c3a3-eee3-4c64-acbf-850ab0bd42ee'
>>> cell_of_interest.uuid
'8512c3a3-eee3-4c64-acbf-850ab0bd42ee'
>>> cell_of_interest.brain_location
BrainRegion('hippocampus CA1', 'http://purl.obolibrary.org/obo/UBERON_0003881')
>>> cell_of_interest.cell_type
CellType('hippocampus CA1 pyramidal cell', 'http://uri.neuinfo.org/nif/nifstd/sao830368389')
Connections between graph nodes are also available as attributes:
>>> cell_of_interest.collection
KGQuery([<class 'fairgraph.electrophysiology.PatchedCellCollection'>], {'path': 'prov:hadMember', 'op': 'eq', 'value': 'https://nexus.humanbrainproject.org/v0/data/neuralactivity/experiment/patchedcell/v0.1.0/8512c3a3-eee3-4c64-acbf-850ab0bd42ee'})
By default, for performance reasons, connections are not followed, and instead you will see either
a KGQuery
or KGProxy
object. In both these cases, follow the connection using the
resolve()
method, e.g.:
>>> cell_collection = cell_of_interest.collection.resolve(client)
>>> patched_slice = cell_collection.slice.resolve(client)
>>> original_slice = patched_slice.slice.resolve(client)
>>> subject = original_slice.subject.resolve(client)
>>> subject.name
'hbp00011_Sub3'
>>> subject.species
Species('Mus musculus', 'http://purl.obolibrary.org/obo/NCBITaxon_10090')
>>> subject.sex
Sex('female', 'schema:Female')
>>> subject.age
Age(QuantitativeValue(3.0 'months'), 'Post-natal')
This could be chained together in a single line!
>>> subject = cell_of_interest.collection.resolve(client).slice.resolve(client).slice.resolve(client).subject.resolve(client)
Note
It is rather cumbersome to have to follow all these connections manually. In the near future, you will be able to ask fairgraph to resolve the connections for you, although with the risk of poor performance if your node of interest is indirectly connected to many other nodes in the graph.
Strict mode¶
fairgraph is quite strict about which metadata attributes and data types are expected, somewhat stricter than the Knowledge Graph itself. If you find that certain queries produce errors, you can relax this strict checking for a given node type as follows:
PatchedCell.set_strict_mode(False)
Creating and updating metadata nodes¶
To create a new metadata node, create an instance of the appropriate Python class,
then use the save()
method, e.g.:
from fairgraph.modelvalidation import AnalysisResult
result = AnalysisResult(
name="inter-spike-interval histograms from subject #f2009a33, white-noise stimulation",
result_file="isi_f2009a33_wn.txt"
)
result.save(client)
To update a node, edit the attributes of the corresponding Python object, then save()
again:
result.description = "ISIs from 32 neurons, first column is bin left edges, remaining columns one per neuron"
result.save(client)
How does fairgraph distinguish between creating a new node and modifying an existing one?¶
If a previously-created node has been retrieved from the Knowledge Graph, it will have a unique ID,
and therefore calling save()
will update the node with this ID.
If a new Python object is created with the same or similar metadata, fairgraph queries for
a node with matching metadata for a subset of the fields.
In the case of AnalysisResult
, above, those fields are name and timestamp.
Note
at present, the only way to know which subset of fields are used in this query is
to view the sourcecode, and inspect the _existence_query()
method.
Permissions¶
If you get an error message when trying to create or update a node, it may be because you do not have the necessary permissions. See Access permissions for more information.
Metadata domains¶
minds¶
“Minimal Information for Neuroscience DataSets” - metadata common to all neuroscience datasets independent of the type of investigation
-
class
fairgraph.minds.
Person
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
- A person associated with research data or models, for example as an experimentalist,
- or a data analyst.
Parameters: - identifier (str) –
- name (str) –
- shortname (str) –
-
class
fairgraph.minds.
Activity
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A research activity.
Parameters: - identifier (str) –
- name (str) –
- ethics_approval (EthicsApproval) –
- ethics_authority (EthicsAuthority) –
- methods (Method) –
- preparation (Preparation) –
- protocols (Protocol) –
-
class
fairgraph.minds.
AgeCategory
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
An age category, e.g. “adult”, “juvenile”
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
EthicsApproval
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
Record of an ethics approval.
Parameters: - identifier (str) –
- name (str) –
- generated_by (EthicsAuthority) –
-
class
fairgraph.minds.
EthicsAuthority
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A entity legally authorised to approve or deny permission to conduct an experiment on ethical grounds.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Dataset
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A collection of related data files.
Parameters: - activity (Activity) –
- container_url_as_ZIP (bool) –
- container_url (str) –
- datalink (str) –
- dataset_doi (str) –
- description (str) –
- external_datalink (str) –
- identifier (str) –
- name (str) –
- release_date (datetime) –
- component (PLAComponent) –
- contributors (Person) –
- doireference (str) –
- embargo_status (EmbargoStatus) –
- formats (Format) –
- license (License) –
- modality (Modality) –
- owners (Person) –
- parcellation_atlas (ParcellationAtlas) –
- parcellation_region (ParcellationRegion) –
- part_of (str) –
- publications (Publication) –
- reference_space (ReferenceSpace) –
- specimen_group (SpecimenGroup) –
-
class
fairgraph.minds.
EmbargoStatus
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
Information about the embargo period during which a given dataset cannot be publicly shared.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
File
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
Metadata about a single file.
Parameters: - absolute_path (str) –
- byte_size (int) –
- content_type (str) –
- hash (str) –
- identifier (str) –
- last_modified (datetime) –
- name (str) –
- relative_path (str) –
-
class
fairgraph.minds.
FileAssociation
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A link between a file and a dataset.
Parameters:
-
class
fairgraph.minds.
Format
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A file/data format.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
License
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A license governing sharing of a dataset.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Method
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
An experimental method.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Modality
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A recording modality.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
ParcellationAtlas
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A brain atlas in which the brain of a given species of animal is divided into regions.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
ParcellationRegion
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A brain region as defined by a brain atlas.
Parameters: - alias (str) –
- identifier (str) –
- name (str) –
- url (str) –
- species (Species) –
-
class
fairgraph.minds.
PLAComponent
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A data or software component, as defined in the HBP “project lifecycle” application.
Parameters: - description (str) –
- identifier (str) –
- name (str) –
- component (str) –
-
class
fairgraph.minds.
Preparation
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
An experimental preparation.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Protocol
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
An experimental procotol.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Publication
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A scientific publication.
Parameters: - cite (str) –
- doi (str) –
- identifier (str) –
- name (str) –
- authors (Person) –
-
class
fairgraph.minds.
ReferenceSpace
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A reference space for a brain atlas.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Role
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
The role of a person within an experiment.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Sample
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A sample of neural tissue.
Parameters: - container_url (str) –
- identifier (str) –
- name (str) –
- weight_post_fixation (str) –
- weight_pre_fixation (str) –
- methods (Method) –
- parcellation_atlas (ParcellationAtlas) –
- parcellation_region (ParcellationRegion) –
- reference (str) –
-
class
fairgraph.minds.
Sex
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
The sex of an animal or person from whom/which data were obtained.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
SoftwareAgent
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
Software that performed a given activity.
Parameters: - description (str) –
- identifier (str) –
- name (str) –
-
class
fairgraph.minds.
Species
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
The species of an experimental subject, expressed with the binomial nomenclature.
Parameters: - identifier (str) –
- name (str) –
-
class
fairgraph.minds.
SpecimenGroup
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
A group of experimental subjects.
Parameters: - identifier (str) –
- name (str) –
- subjects (Subject) –
-
class
fairgraph.minds.
Subject
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
The organism that is the subject of an experimental investigation.
Parameters: - cause_of_death (str) –
- genotype (str) –
- identifier (str) –
- name (str) –
- strain (str) –
- strains (str) –
- weight (str) –
- age (str) –
- age_category (AgeCategory) –
- samples (Sample) –
- sex (Sex) –
- species (Species) –
-
fairgraph.minds.
Project
¶ alias of
fairgraph.minds.PLAComponent
uniminds¶
An updated version of MINDS
-
class
fairgraph.uniminds.
UnimindsObject
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
-
class
fairgraph.uniminds.
UnimindsOption
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.minds.MINDSObject
-
class
fairgraph.uniminds.
Person
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
- A person associated with research data or models, for example as an experimentalist,
- or a data analyst.
Parameters: - alternatives (KGObject) –
- email (str) –
- family_name (str) –
- given_name (str) –
- identifier (str) –
- name (str) –
- orcid (str) –
-
class
fairgraph.uniminds.
AbstractionLevel
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Level of abstraction for a neuroscience model, e.g.rate neurons, spiking neurons
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
AgeCategory
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
An age category, e.g. “adult”, “juvenile”
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
BrainStructure
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A sub-structure or region with the brain.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
CellularTarget
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
The type of neuron or glial cell that is the focus of the study.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Country
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A geographical country.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Dataset
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A collection of related data files.
Parameters: - alternatives (KGObject) –
- description (str) –
- identifier (str) –
- intended_release_date (datetime) –
- name (str) –
- brain_structure (BrainStructure) –
- cellular_target (CellularTarget) –
- contributor (Person) –
- custodian (Person) –
- doi (Doi) –
- embargo_status (EmbargoStatus) –
- ethics_approval (EthicsApproval) –
- funding_information (FundingInformation) –
- hbp_component (HBPComponent) –
- license (License) –
- main_contact (Person) –
- main_file_bundle (FileBundle) –
- method (Method) –
- project (Project) –
- publication (Publication) –
- species (Species) –
- study_target (StudyTarget) –
- subjectgroup (SubjectGroup) –
-
class
fairgraph.uniminds.
Disability
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A disability or disease.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Doi
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Digital Object Identifier (https://www.doi.org)
Parameters: - citation (str) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
EmbargoStatus
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Information about the embargo period during which a given dataset cannot be publicly shared.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
EthicsApproval
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
Record of an ethics approval.
Parameters: - alternatives (KGObject) –
- hbpethicsapproval (str) –
- identifier (str) –
- name (str) –
- country_of_origin (Country) –
- ethics_authority (EthicsAuthority) –
-
class
fairgraph.uniminds.
EthicsAuthority
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A entity legally authorised to approve or deny permission to conduct an experiment on ethical grounds.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
ExperimentalPreparation
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
An experimental preparation.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
File
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
Metadata about a single file.
Parameters: - alternatives (KGObject) –
- description (str) –
- identifier (str) –
- name (str) –
- url (str) –
- mime_type (MimeType) –
-
class
fairgraph.uniminds.
FileAssociation
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A link between a file and a dataset.
Parameters:
-
class
fairgraph.uniminds.
FileBundle
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A collection of files (e.g. in a folder or directory structure)
Parameters: - alternatives (KGObject) –
- description (str) –
- identifier (str) –
- name (str) –
- url (str) –
- usage_notes (str) –
- file (File) –
- file_bundle (FileBundle) –
- mime_type (MimeType) –
-
class
fairgraph.uniminds.
FileBundleGroup
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A collection of file bundles (see
FileBundle
)Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
FundingInformation
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
Information about the source of funding of a study.
Parameters: - alternatives (KGObject) –
- grant_id (str) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Genotype
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
- Genetic makeup of a study subject, typically a reference to an inbred strain,
- with or without mutations.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Handedness
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Preferred hand (left, right, or ambidextrous)
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
HBPComponent
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A data or software component, as defined in the HBP “project lifecycle” application.
Parameters: - alternatives (KGObject) –
- associated_task (str) –
- identifier (str) –
- name (str) –
- component_owner (Person) –
-
class
fairgraph.uniminds.
License
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A license governing sharing of a dataset.
Parameters: - alternatives (KGObject) –
- fullname (str) –
- identifier (str) –
- name (str) –
- url (str) –
-
class
fairgraph.uniminds.
Method
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
An experimental method.
Parameters: - alternatives (KGObject) –
- description (str) –
- fullname (str) –
- identifier (str) –
- name (str) –
- brain_structure (BrainStructure) –
- ethics_approval (EthicsApproval) –
- experimental_preparation (ExperimentalPreparation) –
- method_category (MethodCategory) –
- publication (Publication) –
- study_target (StudyTarget) –
- submethod (Method) –
-
class
fairgraph.uniminds.
MethodCategory
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A category used for classifying experimental methods (see
ExperimentalMethod
)Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
MimeType
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Media type of a document
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
ModelFormat
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Programming or markup language used to describe or create a model
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
ModelInstance
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A specific version/parameterization of a neuroscience model.
Parameters: - alternatives (KGObject) –
- description (str) –
- identifier (str) –
- license (License) –
- name (str) –
- version (str) –
- abstraction_level (AbstractionLevel) –
- brain_structure (BrainStructure) –
- cellular_target (CellularTarget) –
- contributor (Person) –
- custodian (Person) –
- main_contact (Person) –
- modelformat (ModelFormat) –
- modelscope (ModelScope) –
- publication (Publication) –
- study_target (StudyTarget) –
-
class
fairgraph.uniminds.
ModelScope
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
‘What is being modelled’: a protein, a single cell, the entire brain, etc.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Organization
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
An organization associated with research data or models, e.g. a university, lab or department.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
- created_as (str) –
-
class
fairgraph.uniminds.
Project
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A research project, which may have generated one or more datasets (see
Dataset
)Parameters: - alternatives (KGObject) –
- description (str) –
- identifier (str) –
- name (str) –
- coordinator (Person) –
-
class
fairgraph.uniminds.
Publication
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A scientific publication.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
- url (str) –
- brain_structure (BrainStructure) –
- project (Project) –
- publication_id (PublicationId) –
- study_target (StudyTarget) –
- subjectgroup (SubjectGroup) –
-
class
fairgraph.uniminds.
PublicationId
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Identifier for a publication (e.g. a DOI, a PubMed ID)
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
- publication (Publication) –
- publication_id_type (PublicationIdType) –
-
class
fairgraph.uniminds.
PublicationIdType
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
A type of publication identifier (e.g. ISBN, DOI)
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Sex
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
The sex of an animal or person from whom/which data were obtained.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Species
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
The species of an experimental subject, expressed with the binomial nomenclature.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Strain
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
An inbred sub-population within a species.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
StudyTarget
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
The focus of an experimental or modelling study.
Parameters: - alternatives (KGObject) –
- fullname (str) –
- identifier (str) –
- name (str) –
- study_target_source (StudyTargetSource) –
- study_target_type (StudyTargetType) –
-
class
fairgraph.uniminds.
StudyTargetSource
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Context of a study target, e.g. if the target is a brain region, the source might be an atlas.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
StudyTargetType
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsOption
Category of study target (see
StudyTarget
)Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
-
class
fairgraph.uniminds.
Subject
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
The organism that is the subject of an experimental investigation.
Parameters: - age (str, float) –
- age_range_max (str, float) –
- age_range_min (str, float) –
- alternatives (KGObject) –
- identifier (str) –
- name (str) –
- age_category (AgeCategory) –
- brain_structure (BrainStructure) –
- cellular_target (CellularTarget) –
- disability (Disability) –
- genotype (Genotype) –
- handedness (Handedness) –
- publication (Publication) –
- sex (Sex) –
- species (Species) –
- strain (Strain) –
- study_target (StudyTarget) –
-
class
fairgraph.uniminds.
SubjectGroup
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A group of experimental subjects.
Parameters: - age_range_max (str, float) –
- age_range_min (str, float) –
- alternatives (KGObject) –
- description (str) –
- identifier (str) –
- name (str) –
- num_of_subjects (int) –
- age_category (AgeCategory) –
- cellular_target (CellularTarget) –
- brain_structure (BrainStructure) –
- disability (Disability) –
- genotype (Genotype) –
- handedness (Handedness) –
- publication (Publication) –
- sex (Sex) –
- species (Species) –
- strain (Strain) –
- study_target (StudyTarget) –
- subjects (Subject) –
-
class
fairgraph.uniminds.
TissueSample
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.uniminds.UnimindsObject
A sample of brain tissue.
Parameters: - alternatives (KGObject) –
- identifier (str) –
- name (str) –
- subject (Subject) –
electrophysiology¶
Metadata for electrophysiology experiments.
- The following methods are currently supported:
- patch clamp recording in brain slices
- sharp electrode intracellular recording in brain slices
- Coming soon:
- patch clamp recordings in cultured neurons
- extracellular electrode recording, including tetrodes and multi-electrode arrays
-
class
fairgraph.electrophysiology.
Trace
(name, data_location, generated_by, generation_metadata, channel, data_unit, time_step, part_of=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
Single time series recorded during an experiment or simulation.
Trace
represents a single recording from a single channel. If you have a file containing recordings from multiple channels, or multiple recordings from a single channel, useMultiChannelMultiTrialRecording
.Parameters: - name (str) –
- data_location (Distribution) –
- generated_by (PatchClampExperiment) –
- generation_metadata (QualifiedTraceGeneration) –
- channel (int) –
- data_unit (str) –
- time_step (QuantitativeValue) –
- part_of (Dataset) –
-
class
fairgraph.electrophysiology.
MultiChannelMultiTrialRecording
(name, data_location, generated_by, generation_metadata, channel_names, data_unit, time_step, part_of=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.Trace
Multiple time series recorded during an experiment or simulation.
Time series may be recorded from multiple ch If you have a file containing only a single recording from a single channel, you may instead useTrace
.Parameters: - name (str) –
- data_location (Distribution) –
- generated_by (PatchClampExperiment, ExtracellularElectrodeExperiment) –
- generation_metadata (QualifiedMultiTraceGeneration) –
- channel_names (str) –
- data_unit (str) –
- time_step (QuantitativeValue) –
- part_of (Dataset) –
-
class
fairgraph.electrophysiology.
PatchedCell
(name, brain_location, collection=None, cell_type=None, experiments=None, pipette_id=None, seal_resistance=None, pipette_resistance=None, liquid_junction_potential=None, labeling_compound=None, reversal_potential_cl=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
A cell recorded in patch clamp.
Parameters: - name (str) –
- brain_location (BrainRegion) –
- collection (PatchedCellCollection) –
- cell_type (CellType) –
- experiments (PatchClampExperiment) –
- pipette_id (str, int) –
- seal_resistance (QuantitativeValue) –
- pipette_resistance (QuantitativeValue) –
- liquid_junction_potential (QuantitativeValue) –
- labeling_compound (str) –
- reversal_potential_cl (QuantitativeValue) –
-
class
fairgraph.electrophysiology.
Slice
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
A brain slice.
Parameters: - name (str) –
- subject (Subject) –
- brain_slicing_activity (BrainSlicingActivity) –
-
class
fairgraph.electrophysiology.
BrainSlicingActivity
(subject, slices, brain_location=None, slicing_plane=None, slicing_angle=None, cutting_solution=None, cutting_thickness=None, start_time=None, people=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
The activity of cutting brain tissue into slices.
Parameters: - subject (Subject) –
- slices (Slice) –
- brain_location (BrainRegion) –
- slicing_plane (str) –
- slicing_angle (float) –
- cutting_solution (str) –
- cutting_thickness (QuantitativeValue) –
- start_time (datetime) –
- people (Person) –
-
class
fairgraph.electrophysiology.
PatchedSlice
(name, slice, recorded_cells, recording_activity=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
A slice that has been recorded from using patch clamp.
Parameters: - name (str) –
- slice (Slice) –
- recorded_cells (PatchedCellCollection) –
- recording_activity (PatchClampActivity) –
-
class
fairgraph.electrophysiology.
PatchedCellCollection
(name, cells, slice=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
A collection of patched cells.
Parameters: - name (str) –
- cells (PatchedCell) –
- slice (PatchedSlice) –
-
class
fairgraph.electrophysiology.
PatchClampActivity
(name, slice, recorded_slice, protocol=None, people=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
A patch clamp recording session.
Parameters: - name (str) –
- slice (Slice) –
- recorded_slice (PatchedSlice) –
- protocol (str) –
- people (Person) –
-
class
fairgraph.electrophysiology.
PatchClampExperiment
(name, recorded_cell, stimulus=None, traces=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
- Stimulation of the neural tissue and recording of the responses during a patch clamp
- recording session.
Parameters: - name (str) –
- recorded_cell (PatchedCell) –
- stimulus (StimulusType) –
- traces (Trace, MultiChannelMultiTrialRecording) –
-
class
fairgraph.electrophysiology.
QualifiedTraceGeneration
(name, stimulus_experiment, sweep, holding_potential=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
Additional information about the generation of a single-channel electrophysiology trace.
Parameters: - name (str) –
- stimulus_experiment (PatchClampExperiment, IntraCellularSharpElectrodeExperiment) –
- sweep (int) –
- holding_potential (QuantitativeValue) –
-
class
fairgraph.electrophysiology.
ImplantedBrainTissue
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
docstring
Parameters: - name (str) –
- subject (Subject) –
-
class
fairgraph.electrophysiology.
ElectrodeImplantationActivity
(subject, implanted_brain_tissues, brain_location, start_time=None, end_time=None, people=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
docstring
Parameters: - subject (Subject) –
- implanted_brain_tissues (ImplantedBrainTissue) –
- brain_location (BrainRegion) –
- start_time (datetime) –
- end_time (datetime) –
- people (Person) –
-
class
fairgraph.electrophysiology.
ExtracellularElectrodeExperiment
(name, recorded_cell, stimulus=None, traces=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchClampExperiment
docstring
Parameters: - name (str) –
- recorded_cell (ImplantedBrainTissue) –
- stimulus (StimulusType) –
- traces (Trace, MultiChannelMultiTrialRecording) –
-
class
fairgraph.electrophysiology.
IntraCellularSharpElectrodeRecordedCell
(name, brain_location, collection=None, cell_type=None, experiments=None, pipette_id=None, seal_resistance=None, pipette_resistance=None, liquid_junction_potential=None, labeling_compound=None, reversal_potential_cl=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchedCell
A cell recorded intracellularly with a sharp electrode.
Parameters: - name (str) –
- brain_location (BrainRegion) –
- collection (IntraCellularSharpElectrodeRecordedCellCollection) –
- cell_type (CellType) –
- experiments (IntraCellularSharpElectrodeExperiment) –
- pipette_id (str, int) –
- seal_resistance (QuantitativeValue) –
- pipette_resistance (QuantitativeValue) –
- liquid_junction_potential (QuantitativeValue) –
- labeling_compound (str) –
- reversal_potential_cl (QuantitativeValue) –
-
class
fairgraph.electrophysiology.
IntraCellularSharpElectrodeRecording
(name, slice, recorded_slice, protocol=None, people=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchClampActivity
A sharp-electrode recording session.
Parameters: - name (str) –
- slice (Slice) –
- recorded_slice (IntraCellularSharpElectrodeRecordedSlice) –
- protocol (str) –
- people (Person) –
-
class
fairgraph.electrophysiology.
IntraCellularSharpElectrodeRecordedCellCollection
(name, cells, slice=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchedCellCollection
A collection of cells recorded with a sharp electrode.
Parameters: - name (str) –
- cells (IntraCellularSharpElectrodeRecordedCell) –
- slice (IntraCellularSharpElectrodeRecordedSlice) –
-
class
fairgraph.electrophysiology.
IntraCellularSharpElectrodeRecordedSlice
(name, slice, recorded_cells, recording_activity=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchedSlice
A slice that has been recorded from using a sharp electrode.
Parameters: - name (str) –
- slice (Slice) –
- recorded_cells (IntraCellularSharpElectrodeRecordedCellCollection) –
- recording_activity (IntraCellularSharpElectrodeRecording) –
-
class
fairgraph.electrophysiology.
IntraCellularSharpElectrodeExperiment
(name, recorded_cell, stimulus=None, traces=None, id=None, instance=None)[source]¶ Bases:
fairgraph.electrophysiology.PatchClampExperiment
- Stimulation of the neural tissue and recording of the responses with
- a sharp intracellular electrode.
Parameters: - name (str) –
- recorded_cell (IntraCellularSharpElectrodeRecordedCell) –
- stimulus (StimulusType) –
- traces (Trace) –
-
class
fairgraph.electrophysiology.
QualifiedMultiTraceGeneration
(name, stimulus_experiment, sweeps, holding_potential=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
Parameters: - name (str) –
- stimulus_experiment (ExtracellularElectrodeExperiment, IntraCellularSharpElectrodeExperiment, PatchClampExperiment) –
- sweeps (int) –
- holding_potential (QuantitativeValue) –
brainsimulation¶
Metadata for model building, simulation and validation.
-
class
fairgraph.brainsimulation.
ModelProject
(name, owners, authors, description, date_created, private, collab_id=None, alias=None, organization=None, pla_components=None, brain_region=None, species=None, celltype=None, abstraction_level=None, model_of=None, old_uuid=None, parents=None, instances=None, images=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
,fairgraph.brainsimulation.HasAliasMixin
Representation of a neuroscience model or modelling project.
We distinguish a model in an abstract sense (this class), which may have multiple parameterizations and multiple implementations, from a specific version and parameterization of a model - seeModelInstance
andModelScript
Parameters: - name (str) –
- owners (Person) –
- authors (Person) –
- description (str) –
- date_created (datetime) –
- private (bool) –
- collab_id (int) –
- alias (str) –
- organization (Organization) –
- pla_components (str) –
- brain_region (BrainRegion) –
- species (Species) –
- celltype (CellType) –
- abstraction_level (AbstractionLevel) –
- model_of (ModelScope) –
- old_uuid (str) –
- parents (ModelProject) –
- instances (ModelInstance, MEModel) –
- images (dict) –
-
class
fairgraph.brainsimulation.
ModelInstance
(name, main_script, version, timestamp=None, brain_region=None, species=None, model_of=None, release=None, part_of=None, description=None, parameters=None, old_uuid=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
A specific implementation, code version and parameterization of a model.
Parameters: - name (str) –
- brain_region (BrainRegion) –
- species (Species) –
- model_of (CellType, BrainRegion) –
- main_script (ModelScript) –
- release (str) –
- version (str) –
- timestamp (datetime) –
- part_of (KGObject) –
- description (str) –
- parameters (str) –
- old_uuid (str) –
-
class
fairgraph.brainsimulation.
MEModel
(name, e_model, morphology, main_script, version, timestamp=None, brain_region=None, species=None, model_of=None, release=None, part_of=None, description=None, parameters=None, old_uuid=None, id=None, instance=None)[source]¶ Bases:
fairgraph.brainsimulation.ModelInstance
- A specific implementation, code version and parameterization of a single neuron model
with a defined morphology (M) and electrical (E) behaviour.
This is a specialized sub-class of
ModelInstance
.See also:
ModelProject
,ModelScript
,Morphology
,EModel
Parameters: - name (str) –
- brain_region (BrainRegion) –
- species (Species) –
- model_of (CellType, BrainRegion) –
- main_script (ModelScript) –
- release (str) –
- version (str) –
- timestamp (datetime) –
- part_of (KGObject) –
- description (str) –
- parameters (str) –
- old_uuid (str) –
- morphology (Morphology) –
- e_model (EModel) –
-
class
fairgraph.brainsimulation.
Morphology
(name, cell_type=None, morphology_file=None, distribution=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
- The morphology of a single neuron model, typically defined as a set of cylinders or
- truncated cones connected in a tree structure.
Parameters: - name (str) –
- cell_type (CellType) –
- distribution (Distribution) –
-
class
fairgraph.brainsimulation.
ModelScript
(name, code_location=None, code_format=None, license=None, distribution=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
Code or markup defining all or part of a model.
Parameters: - name (str) –
- code_format (str) –
- license (str) –
- distribution (Distribution) –
-
class
fairgraph.brainsimulation.
EModel
(name, main_script=None, version=None, timestamp=None, brain_region=None, species=None, model_of=None, release=None, part_of=None, description=None, parameters=None, old_uuid=None, id=None, instance=None)[source]¶ Bases:
fairgraph.brainsimulation.ModelInstance
The electrical component of an
MEModel
Parameters: - name (str) –
- brain_region (BrainRegion) –
- species (Species) –
- model_of (CellType, BrainRegion) –
- main_script (ModelScript) –
- release (str) –
- version (str) –
- timestamp (datetime) –
- part_of (KGObject) –
- description (str) –
- parameters (str) –
- old_uuid (str) –
-
class
fairgraph.brainsimulation.
AnalysisResult
(name, result_file=None, timestamp=None, derived_from=None, attributed_to=None, description=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
The result of a data analysis.
For example a graph, a histogram, etc. The result is expected to be stored either in a local file or in a web-accessible location with a direct URL.
Note that local results files smaller than 1 MB in size will be uploaded and stored within the Knowledge Graph. Larger files must be stored elsewhere.
Parameters: - name (str) –
- result_file (Distribution, str) –
- timestamp (datetime) –
- derived_from (KGObject) –
- attributed_to (Person) –
- description (str) –
-
class
fairgraph.brainsimulation.
ValidationTestDefinition
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
,fairgraph.brainsimulation.HasAliasMixin
Definition of a model validation test.
Parameters: - name (str) –
- authors (Person) –
- description (str) –
- date_created (date, datetime) –
- alias (str) –
- brain_region (BrainRegion) –
- species (Species) –
- celltype (CellType) –
- test_type (str) –
- age (Age) –
- reference_data (KGObject) –
- data_type (str) –
- recording_modality (str) –
- score_type (str) –
- status (str) –
- old_uuid (str) –
-
class
fairgraph.brainsimulation.
ValidationScript
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
Code implementing a particular model validation test.
Parameters: - name (str) –
- date_created (date, datetime) –
- repository (IRI) –
- version (str) –
- description (str) –
- parameters (str) –
- test_definition (ValidationTestDefinition) –
- old_uuid (str) –
-
class
fairgraph.brainsimulation.
ValidationResult
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
The results of running a model validation test.
Including a numerical score, and optional additional data.
See also:
ValidationTestDefinition
,ValidationScript
,ValidationActivity
.Parameters: - name (str) –
- generated_by (ValidationActivity) –
- description (str) –
- score (float, int) –
- normalized_score (float, int) –
- passed (bool) –
- timestamp (date, datetime) –
- additional_data (KGObject) –
- old_uuid (str) –
- collab_id (int, str) –
- hash (str) –
-
class
fairgraph.brainsimulation.
ValidationActivity
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
Record of the validation of a model against experimental data.
Parameters: - model_instance (ModelInstance, MEModel) –
- test_script (ValidationScript) –
- reference_data (Collection) –
- timestamp (datetime) –
- result (ValidationResult) –
- started_by (Person) –
- end_timestamp (datetime) –
software¶
Metadata about, or related to, software
-
class
fairgraph.software.
SoftwareCategory
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
-
class
fairgraph.software.
OperatingSystem
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
-
class
fairgraph.software.
ProgrammingLanguage
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
-
class
fairgraph.software.
Software
(name, version, summary=None, description=None, identifier=None, citation=None, license=None, release_date=None, previous_version=None, contributors=None, project=None, image=None, download_url=None, access_url=None, categories=None, subcategories=None, operating_system=None, release_notes=None, requirements=None, copyright=None, components=None, part_of=None, funding=None, languages=None, features=None, keywords=None, is_free=None, homepage=None, documentation=None, help=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
core¶
Metadata for entities that are used in multiple contexts (e.g. in both electrophysiology and in simulation).
-
class
fairgraph.core.
Subject
(name, species, age, sex=None, strain=None, death_date=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
The individual organism that is the subject of an experimental study.
Parameters:
-
class
fairgraph.core.
Organization
(name, address=None, parent=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
An organization associated with research data or models, e.g. a university, lab or department.
Parameters: - name (str) –
- address (Address) –
- parent (Organization) –
-
class
fairgraph.core.
Person
(family_name, given_name, email=None, affiliation=None, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
- A person associated with research data or models, for example as an experimentalist,
- or a data analyst.
Parameters: - family_name (str) – Family name / surname
- given_name (str) – Given name
- email (str) – e-mail address
- affiliation (Organization) – Organization to which person belongs
-
classmethod
list
(client, size=100, api='query', scope='released', resolved=False, **filters)[source]¶ List all objects of this type in the Knowledge Graph
-
class
fairgraph.core.
Protocol
(name, steps, materials, author, date_published, identifier, id=None, instance=None)[source]¶ Bases:
fairgraph.base.KGObject
An experimental protocol.
-
class
fairgraph.core.
Identifier
(id=None, instance=None, **properties)[source]¶ Bases:
fairgraph.base.KGObject
-
class
fairgraph.core.
Material
(name, molar_weight, formula, stock_keeping_unit, identifier, vendor)[source]¶ Bases:
object
Metadata about a chemical product or other material used in an experimental protocol.
commons¶
-
class
fairgraph.commons.
Address
(locality, country)[source]¶ Bases:
fairgraph.base.StructuredMetadata
-
class
fairgraph.commons.
Species
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
The species of an experimental subject, expressed with the binomial nomenclature.
-
class
fairgraph.commons.
Strain
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
An inbred sub-population within a species.
-
class
fairgraph.commons.
Sex
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
The sex of an animal or person from whom/which data were obtained.
-
class
fairgraph.commons.
BrainRegion
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
A sub-structure or region with the brain.
-
class
fairgraph.commons.
CellType
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
A type of neuron or glial cell.
-
class
fairgraph.commons.
AbstractionLevel
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
Level of abstraction for a neuroscience model, e.g.rate neurons, spiking neurons
-
class
fairgraph.commons.
ModelScope
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
docstring
-
class
fairgraph.commons.
License
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
-
class
fairgraph.commons.
StimulusType
(label, iri=None, strict=False)[source]¶ Bases:
fairgraph.base.OntologyTerm
-
class
fairgraph.commons.
QuantitativeValue
(value, unit_text, unit_code=None)[source]¶ Bases:
fairgraph.base.StructuredMetadata
docstring
fairgraph currently provides the following modules:
- minds
- “Minimal Information for Neuroscience DataSets” - metadata common to all neuroscience datasets independent of the type of investigation
- uniminds
- an updated version of MINDS
- electrophysiology
- metadata relating to patch clamp and sharp electrode intracellular recordings in vitro. Support for extracellular recording, tetrodes, multi-electrode arrays and in vivo recordings coming soon.
- brainsimulation
- metadata relating to modelling, simulation and validation
- software
- metadata relating to software used in neuroscience (for simulation, data analysis, stimulus presentation, etc.)
- core
- metadata for entities that are used in multiple contexts (e.g. in both electrophysiology and in simulation).
- commons
- metadata that are not specific to EBRAINS, typically these refer to URIs in standard ontologies, outside the Knowledge Graph.
Additional modules are planned, e.g. for fMRI, functional optical imaging. In addition, the base, commons, and utility modules provide additional tools for structuring metadata and for working with fairgraph objects.
Access permissions¶
Before accessing the Human Brain Project/EBRAINS Knowledge Graph through fairgraph, you must read and accept the Terms of Use, and then e-mail support@humanbrainproject.eu to request access.
Contributing to fairgraph¶
Todo
add information about creating tickets, sending feedback, and a developers’ guide.
Getting help¶
In case of questions about fairgraph, please e-mail support@humanbrainproject.eu. If you find a bug or would like to suggest an enhancement or new feature, please open a ticket in the issue tracker.
Authors / contributors¶
The following people have contributed to fairgraph. Their affiliations at the time of the contributions are shown below.
- Andrew Davison [1]
- Onur Ates [1]
- Yann Zerlaut [1]
- Nico Feld [2]
- Glynis Mattheisen[1]
- Department of Integrative and Computational Neuroscience, Paris-Saclay Institute of Neuroscience, CNRS/Université Paris Sud
- Human-Computer Interaction, Department IV, Computer Science, Universität Trier
Acknowledgements¶
- <div><img src=”https://www.braincouncil.eu/wp-content/uploads/2018/11/wsi-imageoptim-EU-Logo.jpg”
- alt=”EU Logo” height=”23%” width=”15%” align=”right” style=”margin-left: 10px”></div>
This open source software code was developed in part or in whole in the Human Brain Project, funded from the European Union’s Horizon 2020 Framework Programme for Research and Innovation under Specific Grant Agreements No. 720270 and No. 785907 (Human Brain Project SGA1 and SGA2).
Quickstart¶
Installation¶
To get the latest release:
pip install fairgraph
To get the development version:
git clone https://github.com/HumanBrainProject/fairgraph.git
pip install -r ./fairgraph/requirements.txt
pip install -U ./fairgraph
Basic setup¶
The basic idea of the library is to represent metadata nodes from the Knowledge Graph as Python objects. Communication with the Knowledge Graph service is through a client object, for which an access token associated with an HBP Identity account is needed.
If you are working in a Collaboratory Jupyter notebook:
from jupyter_collab_storage import oauth_token_handler
token = oauth_token_handler.get_token()
If working outside the Collaboratory, we recommend you obtain a token from https://nexus-iam.humanbrainproject.org/v0/oauth2/authorize and save it as an environment variable, e.g. at a shell prompt:
export HBP_AUTH_TOKEN=eyJhbGci...nPq
and then in Python:
token = os.environ['HBP_AUTH_TOKEN']
Once you have a token:
from fairgraph import KGClient
client = KGClient(token)
Retrieving metadata from the Knowledge Graph¶
The different metadata/data types available in the Knowledge Graph are grouped into modules, currently commons, core, brainsimulation, electrophysiology, software, minds and uniminds. For example:
from fairgraph.commons import BrainRegion
from fairgraph.electrophysiology import PatchedCell
Using these classes, it is possible to list all metadata matching a particular criterion, e.g.:
cells_in_ca1 = PatchedCell.list(client, brain_region=BrainRegion("hippocampus CA1"))
If you know the unique identifier of an object, you can retrieve it directly:
cell_of_interest = PatchedCell.from_uuid("153ec151-b1ae-417b-96b5-4ce9950a3c56", client)
Links between metadata in the Knowledge Graph are not followed automatically, to avoid unnecessary network traffic, but can be followed with the resolve() method:
example_cell = cells_in_ca1[3]
experiment = example_cell.experiments.resolve(client)
trace = experiment.traces.resolve(client)
The associated metadata is accessible as attributes of the Python objects, e.g.:
print(example_cell.cell_type)
print(example_cell.reversal_potential_cl)
print(trace.time_step)
print(trace.data_unit)
You can also access any associated data:
import requests
import numpy as np
from io import BytesIO
download_url = trace.data_location['downloadURL']
data = np.genfromtxt(BytesIO(requests.get(download_url).content))
Advanced queries¶
While certain filters and queries are built in (such as the filter by brain region, above), more complex queries are possible using the Nexus query API.
from fairgraph.base import KGQuery
from fairgraph.minds import Dataset
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("* " + dataset.name)
Storing and editing metadata¶
For those users who have the necessary permissions to store and edit metadata in the Knowledge Graph, fairgraph objects can be created or edited in Python, and then saved back to the Knowledge Graph, e.g.:
from fairgraph.core import Person, Organization, use_namespace
from fairgraph.commons import Address
use_namespace("neuralactivity")
mgm = Organization("Metro-Goldwyn-Mayer")
mgm.save(client)
author = Person("Laurel", "Stan", "laurel@example.com", affiliation=mgm)
author.save(client)
mgm.address = Address(locality='Hollywood', country='United States')
mgm.save(client)
Getting help¶
In case of questions about fairgraph, please e-mail support@humanbrainproject.eu. If you find a bug or would like to suggest an enhancement or new feature, please open a ticket in the issue tracker.
Acknowledgements¶

This open source software code was developed in part or in whole in the Human Brain Project, funded from the European Union’s Horizon 2020 Framework Programme for Research and Innovation under Specific Grant Agreements No. 720270 and No. 785907 (Human Brain Project SGA1 and SGA2).