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

added cli to anatomical_structure_translator #37

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
53 changes: 32 additions & 21 deletions bkbit/data_translators/README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,38 @@
# specimen_portal_translator.py
# anatomical_structure_translator.py

specimen_portal_translator retrieves data from the Specimen Portal using the NIMP API and then generates respective data classes using classes defined in library_generation.py.

## Usage
## Overview
anatomical_structure_translator will create a single .jsonld file containing the objects generated from all the files in the “package” directory. All data objects are defined in the [Anatomical Structure Schema](https://brain-bican.github.io/models/index_anatomical_structure/)

## Command Line
### gen-geneannotation
```python
gen-anatomicalstructure path/to/csv_directory
```

## Required Format of Data
Each .csv must have the **specific column names** listed below in the **given order**.

| File Name | Column Names |
|--------------------------------------|-------------------------------------------------------------------------------------------------------------|
| anatomical_annotation_set | label, name, description, revision_of, version, anatomical_space_label |
| anatomical_space | label, name, description, revision_of, version, image_dataset_label |
| image_dataset | label, name, description, revision_of, version, x_direction, y_direction, z_direction, x_size, y_size, z_size, x_resolution, y_resolution, z_resolution, unit |
| parcellation_annotation | internal_identifier, anatomical_annotation_set_label, voxel_count |
| parcellation_annotation_term_map | internal_identifier, anatomical_annotation_set_label, parcellation_term_identifier, parcellation_term_set_label, parcellation_terminology_label |
| parcellation_atlas | label, name, description, specialization_of, revision_of, version, anatomical_space_label, anatomical_annotation_set_label, parcellation_terminology_label |
| parcellation_color_assignment | parcellation_color_scheme_label, parcellation_term_identifier, parcellation_terminology_label, color_hex_triplet |
| parcellation_color_scheme | label, name, description, revision_of, version, parcellation_terminology_label |
| parcellation_term_set | label, name, description, parcellation_terminology_label, parcellation_term_set_order, parcellation_parent_term_set_label |
| parcellation_term | name, symbol, description, parcellation_term_set_label, parcellation_terminology_label, parcellation_term_identifier, parcellation_term_order, parcellation_parent_term_set_label, parcellation_parent_term_identifier |
| parcellation_terminology | label, name, description, revision_of, version |


## Examples
#### Example 1

# Step 0: Download Mapping Data bkbit.utils.bican_to_nimp_slots.csv and set correct path in specimen_portal_translator.py line 7

# Step 1: Import specimen_portal_translator
from bkbit.data_translators.libray_generation_translator import SpecimenPortal

# Step 2: Retrieve Personal API Token from SpecimenPortal
token = ...

# Step 3: Initialize SpecimenPortal instance
sp = SpecimenPortal(token)
```python
pip install bkbit

# Step 4: Generate respective BICAN data objects for provided nhash_id and its ancestors:
nhash_id = ... # i.e. nhashid = 'LP-CVFLMQ819998'
sp.parse_nhash_id(nhash_id)
gen-anatomicalstructure path/to/package_dir > output.jsonld
```

# Step 5: Serialize BICAN data objects to jsonld
output_file_name = ... # i.e. output_file_name = output_LP-CVFLMQ819998.jsonld
sp.serialize_to_jsonld(output_file_name)
```
Loading