forked from datajoint/element-miniscope
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request datajoint#39 from CBroz1/main
Add CaImAn QC metrics
- Loading branch information
Showing
14 changed files
with
515 additions
and
35 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 |
---|---|---|
|
@@ -104,3 +104,4 @@ temp/* | |
/docs/site/ | ||
/docs/src/tutorials/*ipynb | ||
/docs/mike-mkdocs* | ||
element_miniscope/qc.py |
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
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import datajoint as dj | ||
|
||
schema = dj.schema() | ||
|
||
miniscope = None | ||
|
||
|
||
def activate( | ||
schema_name, miniscope_schema_name, *, create_schema=True, create_tables=True | ||
): | ||
"""Activate this schema. | ||
The "activation" of miniscope_report should be evoked by the miniscope module | ||
Args: | ||
schema_name (str): schema name on the database server to activate the | ||
`miniscope_report` schema | ||
miniscope_schema_name (str): schema name of the activated miniscope element for | ||
which this miniscope_report schema will be downstream from | ||
create_schema (bool): when True (default), create schema in the database if it | ||
does not yet exist. | ||
create_tables (str): when True (default), create schema takes in the database | ||
if they do not yet exist. | ||
""" | ||
global miniscope | ||
miniscope = dj.create_virtual_module("miniscope", miniscope_schema_name) | ||
schema.activate( | ||
schema_name, | ||
create_schema=create_schema, | ||
create_tables=create_tables, | ||
add_objects=miniscope.__dict__, | ||
) | ||
|
||
|
||
@schema | ||
class QualityMetrics(dj.Imported): | ||
definition = """ | ||
-> miniscope.Curation | ||
--- | ||
r_values=null : longblob # space correlation for each component | ||
snr=null : longblob # trace SNR for each component | ||
cnn_preds=null : longblob # CNN predictions for each component | ||
""" | ||
|
||
def make(self, key): | ||
from .miniscope import get_loader_result | ||
|
||
method, loaded_result = get_loader_result(key, miniscope.Curation) | ||
assert ( | ||
method == "caiman" | ||
), f"Quality figures for {method} not yet implemented. Try CaImAn." | ||
|
||
key.update( | ||
{ | ||
attrib_name: getattr(loaded_result.cnmf.estimates, attrib, None) | ||
for attrib_name, attrib in zip( | ||
["r_values", "snr", "cnn_preds"], | ||
["r_values", "SNR_comp", "cnn_preds"], | ||
) | ||
} | ||
) | ||
|
||
self.insert1(key) |
Oops, something went wrong.