-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dependency and restructure fixes (#343)
* fix: 1355 dependency and restructure fix * Fix: add build.yml for github actions * Fix: run build on push * chore: add pre-commit hooks: isort, black, flake8, pydocstyle (#1412) * style: applied isort, black * fix: flake8 config * fix: removing stale directories * feat: add additional pre-commit flags, updated make * refactor: archived old code * ci: #1411 move from CircleCI to GitHub Actions * refactor: resolve flake8 issues * fix: unify Makefile commands and pre-commit hooks * docs: add requirements.txt for readthedocs * fix: resolve missing import and flake8 issues * test: update stain_texture test fname * test: removing unneeded param for stain fx, updating test * test: update assertion statement * Fix: utils unit test * fix: deprecated numpy type * feat: add scale_factor to dsa bitmask-polygon * test: fixing binary fieldname in parquet file, adding back schema * fix: build readthedocs with poetry * Revert "docs: add requirements.txt for readthedocs" This reverts commit 6424674. Co-authored-by: kohlia <[email protected]>
- Loading branch information
Showing
1,125 changed files
with
19,397 additions
and
272,438 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,165 @@ | ||
from enum import Enum | ||
|
||
|
||
|
||
class NodeType(object): | ||
""" | ||
NodeType object defines the schema used to populate a graph node. | ||
""" | ||
NodeType object defines the schema used to populate a graph node. | ||
:param: node_type: node type. e.g. scan | ||
:param: name: required node name. e.g. scan-123 | ||
:param: schema: list of column names. e.g. slide_id | ||
""" | ||
def __init__(self, node_type, name, schema=[]): | ||
:param: node_type: node type. e.g. scan | ||
:param: name: required node name. e.g. scan-123 | ||
:param: schema: list of column names. e.g. slide_id | ||
""" | ||
|
||
self.type = node_type | ||
self.name = name | ||
self.schema = schema | ||
def __init__(self, node_type, name, schema=[]): | ||
|
||
self.type = node_type | ||
self.name = name | ||
self.schema = schema | ||
|
||
def get_all_schema(self): | ||
""" | ||
Name is a required field, but it's still a property of this node. | ||
Return the properties including the name property! | ||
""" | ||
return self.schema + [self.name] | ||
def get_all_schema(self): | ||
""" | ||
Name is a required field, but it's still a property of this node. | ||
Return the properties including the name property! | ||
""" | ||
return self.schema + [self.name] | ||
|
||
|
||
class Graph(object): | ||
""" | ||
Graph object that stores src-[relationship]-target information. | ||
This object is used get data from existing delta tables to populate the graph database. | ||
""" | ||
Graph object that stores src-[relationship]-target information. | ||
This object is used get data from existing delta tables to populate the graph database. | ||
:param: src: NodeType - source node | ||
:param: relationship: str - relationship name e.g. HAS_PX, HAS_RECORD etc | ||
:param: target: NodeType - target node | ||
""" | ||
|
||
:param: src: NodeType - source node | ||
:param: relationship: str - relationship name e.g. HAS_PX, HAS_RECORD etc | ||
:param: target: NodeType - target node | ||
""" | ||
def __init__(self, src, relationship, target): | ||
def __init__(self, src, relationship, target): | ||
|
||
self.src = src | ||
self.relationship = relationship | ||
self.target = target | ||
self.src = src | ||
self.relationship = relationship | ||
self.target = target | ||
|
||
|
||
class GraphEnum(Enum): | ||
""" | ||
Defines Graph relationships. | ||
We assume that all properties come from the table defined in GraphEnum.name | ||
name: data type | ||
value: list of Graphs - to accomodate multiple relationship update | ||
>>> GraphEnum['DICOM'].value[0].src.type | ||
'patient' | ||
""" | ||
accession_radiology_dicom = NodeType("accession", "metadata.AccessionNumber") | ||
accession_radiology = NodeType("accession", "accession_number") | ||
scan = NodeType("scan", "metadata.SeriesInstanceUID") | ||
|
||
# radiology | ||
DICOM = [Graph(NodeType("patient", "metadata.PatientID"), | ||
"HAS_CASE", | ||
accession_radiology_dicom), | ||
Graph(accession_radiology_dicom, | ||
"HAS_SCAN", | ||
scan), | ||
Graph(scan, | ||
"HAS_DATA", | ||
NodeType("DicomSeries", "metadata.SeriesInstanceUID", ["path"]))] | ||
|
||
MHA = [Graph(accession_radiology, | ||
"HAS_DATA", | ||
NodeType("VolumetricLabel", "scan_annotation_record_uuid", ["path", "label"]))] | ||
|
||
MHD = [Graph(accession_radiology, | ||
"HAS_DATA", | ||
NodeType("VolumetricImage", "scan_annotation_record_uuid", ["path"]))] | ||
|
||
PNG = [Graph(scan, "HAS_DATA", NodeType("DicomImageSeries", "png_record_uuid", ["metadata.SeriesInstanceUID", "label"]))] | ||
FEATURE = [Graph(scan, "HAS_DATA", NodeType("DicomImageSeries", "feature_record_uuid", ["metadata.SeriesInstanceUID", "label"]))] | ||
|
||
# pathology | ||
slide = NodeType("slide", "slide_id", ["sv_project_id","slideviewer_path"]) | ||
REGIONAL_BITMASK = [Graph(slide, | ||
"HAS_DATA", | ||
NodeType("RegionalAnnotationBitmap", "bmp_record_uuid", ["user","date_updated","latest"]))] | ||
|
||
# regional concat geojson table contains regional geojson table + concatenated jsons | ||
REGIONAL_CONCAT_GEOJSON = [Graph(slide, | ||
"HAS_DATA", | ||
NodeType("RegionalAnnotationJSON", "concat_geojson_record_uuid", ["labelset","date_updated","latest"]))] | ||
|
||
|
||
POINT_RAW_JSON = [Graph(slide, | ||
"HAS_DATA", | ||
NodeType("PointAnnotation", "sv_json_record_uuid", ["user","date_updated","latest"]))] | ||
|
||
POINT_GEOJSON = [Graph(slide, | ||
"HAS_DATA", | ||
NodeType("PointAnnotationJson", "geojson_record_uuid", ["labelset","date_updated","latest"]))] | ||
""" | ||
Defines Graph relationships. | ||
We assume that all properties come from the table defined in GraphEnum.name | ||
name: data type | ||
value: list of Graphs - to accomodate multiple relationship update | ||
>>> GraphEnum['DICOM'].value[0].src.type | ||
'patient' | ||
""" | ||
|
||
accession_radiology_dicom = NodeType("accession", "metadata.AccessionNumber") | ||
accession_radiology = NodeType("accession", "accession_number") | ||
scan = NodeType("scan", "metadata.SeriesInstanceUID") | ||
|
||
# radiology | ||
DICOM = [ | ||
Graph( | ||
NodeType("patient", "metadata.PatientID"), | ||
"HAS_CASE", | ||
accession_radiology_dicom, | ||
), | ||
Graph(accession_radiology_dicom, "HAS_SCAN", scan), | ||
Graph( | ||
scan, | ||
"HAS_DATA", | ||
NodeType("DicomSeries", "metadata.SeriesInstanceUID", ["path"]), | ||
), | ||
] | ||
|
||
MHA = [ | ||
Graph( | ||
accession_radiology, | ||
"HAS_DATA", | ||
NodeType( | ||
"VolumetricLabel", "scan_annotation_record_uuid", ["path", "label"] | ||
), | ||
) | ||
] | ||
|
||
MHD = [ | ||
Graph( | ||
accession_radiology, | ||
"HAS_DATA", | ||
NodeType("VolumetricImage", "scan_annotation_record_uuid", ["path"]), | ||
) | ||
] | ||
|
||
PNG = [ | ||
Graph( | ||
scan, | ||
"HAS_DATA", | ||
NodeType( | ||
"DicomImageSeries", | ||
"png_record_uuid", | ||
["metadata.SeriesInstanceUID", "label"], | ||
), | ||
) | ||
] | ||
FEATURE = [ | ||
Graph( | ||
scan, | ||
"HAS_DATA", | ||
NodeType( | ||
"DicomImageSeries", | ||
"feature_record_uuid", | ||
["metadata.SeriesInstanceUID", "label"], | ||
), | ||
) | ||
] | ||
|
||
# pathology | ||
slide = NodeType("slide", "slide_id", ["sv_project_id", "slideviewer_path"]) | ||
REGIONAL_BITMASK = [ | ||
Graph( | ||
slide, | ||
"HAS_DATA", | ||
NodeType( | ||
"RegionalAnnotationBitmap", | ||
"bmp_record_uuid", | ||
["user", "date_updated", "latest"], | ||
), | ||
) | ||
] | ||
|
||
# regional concat geojson table contains regional geojson table + concatenated jsons | ||
REGIONAL_CONCAT_GEOJSON = [ | ||
Graph( | ||
slide, | ||
"HAS_DATA", | ||
NodeType( | ||
"RegionalAnnotationJSON", | ||
"concat_geojson_record_uuid", | ||
["labelset", "date_updated", "latest"], | ||
), | ||
) | ||
] | ||
|
||
POINT_RAW_JSON = [ | ||
Graph( | ||
slide, | ||
"HAS_DATA", | ||
NodeType( | ||
"PointAnnotation", | ||
"sv_json_record_uuid", | ||
["user", "date_updated", "latest"], | ||
), | ||
) | ||
] | ||
|
||
POINT_GEOJSON = [ | ||
Graph( | ||
slide, | ||
"HAS_DATA", | ||
NodeType( | ||
"PointAnnotationJson", | ||
"geojson_record_uuid", | ||
["labelset", "date_updated", "latest"], | ||
), | ||
) | ||
] |
Oops, something went wrong.