From 3ba11c6540de8877bf4e44da757158cd28791d23 Mon Sep 17 00:00:00 2001 From: bjhardcastle Date: Wed, 29 May 2024 15:19:45 -0700 Subject: [PATCH] Update `units.raw_structure` description and remove `raw_location` --- src/npc_sessions/sessions.py | 15 +++++++-------- src/npc_sessions/utils/electrodes.py | 5 ++--- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/npc_sessions/sessions.py b/src/npc_sessions/sessions.py index 16c59da0..538e86c9 100644 --- a/src/npc_sessions/sessions.py +++ b/src/npc_sessions/sessions.py @@ -1323,15 +1323,13 @@ def electrodes(self) -> pynwb.core.DynamicTable: "z", ) + column_names ccf_df = utils.get_tissuecyte_electrodes_table(self.id) - if "raw_location" in ccf_df: + if "raw_structure" in ccf_df: column_names = column_names + ( - "raw_location", "raw_structure", ) column_description = { "structure": "acronym for the Allen CCF structure that the electrode recorded from - less-specific than `location`", - "raw_location": "raw non-processed (for white matter areas (lowercase), will be different than location) acronym for the Allen CCF strucutre that the electrode recorded from", - "raw_structure": "raw non-processed (for white matter areas (lowercase), will be different than structure) acronym for the Allen CCF strucutre that the electrode recorded from - less specific than location", + "raw_structure": "same as `structure`, except white matter areas (lowercase names) have not been reassigned", "x": "x coordinate in the Allen CCF, +x is posterior", "y": "y coordinate in the Allen CCF, +y is inferior", "z": "z coordinate in the Allen CCF, +z is right", @@ -1356,7 +1354,7 @@ def electrodes(self) -> pynwb.core.DynamicTable: group = self.electrode_groups[f"probe{probe_letter}"] for channel_label, (x, y) in channel_pos_xy.items(): channel_idx = int(channel_label.strip("CH")) - kwargs: dict[str, str | float] = { + row_kwargs: dict[str, str | float] = { "group": group, "group_name": group.name, "rel_x": x, @@ -1373,13 +1371,14 @@ def electrodes(self) -> pynwb.core.DynamicTable: ) ).any() ): - kwargs |= ( - annotated_probes.query(f"channel == {channel_idx}") + row_kwargs |= ( + annotated_probes + .query(f"channel == {channel_idx}") .iloc[0] .to_dict() ) electrodes.add_row( - **kwargs, + **row_kwargs, ) return electrodes diff --git a/src/npc_sessions/utils/electrodes.py b/src/npc_sessions/utils/electrodes.py index 81fa42f3..36fe811a 100644 --- a/src/npc_sessions/utils/electrodes.py +++ b/src/npc_sessions/utils/electrodes.py @@ -20,7 +20,7 @@ def get_tissuecyte_electrodes_table( >>> df = get_tissuecyte_electrodes_table('626791_2022-08-16') >>> df.columns Index(['group_name', 'channel', 'location', 'structure', 'x', 'y', 'z', - 'raw_location', 'raw_structure'], + 'raw_structure'], dtype='object') """ electrode_files = npc_lims.get_tissuecyte_annotation_files_from_s3(session) @@ -62,10 +62,9 @@ def get_tissuecyte_electrodes_table( ] + ( [ - "raw_location", "raw_structure", ] - if "raw_location" in session_electrodes.columns + if "raw_structure" in session_electrodes.columns else [] ) ]