Skip to content

Commit

Permalink
Merge pull request #39 from ssciwr/fix_38_mock_nwb_metadata
Browse files Browse the repository at this point in the history
add `get_sample_nwb_metadata()`
  • Loading branch information
lkeegan authored May 2, 2022
2 parents 2111315 + 2650f48 commit 7c46dee
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
47 changes: 47 additions & 0 deletions mease_elabftw/nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,50 @@ def validate_pynwb_data(nwb_metadata):
io.close()

return validation_bool


def get_sample_nwb_metadata(experiment_id):
"""
Returns sample NWB metadata for testing purposes without needing an ElabFTW token.
:param experiment_id: Ignored - this function always returns the same sample metadata
:return: Sample NWB metadata
:rtype: dict
"""

# Output of get_nwb_metadata(156) with a valid elabftw token.
# Note: this needs to be updated when this output changes.
return {
"NWBFile": {
"session_description": "test fake experiment with json metadata",
"identifier": "20211001-8b6f100d66f4312d539c52620f79d6a503c1e2d1",
"session_start_time": "2021-10-01 11:13:47",
"experimenter": ["Liam Keegan"],
"institution": "Heidelberg University, Physiology and Pathophysiology",
"lab": "Medical Biophysics, Groh/Mease",
"virus": "AAVretr ChR2-tdTomato:\n * Virus in -80 storage: AAVrg-CAG-hChR2-tdTomato (AAV Retrograde)\n * Origin: Addgene\n * Comments: retrograde\n * Expression Quality: \n * product number: \nAAVretr Flpo:\n * Virus in -80 storage: AAVretr EF1a-Flpo\n * Origin: Addgene\n * Comments: retrograde Flip\n * Expression Quality: \n * product number: 55637-AAVrg\n",
},
"Subject": {
"sex": "unknown",
"weight": 0.002,
"genotype": "Nt1Cre-ChR2-EYFP",
"subject_id": "xy1",
"description": "test mouse",
"date_of_birth": "2000-01-01",
},
"Ecephys": {},
"Other": {
"OptogeneticStimulationSite": {
"device": "the device",
"location": "S1: primary somatosensory cortex",
"description": "laser stimulation",
"excitation_lambda": "473",
},
"SiliconProbe": {
"Probe identifier:": "1234356",
"ElectrodeGroup.name": "H5",
"ElectrodeGroup.description": "a test H5 probe",
},
},
}
6 changes: 6 additions & 0 deletions mease_elabftw/tests/test_nwb.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ def test_validate_pynwb_data():
nwb_metadata["NWBFile"]["session_start_time"] = ""
with pytest.raises(ValueError) as ValueError_info:
mease_elabftw.nwb.validate_pynwb_data(nwb_metadata)


def test_get_sample_nwb_metadata():
nwb_metadata = mease_elabftw.nwb.get_nwb_metadata(test_ids.valid_experiment)
sample_nwb_metadata = mease_elabftw.nwb.get_sample_nwb_metadata(123)
assert nwb_metadata == sample_nwb_metadata

0 comments on commit 7c46dee

Please sign in to comment.