Skip to content

Commit

Permalink
add columns to dict and then convert to dataframe to prevent warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanharvey1 committed Sep 26, 2024
1 parent e11cbee commit c214eec
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions neuro_py/io/loading.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ def un_nest_df(df):
data = sio.loadmat(filename)

# construct data frame with features per neuron
df = pd.DataFrame()
df = {}
# count units
n_cells = data["cell_metrics"]["UID"][0][0][0].size
dt = data["cell_metrics"].dtype
Expand All @@ -497,11 +497,17 @@ def un_nest_df(df):
try:
if (data["cell_metrics"][dn][0][0][0][0].size == 1) & (
data["cell_metrics"][dn][0][0][0].size == n_cells
):
df[dn] = data["cell_metrics"][dn][0][0][0]
):
# check if nested within brackets
try:
df[dn] = list(chain(*data["cell_metrics"][dn][0][0][0]))
except Exception:
df[dn] = data["cell_metrics"][dn][0][0][0]
except Exception:
continue

df = pd.DataFrame(df)

# load in tag
# check if tags exist within cell_metrics
if "tags" in data.get("cell_metrics").dtype.names:
Expand Down

0 comments on commit c214eec

Please sign in to comment.