Skip to content

Commit

Permalink
Merge pull request #146 from JaerongA/metrics
Browse files Browse the repository at this point in the history
Remap `metrics.csv` column names
  • Loading branch information
kabilar authored Apr 19, 2023
2 parents 5abecc3 + 6b069e6 commit 6aef807
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
[Keep a Changelog](https://keepachangelog.com/en/1.0.0/) convention.

## [0.2.7] - 2023-04-19

+ Bugfix - A name remapping dictionary was added to ensure consistency between the column names of the `metrics.csv` file and the attribute names of the `QualityMetrics` table

## [0.2.6] - 2023-04-17

+ Fix - Update Pandas DataFrame column name to insert `pt_ratio` in `QualityMetrics.Waveform` table
Expand Down Expand Up @@ -101,6 +105,7 @@ Observes [Semantic Versioning](https://semver.org/spec/v2.0.0.html) standard and
+ Add - Probe table supporting: Neuropixels probes 1.0 - 3A, 1.0 - 3B, 2.0 - SS,
2.0 - MS

[0.2.7]: https://github.com/datajoint/element-array-ephys/releases/tag/0.2.7
[0.2.6]: https://github.com/datajoint/element-array-ephys/releases/tag/0.2.6
[0.2.5]: https://github.com/datajoint/element-array-ephys/releases/tag/0.2.5
[0.2.4]: https://github.com/datajoint/element-array-ephys/releases/tag/0.2.4
Expand Down
6 changes: 6 additions & 0 deletions element_array_ephys/ephys_acute.py
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,11 @@ def make(self, key):
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)

metric_fp = kilosort_dir / "metrics.csv"
rename_dict = {
"isi_viol": "isi_violation",
"num_viol": "number_violation",
"contam_rate": "contamination_rate",
}

if not metric_fp.exists():
raise FileNotFoundError(f"QC metrics file not found: {metric_fp}")
Expand All @@ -1361,6 +1366,7 @@ def make(self, key):
metrics_df.set_index("cluster_id", inplace=True)
metrics_df.replace([np.inf, -np.inf], np.nan, inplace=True)
metrics_df.columns = metrics_df.columns.str.lower()
metrics_df.rename(columns=rename_dict, inplace=True)
metrics_list = [
dict(metrics_df.loc[unit_key["unit"]], **unit_key)
for unit_key in (CuratedClustering.Unit & key).fetch("KEY")
Expand Down
6 changes: 6 additions & 0 deletions element_array_ephys/ephys_chronic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,11 @@ def make(self, key):
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)

metric_fp = kilosort_dir / "metrics.csv"
rename_dict = {
"isi_viol": "isi_violation",
"num_viol": "number_violation",
"contam_rate": "contamination_rate",
}

if not metric_fp.exists():
raise FileNotFoundError(f"QC metrics file not found: {metric_fp}")
Expand All @@ -1290,6 +1295,7 @@ def make(self, key):
metrics_df.set_index("cluster_id", inplace=True)
metrics_df.replace([np.inf, -np.inf], np.nan, inplace=True)
metrics_df.columns = metrics_df.columns.str.lower()
metrics_df.rename(columns=rename_dict, inplace=True)
metrics_list = [
dict(metrics_df.loc[unit_key["unit"]], **unit_key)
for unit_key in (CuratedClustering.Unit & key).fetch("KEY")
Expand Down
6 changes: 6 additions & 0 deletions element_array_ephys/ephys_no_curation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,11 @@ def make(self, key):
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)

metric_fp = kilosort_dir / "metrics.csv"
rename_dict = {
"isi_viol": "isi_violation",
"num_viol": "number_violation",
"contam_rate": "contamination_rate",
}

if not metric_fp.exists():
raise FileNotFoundError(f"QC metrics file not found: {metric_fp}")
Expand All @@ -1301,6 +1306,7 @@ def make(self, key):
metrics_df.set_index("cluster_id", inplace=True)
metrics_df.replace([np.inf, -np.inf], np.nan, inplace=True)
metrics_df.columns = metrics_df.columns.str.lower()
metrics_df.rename(columns=rename_dict, inplace=True)
metrics_list = [
dict(metrics_df.loc[unit_key["unit"]], **unit_key)
for unit_key in (CuratedClustering.Unit & key).fetch("KEY")
Expand Down
8 changes: 6 additions & 2 deletions element_array_ephys/ephys_precluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,6 @@ def make(self, key):
][recorded_site]
electrode_keys.append(probe_electrodes[(shank, shank_col, shank_row)])
elif acq_software == "Open Ephys":

session_dir = find_full_path(
get_ephys_root_data_dir(), get_session_directory(key)
)
Expand Down Expand Up @@ -1270,6 +1269,11 @@ def make(self, key):
kilosort_dir = find_full_path(get_ephys_root_data_dir(), output_dir)

metric_fp = kilosort_dir / "metrics.csv"
rename_dict = {
"isi_viol": "isi_violation",
"num_viol": "number_violation",
"contam_rate": "contamination_rate",
}

if not metric_fp.exists():
raise FileNotFoundError(f"QC metrics file not found: {metric_fp}")
Expand All @@ -1278,7 +1282,7 @@ def make(self, key):
metrics_df.set_index("cluster_id", inplace=True)
metrics_df.replace([np.inf, -np.inf], np.nan, inplace=True)
metrics_df.columns = metrics_df.columns.str.lower()

metrics_df.rename(columns=rename_dict, inplace=True)
metrics_list = [
dict(metrics_df.loc[unit_key["unit"]], **unit_key)
for unit_key in (CuratedClustering.Unit & key).fetch("KEY")
Expand Down
2 changes: 1 addition & 1 deletion element_array_ephys/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Package metadata."""
__version__ = "0.2.6"
__version__ = "0.2.7"

0 comments on commit 6aef807

Please sign in to comment.