From bdce47bd10ccf0ac2114dff934b940d6b289c007 Mon Sep 17 00:00:00 2001 From: Christopher Morrison Date: Fri, 27 Oct 2023 18:16:31 -0700 Subject: [PATCH] Add column order to lims. --- .../data_io/behavior_project_lims_api.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/allensdk/brain_observatory/behavior/behavior_project_cache/project_apis/data_io/behavior_project_lims_api.py b/allensdk/brain_observatory/behavior/behavior_project_cache/project_apis/data_io/behavior_project_lims_api.py index e4bfffadd..6ec30ed5c 100644 --- a/allensdk/brain_observatory/behavior/behavior_project_cache/project_apis/data_io/behavior_project_lims_api.py +++ b/allensdk/brain_observatory/behavior/behavior_project_cache/project_apis/data_io/behavior_project_lims_api.py @@ -24,7 +24,10 @@ build_in_list_selector_query, build_where_clause, ) -from allensdk.core.dataframe_utils import enforce_df_int_typing +from allensdk.core.dataframe_utils import ( + enforce_df_column_order, + enforce_df_int_typing +) from allensdk.brain_observatory.ophys.project_constants import ( VBO_METADATA_COLUMN_ORDER, VBO_INTEGER_COLUMNS @@ -390,6 +393,7 @@ def _get_ophys_experiment_table(self) -> pd.DataFrame: targeted_imaging_depth.columns = ["targeted_imaging_depth"] df = query_df.merge(targeted_imaging_depth, on="ophys_container_id") df = enforce_df_int_typing(df, VBO_INTEGER_COLUMNS) + df = enforce_df_column_order(df, VBO_METADATA_COLUMN_ORDER) return df def _get_ophys_cells_table(self): @@ -508,6 +512,7 @@ def get_ophys_session_table(self) -> pd.DataFrame: # Fill NaN values of imaging_plane_group_count with zero to match # the behavior of the BehaviorOphysExperiment object. table = enforce_df_int_typing(table, VBO_INTEGER_COLUMNS) + table = enforce_df_column_order(table, VBO_METADATA_COLUMN_ORDER) return table def get_behavior_session( @@ -540,6 +545,8 @@ def get_ophys_experiment_table(self) -> pd.DataFrame: # Set type to pandas.Int64 to enforce integer typing and not revert to # float. df = enforce_df_int_typing(df, VBO_INTEGER_COLUMNS) + df = enforce_df_column_order(df, VBO_METADATA_COLUMN_ORDER) + return df.set_index("ophys_experiment_id") def get_behavior_session_table(self) -> pd.DataFrame: @@ -561,6 +568,10 @@ def get_behavior_session_table(self) -> pd.DataFrame: # Query returns float typing of age_in_days. Convert to int to match # typing of the Age data_object. summary_tbl = enforce_df_int_typing(summary_tbl, VBO_INTEGER_COLUMNS) + summary_tbl = enforce_df_column_order( + summary_tbl, + VBO_METADATA_COLUMN_ORDER + ) return summary_tbl.set_index("behavior_session_id")