Skip to content

Commit

Permalink
Merge pull request #231 from AllenNeuralDynamics/release-v0.23.0
Browse files Browse the repository at this point in the history
Release v0.23.0
  • Loading branch information
jtyoung84 authored Jan 23, 2025
2 parents 37f43f9 + e503c3f commit 09edc84
Show file tree
Hide file tree
Showing 5 changed files with 251 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/aind_metadata_mapper/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
"""Init package"""

__version__ = "0.22.2"
__version__ = "0.23.0"
18 changes: 18 additions & 0 deletions src/aind_metadata_mapper/gather_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from aind_data_schema.core.metadata import Metadata
from aind_data_schema.core.procedures import Procedures
from aind_data_schema.core.processing import PipelineProcess, Processing
from aind_data_schema.core.quality_control import QualityControl
from aind_data_schema.core.rig import Rig
from aind_data_schema.core.session import Session
from aind_data_schema.core.subject import Subject
Expand Down Expand Up @@ -304,6 +305,17 @@ def get_rig_metadata(self) -> Optional[dict]:
else:
return None

def get_quality_control_metadata(self) -> Optional[dict]:
"""Get quality_control metadata"""
file_name = QualityControl.default_filename()
if self._does_file_exist_in_user_defined_dir(file_name=file_name):
contents = self._get_file_from_user_defined_directory(
file_name=file_name
)
return contents
else:
return None

def get_acquisition_metadata(self) -> Optional[dict]:
"""Get acquisition metadata"""
file_name = Acquisition.default_filename()
Expand Down Expand Up @@ -388,6 +400,10 @@ def load_model(
self.settings.metadata_settings.session_filepath, Session
)
rig = load_model(self.settings.metadata_settings.rig_filepath, Rig)
quality_control = load_model(
self.settings.metadata_settings.quality_control_filepath,
QualityControl,
)
acquisition = load_model(
self.settings.metadata_settings.acquisition_filepath, Acquisition
)
Expand All @@ -410,6 +426,7 @@ def load_model(
processing=processing,
acquisition=acquisition,
instrument=instrument,
quality_control=quality_control,
)
metadata_json = json.loads(metadata.model_dump_json(by_alias=True))
return metadata_json
Expand All @@ -430,6 +447,7 @@ def load_model(
metadata_json["processing"] = processing
metadata_json["acquisition"] = acquisition
metadata_json["instrument"] = instrument
metadata_json["quality_control"] = quality_control
return metadata_json

def _write_json_file(self, filename: str, contents: dict) -> None:
Expand Down
1 change: 1 addition & 0 deletions src/aind_metadata_mapper/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ class MetadataSettings(BaseSettings, extra="allow"):
processing_filepath: Optional[Path] = None
acquisition_filepath: Optional[Path] = None
instrument_filepath: Optional[Path] = None
quality_control_filepath: Optional[Path] = None


class JobSettings(BaseSettings, extra="allow"):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
{
"describedBy": "https://raw.githubusercontent.com/AllenNeuralDynamics/aind-data-schema/main/src/aind_data_schema/core/quality_control.py",
"schema_version": "1.2.2",
"evaluations": [
{
"modality": {
"name": "Extracellular electrophysiology",
"abbreviation": "ecephys"
},
"stage": "Raw data",
"name": "Drift map",
"description": "Check that all probes show minimal drift",
"metrics": [
{
"name": "Probe A drift",
"value": {
"value": "",
"options": [
"Low",
"Medium",
"High"
],
"status": [
"Pass",
"Fail",
"Fail"
],
"type": "dropdown"
},
"status_history": [
{
"evaluator": "",
"status": "Pending",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": "Qualitative check that drift map shows minimal movement",
"reference": "ecephys-drift-map",
"evaluated_assets": null
},
{
"name": "Probe B drift",
"value": {
"value": "",
"options": [
"No Drift",
"Drift visible in part of session",
"Drift visible in entire session",
"Sudden movement event"
],
"status": [
"Pass",
"Pass",
"Fail",
"Fail"
],
"type": "checkbox"
},
"status_history": [
{
"evaluator": "",
"status": "Pending",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": "Qualitative check that drift map shows minimal movement",
"reference": "ecephys-drift-map",
"evaluated_assets": null
},
{
"name": "Probe C drift",
"value": "Low",
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": null,
"reference": "ecephys-drift-map",
"evaluated_assets": null
}
],
"tags": null,
"notes": "",
"allow_failed_metrics": false,
"latest_status": "Pending",
"created": "2022-11-22T00:00:00Z"
},
{
"modality": {
"name": "Behavior videos",
"abbreviation": "behavior-videos"
},
"stage": "Raw data",
"name": "Video frame count check",
"description": null,
"metrics": [
{
"name": "Expected frame count",
"value": 662,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": "Expected frame count from experiment length, always pass",
"reference": null,
"evaluated_assets": null
},
{
"name": "Video 1 frame count",
"value": 662,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": "Pass when frame count matches expected",
"reference": null,
"evaluated_assets": null
},
{
"name": "Video 2 num frames",
"value": 662,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": "Pass when frame count matches expected",
"reference": null,
"evaluated_assets": null
}
],
"tags": null,
"notes": "Pass when video_1_num_frames==video_2_num_frames",
"allow_failed_metrics": false,
"latest_status": "Pass",
"created": "2022-11-22T00:00:00Z"
},
{
"modality": {
"name": "Extracellular electrophysiology",
"abbreviation": "ecephys"
},
"stage": "Raw data",
"name": "Probes present",
"description": "Pass when data from a probe is present",
"metrics": [
{
"name": "ProbeA",
"value": true,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": null,
"reference": null,
"evaluated_assets": null
},
{
"name": "ProbeB",
"value": true,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": null,
"reference": null,
"evaluated_assets": null
},
{
"name": "ProbeC",
"value": true,
"status_history": [
{
"evaluator": "Automated",
"status": "Pass",
"timestamp": "2022-11-22T00:00:00Z"
}
],
"description": null,
"reference": null,
"evaluated_assets": null
}
],
"tags": null,
"notes": null,
"allow_failed_metrics": false,
"latest_status": "Pass",
"created": "2022-11-22T00:00:00Z"
}
],
"notes": null
}
22 changes: 22 additions & 0 deletions tests/test_gather_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,6 +644,28 @@ def test_get_rig_metadata_none(self):
contents = metadata_job.get_rig_metadata()
self.assertIsNone(contents)

def test_get_quality_control_metadata(self):
"""Tests get_quality_control_metadata"""
metadata_dir = RESOURCES_DIR / "metadata_files"

job_settings = JobSettings(
directory_to_write_to=RESOURCES_DIR,
metadata_dir=metadata_dir,
)
metadata_job = GatherMetadataJob(settings=job_settings)
contents = metadata_job.get_quality_control_metadata()
self.assertIsNotNone(contents)

def test_get_quality_control_metadata_none(self):
"""Tests get_quality_control_metadata returns none"""

job_settings = JobSettings(
directory_to_write_to=RESOURCES_DIR,
)
metadata_job = GatherMetadataJob(settings=job_settings)
contents = metadata_job.get_quality_control_metadata()
self.assertIsNone(contents)

def test_get_problematic_rig_metadata(self):
"""Tests get_rig_metadata when there is a pydantic serialization
issue."""
Expand Down

0 comments on commit 09edc84

Please sign in to comment.